diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInventoryBase.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInventoryBase.java index 6040486c2..c2ec09bad 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInventoryBase.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInventoryBase.java @@ -31,9 +31,13 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements this.slots = new ItemStack[slots]; if(this.hasInvWrapperCapabilities()){ - for(int i = 0; i < this.invWrappers.length; i++){ - this.invWrappers[i] = new SidedInvWrapper(this, EnumFacing.values()[i]); - } + this.getInvWrappers(this.invWrappers); + } + } + + protected void getInvWrappers(SidedInvWrapper[] wrappers){ + for(int i = 0; i < wrappers.length; i++){ + wrappers[i] = new SidedInvWrapper(this, EnumFacing.values()[i]); } } 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 ebce0c0f3..b7e4efd9a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemViewer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemViewer.java @@ -18,6 +18,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraftforge.items.IItemHandler; +import net.minecraftforge.items.wrapper.SidedInvWrapper; import java.util.ArrayList; import java.util.Collections; @@ -36,6 +37,35 @@ public class TileEntityItemViewer extends TileEntityInventoryBase{ super.updateEntity(); } + @Override + protected void getInvWrappers(SidedInvWrapper[] wrappers){ + for(int i = 0; i < wrappers.length; i++){ + wrappers[i] = new SidedInvWrapper(this, EnumFacing.values()[i]){ + @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); + } + } + + @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); + } + } + }; + } + } + private List getItemHandlerInfos(){ TileEntityLaserRelayItem relay = this.connectedRelay; if(relay != null){