fix storage/monitors wrong item count and interactions
This commit is contained in:
+1
-1
@@ -3,7 +3,7 @@ aechannel=stable
|
|||||||
aebuild=7
|
aebuild=7
|
||||||
aegroup=appeng
|
aegroup=appeng
|
||||||
aebasename=appliedenergistics2
|
aebasename=appliedenergistics2
|
||||||
trousers=omni-fixes-v46f
|
trousers=omni-fixes-v46g
|
||||||
|
|
||||||
#########################################################
|
#########################################################
|
||||||
# Versions #
|
# Versions #
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
|
|||||||
|
|
||||||
private IAEItemStack configuredItem;
|
private IAEItemStack configuredItem;
|
||||||
private IAEFluidStack configuredFluid;
|
private IAEFluidStack configuredFluid;
|
||||||
|
private long configuredAmount;
|
||||||
private String lastHumanReadableText;
|
private String lastHumanReadableText;
|
||||||
private boolean isLocked;
|
private boolean isLocked;
|
||||||
private IStackWatcher myWatcher;
|
private IStackWatcher myWatcher;
|
||||||
@@ -211,11 +212,11 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
|
|||||||
if (fluidInTank == null)
|
if (fluidInTank == null)
|
||||||
{
|
{
|
||||||
this.configuredFluid = null;
|
this.configuredFluid = null;
|
||||||
this.configuredItem = AEItemStack.fromItemStack( eq );
|
this.configuredItem = AEItemStack.fromItemStack( eq ).setStackSize( 0 );
|
||||||
}
|
}
|
||||||
else if( fluidInTank.amount > 0 )
|
else if( fluidInTank.amount > 0 )
|
||||||
{
|
{
|
||||||
this.configuredFluid = AEFluidStack.fromFluidStack( fluidInTank );
|
this.configuredFluid = AEFluidStack.fromFluidStack( fluidInTank ).setStackSize( 0 );
|
||||||
this.configuredItem = null;
|
this.configuredItem = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,11 +306,11 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
|
|||||||
final IAEItemStack result = (IAEItemStack) monitor.getStorageList().findPrecise( (T) this.configuredItem );
|
final IAEItemStack result = (IAEItemStack) monitor.getStorageList().findPrecise( (T) this.configuredItem );
|
||||||
if( result == null )
|
if( result == null )
|
||||||
{
|
{
|
||||||
this.configuredItem.setStackSize( 0 );
|
this.configuredAmount = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.configuredItem.setStackSize( result.getStackSize() );
|
this.configuredAmount = result.getStackSize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( this.configuredFluid != null)
|
else if( this.configuredFluid != null)
|
||||||
@@ -317,11 +318,11 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
|
|||||||
final IAEFluidStack result = (IAEFluidStack) monitor.getStorageList().findPrecise( (T) this.configuredFluid );
|
final IAEFluidStack result = (IAEFluidStack) monitor.getStorageList().findPrecise( (T) this.configuredFluid );
|
||||||
if( result == null )
|
if( result == null )
|
||||||
{
|
{
|
||||||
this.configuredFluid.setStackSize( 0 );
|
this.configuredAmount = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.configuredFluid.setStackSize( result.getStackSize() );
|
this.configuredAmount = result.getStackSize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -390,108 +391,35 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
|
|||||||
@MENetworkEventSubscribe
|
@MENetworkEventSubscribe
|
||||||
public void powerStatusChange( final MENetworkPowerStatusChange ev )
|
public void powerStatusChange( final MENetworkPowerStatusChange ev )
|
||||||
{
|
{
|
||||||
if( !this.getProxy().isPowered() )
|
if( this.getProxy().isPowered() )
|
||||||
{
|
{
|
||||||
if( this.myWatcher != null )
|
this.configureWatchers();
|
||||||
{
|
|
||||||
if( this.configuredItem != null )
|
|
||||||
{
|
|
||||||
this.configuredItem.setStackSize( 0 );
|
|
||||||
}
|
|
||||||
if( this.configuredFluid != null )
|
|
||||||
{
|
|
||||||
this.configuredFluid.setStackSize( 0 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if( this.configuredItem != null )
|
|
||||||
{
|
|
||||||
this.updateReportingValue( this.getProxy().getStorage().getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ) );
|
|
||||||
}
|
|
||||||
if( this.configuredFluid != null )
|
|
||||||
{
|
|
||||||
this.updateReportingValue( this.getProxy().getStorage().getInventory( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch( final GridAccessException e )
|
|
||||||
{
|
|
||||||
// ;P
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@MENetworkEventSubscribe
|
@MENetworkEventSubscribe
|
||||||
public void channelChanged( final MENetworkChannelsChanged c )
|
public void channelChanged( final MENetworkChannelsChanged c )
|
||||||
{
|
{
|
||||||
if( !this.getProxy().isPowered() )
|
if( this.getProxy().isPowered() )
|
||||||
{
|
{
|
||||||
if( this.myWatcher != null )
|
this.configureWatchers();
|
||||||
{
|
|
||||||
if( this.configuredItem != null )
|
|
||||||
{
|
|
||||||
this.configuredItem.setStackSize( 0 );
|
|
||||||
}
|
|
||||||
if( this.configuredFluid != null )
|
|
||||||
{
|
|
||||||
this.configuredFluid.setStackSize( 0 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if( this.configuredItem != null )
|
|
||||||
{
|
|
||||||
this.updateReportingValue( this.getProxy().getStorage().getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ) );
|
|
||||||
}
|
|
||||||
if( this.configuredFluid != null )
|
|
||||||
{
|
|
||||||
this.updateReportingValue( this.getProxy().getStorage().getInventory( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch( final GridAccessException e )
|
|
||||||
{
|
|
||||||
// ;P
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStackChange( IItemList<?> o, IAEStack<?> fullStack, IAEStack<?> diffStack, IActionSource src, IStorageChannel<?> chan )
|
public void onStackChange( IItemList<?> o, IAEStack<?> fullStack, IAEStack<?> diffStack, IActionSource src, IStorageChannel<?> chan )
|
||||||
{
|
{
|
||||||
|
this.configuredAmount = this.configuredAmount + diffStack.getStackSize();
|
||||||
|
|
||||||
if( this.configuredItem != null )
|
if( this.configuredItem != null )
|
||||||
{
|
{
|
||||||
long diff = this.configuredItem.getStackSize() + diffStack.getStackSize();
|
this.configuredItem.setStackSize( this.configuredAmount );
|
||||||
this.configuredItem.setStackSize( diff >= 0 ? this.configuredItem.getStackSize() + diffStack.getStackSize() : 0 );
|
|
||||||
|
|
||||||
final long stackSize = this.configuredItem.getStackSize();
|
|
||||||
final String humanReadableText = NUMBER_CONVERTER.toWideReadableForm( stackSize );
|
|
||||||
|
|
||||||
if( !humanReadableText.equals( this.lastHumanReadableText ) )
|
|
||||||
{
|
|
||||||
this.lastHumanReadableText = humanReadableText;
|
|
||||||
this.getHost().markForUpdate();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if( this.configuredFluid != null )
|
else if( this.configuredFluid != null )
|
||||||
{
|
{
|
||||||
long diff = this.configuredFluid.getStackSize() + diffStack.getStackSize();
|
this.configuredFluid.setStackSize( this.configuredAmount );
|
||||||
this.configuredFluid.setStackSize( diff >= 0 ? this.configuredFluid.getStackSize() + diffStack.getStackSize() : 0 );
|
|
||||||
|
|
||||||
final long stackSize = this.configuredFluid.getStackSize() / 1000;
|
|
||||||
final String humanReadableText = NUMBER_CONVERTER.toWideReadableForm( stackSize ) + "B";
|
|
||||||
|
|
||||||
if( !humanReadableText.equals( this.lastHumanReadableText ) )
|
|
||||||
{
|
|
||||||
this.lastHumanReadableText = humanReadableText;
|
|
||||||
this.getHost().markForUpdate();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
this.getHost().markForUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -137,14 +137,15 @@ public class PartConversionMonitor extends AbstractPartMonitor
|
|||||||
{
|
{
|
||||||
this.insertItem( player, hand, false );
|
this.insertItem( player, hand, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//If its a fluid container, grab its fluidstack. if its empty pass its itemstack;
|
//If its a fluid container, grab its fluidstack. if its empty pass its itemstack;
|
||||||
|
|
||||||
if (eq.isEmpty()){
|
if( eq.isEmpty() )
|
||||||
|
{
|
||||||
return super.onPartActivate( player, hand, pos );
|
return super.onPartActivate( player, hand, pos );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( fluidInTank != null && fluidInTank.amount > 0 )
|
if( fluidInTank != null && fluidInTank.amount > 0 )
|
||||||
{
|
{
|
||||||
if( getDisplayed() instanceof IAEItemStack || getDisplayed() == null )
|
if( getDisplayed() instanceof IAEItemStack || getDisplayed() == null )
|
||||||
@@ -155,22 +156,19 @@ public class PartConversionMonitor extends AbstractPartMonitor
|
|||||||
{
|
{
|
||||||
this.drainFluidContainer( player, hand );
|
this.drainFluidContainer( player, hand );
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
return super.onPartActivate( player, hand, pos );
|
return super.onPartActivate( player, hand, pos );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if( this.getDisplayed() != null && this.getDisplayed().equals( eq ) )
|
||||||
|
{
|
||||||
|
this.insertItem( player, hand, false );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( getDisplayed() instanceof IAEFluidStack || getDisplayed() == null )
|
return super.onPartActivate( player, hand, pos );
|
||||||
{
|
|
||||||
return super.onPartActivate( player, hand, pos );
|
|
||||||
}
|
|
||||||
if( ( (IAEItemStack) this.getDisplayed() ).equals( eq ) )
|
|
||||||
{
|
|
||||||
this.insertItem( player, hand, false );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,7 +190,6 @@ public class PartConversionMonitor extends AbstractPartMonitor
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack eq = player.getHeldItem( hand );
|
|
||||||
if( this.getDisplayed() != null && this.getDisplayed() instanceof IAEItemStack )
|
if( this.getDisplayed() != null && this.getDisplayed() instanceof IAEItemStack )
|
||||||
{
|
{
|
||||||
this.extractItem( player, ( (IAEItemStack) this.getDisplayed() ).getDefinition().getMaxStackSize() );
|
this.extractItem( player, ( (IAEItemStack) this.getDisplayed() ).getDefinition().getMaxStackSize() );
|
||||||
@@ -282,7 +279,7 @@ public class PartConversionMonitor extends AbstractPartMonitor
|
|||||||
{
|
{
|
||||||
if (!(this.getDisplayed() instanceof IAEItemStack))
|
if (!(this.getDisplayed() instanceof IAEItemStack))
|
||||||
return;
|
return;
|
||||||
final IAEItemStack input = (IAEItemStack) this.getDisplayed();
|
final IAEItemStack input = (IAEItemStack) this.getDisplayed().copy();
|
||||||
if( input != null )
|
if( input != null )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
Reference in New Issue
Block a user