From d24a09ad67aa8f91ca663b3bbc4871e35b8cb8ac Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Tue, 11 Oct 2016 14:24:18 +0200 Subject: [PATCH] Supposedly fix a bug with item interfaces ignoring whitelisting --- .../mod/tile/TileEntityItemViewer.java | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemViewer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemViewer.java index b7e4efd9a..84f3e5c3d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemViewer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemViewer.java @@ -40,27 +40,31 @@ public class TileEntityItemViewer extends TileEntityInventoryBase{ @Override protected void getInvWrappers(SidedInvWrapper[] wrappers){ for(int i = 0; i < wrappers.length; i++){ - wrappers[i] = new SidedInvWrapper(this, EnumFacing.values()[i]){ + final EnumFacing direction = EnumFacing.values()[i]; + wrappers[i] = new SidedInvWrapper(this, direction){ @Override public ItemStack insertItem(int slot, ItemStack stack, boolean simulate){ - SpecificItemHandlerInfo info = TileEntityItemViewer.this.getSwitchedIndexHandler(slot); - if(info != null){ - return info.handler.insertItem(info.switchedIndex, stack, simulate); - } - else{ - return super.insertItem(slot, stack, simulate); + if(TileEntityItemViewer.this.canInsertItem(slot, stack, direction)){ + SpecificItemHandlerInfo info = TileEntityItemViewer.this.getSwitchedIndexHandler(slot); + if(info != null){ + return info.handler.insertItem(info.switchedIndex, stack, simulate); + } } + return super.insertItem(slot, stack, simulate); } @Override public ItemStack extractItem(int slot, int amount, boolean simulate){ - SpecificItemHandlerInfo info = TileEntityItemViewer.this.getSwitchedIndexHandler(slot); - if(info != null){ - return info.handler.extractItem(info.switchedIndex, amount, simulate); - } - else{ - return super.extractItem(slot, amount, simulate); + ItemStack stackIn = TileEntityItemViewer.this.getStackInSlot(slot); + if(stackIn != null){ + if(TileEntityItemViewer.this.canExtractItem(slot, stackIn, direction)){ + SpecificItemHandlerInfo info = TileEntityItemViewer.this.getSwitchedIndexHandler(slot); + if(info != null){ + return info.handler.extractItem(info.switchedIndex, amount, simulate); + } + } } + return super.extractItem(slot, amount, simulate); } }; }