WIP
This commit is contained in:
@@ -85,11 +85,7 @@ public class MEMonitorHandler<T extends IAEStack<T>> implements IMEMonitor<T>
|
||||
@Override
|
||||
public T injectItems( final T input, final Actionable mode, final IActionSource src )
|
||||
{
|
||||
if( mode == Actionable.SIMULATE )
|
||||
{
|
||||
return this.getHandler().injectItems( input, mode, src );
|
||||
}
|
||||
return this.monitorDifference( input.copy(), this.getHandler().injectItems( input, mode, src ), false, src );
|
||||
return this.getHandler().injectItems( input, mode, src );
|
||||
}
|
||||
|
||||
protected IMEInventoryHandler<T> getHandler()
|
||||
@@ -97,27 +93,6 @@ public class MEMonitorHandler<T extends IAEStack<T>> implements IMEMonitor<T>
|
||||
return this.internalHandler;
|
||||
}
|
||||
|
||||
private T monitorDifference( final T original, final T leftOvers, final boolean extraction, final IActionSource src )
|
||||
{
|
||||
final T diff = original.copy();
|
||||
|
||||
if( extraction )
|
||||
{
|
||||
diff.setStackSize( leftOvers == null ? 0 : -leftOvers.getStackSize() );
|
||||
}
|
||||
else if( leftOvers != null )
|
||||
{
|
||||
diff.decStackSize( leftOvers.getStackSize() );
|
||||
}
|
||||
|
||||
if( diff.getStackSize() != 0 )
|
||||
{
|
||||
this.postChangesToListeners( ImmutableList.of( diff ), src );
|
||||
}
|
||||
|
||||
return leftOvers;
|
||||
}
|
||||
|
||||
protected void postChangesToListeners( final Iterable<T> changes, final IActionSource src )
|
||||
{
|
||||
this.notifyListenersOfChange( changes, src );
|
||||
@@ -150,11 +125,7 @@ public class MEMonitorHandler<T extends IAEStack<T>> implements IMEMonitor<T>
|
||||
@Override
|
||||
public T extractItems( final T request, final Actionable mode, final IActionSource src )
|
||||
{
|
||||
if( mode == Actionable.SIMULATE )
|
||||
{
|
||||
return this.getHandler().extractItems( request, mode, src );
|
||||
}
|
||||
return this.monitorDifference( request.copy(), this.getHandler().extractItems( request, mode, src ), true, src );
|
||||
return this.getHandler().extractItems( request, mode, src );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package appeng.me.storage;
|
||||
|
||||
|
||||
import appeng.core.features.registries.cell.CreativeCellHandler;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.helpers.MachineSource;
|
||||
import appeng.tile.storage.TileDrive;
|
||||
@@ -73,7 +74,7 @@ public class DriveWatcher<T extends IAEStack<T>> extends MEInventoryHandler<T>
|
||||
this.drive.blinkCell( this.getSlot() );
|
||||
this.oldStatus = newStatus;
|
||||
}
|
||||
if (this.drive.getProxy().isActive())
|
||||
if (this.drive.getProxy().isActive() && !(handler instanceof CreativeCellHandler))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -102,7 +103,7 @@ public class DriveWatcher<T extends IAEStack<T>> extends MEInventoryHandler<T>
|
||||
this.drive.blinkCell( this.getSlot() );
|
||||
this.oldStatus = newStatus;
|
||||
}
|
||||
if (this.drive.getProxy().isActive())
|
||||
if (this.drive.getProxy().isActive() && !(handler instanceof CreativeCellHandler ))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -26,6 +26,8 @@ import java.util.List;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.me.storage.BasicCellInventoryHandler;
|
||||
import appeng.me.storage.CreativeCellInventory;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -735,7 +737,24 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
||||
{
|
||||
return input;
|
||||
}
|
||||
return super.injectItems( input, mode, src );
|
||||
T injected = super.injectItems( input, mode, src );
|
||||
if (mode == Actionable.MODULATE && ( injected == null || injected.getStackSize() != input.getStackSize() ))
|
||||
{
|
||||
if( TileChest.this.getProxy().isActive() && this.getInternalHandler().getCellInv() != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
TileChest.this.getProxy().getStorage().postAlterationOfStoredItems(
|
||||
this.getChannel(),
|
||||
Collections.singletonList( input.copy().setStackSize( input.getStackSize() - ( injected == null ? 0 : injected.getStackSize() ) ) ),
|
||||
TileChest.this.mySrc );
|
||||
} catch ( GridAccessException e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return injected;
|
||||
}
|
||||
|
||||
private boolean securityCheck( final EntityPlayer player, final SecurityPermissions requiredPermission )
|
||||
@@ -779,7 +798,24 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return super.extractItems( request, mode, src );
|
||||
T extracted = super.extractItems( request, mode, src );
|
||||
if( mode == Actionable.MODULATE && extracted != null )
|
||||
{
|
||||
if( TileChest.this.getProxy().isActive() && this.getInternalHandler().getCellInv() != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
TileChest.this.getProxy().getStorage().postAlterationOfStoredItems(
|
||||
this.getChannel(),
|
||||
Collections.singletonList( request.copy().setStackSize( -extracted.getStackSize() ) ),
|
||||
TileChest.this.mySrc );
|
||||
} catch ( GridAccessException e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return extracted;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user