From 4615a94339ecaf1e7fd3bf698c22e9330caacfdd Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sat, 4 Feb 2017 14:12:17 +0100 Subject: [PATCH] Implemented slotless item handler compat (untested!) --- build.gradle | 4 + .../mod/ActuallyAdditions.java | 10 +- .../mod/tile/TileEntityInputter.java | 115 ++++++++++-------- .../mod/tile/TileEntityItemViewer.java | 112 +++++++++++++---- .../mod/tile/TileEntityItemViewerHopping.java | 90 +++++++++----- .../mod/tile/TileEntityLaserRelayItem.java | 27 +++- .../TileEntityLaserRelayItemWhitelist.java | 68 ++++++----- .../actuallyadditions/mod/util/WorldUtil.java | 84 ++++++++++++- .../mod/util/compat/CommonCapsUtil.java | 105 ++++++++++++++++ .../SlotlessableItemHandlerWrapper.java | 32 +++++ 10 files changed, 492 insertions(+), 155 deletions(-) create mode 100644 src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/CommonCapsUtil.java create mode 100644 src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/SlotlessableItemHandlerWrapper.java diff --git a/build.gradle b/build.gradle index 25f527342..61fefd5c0 100644 --- a/build.gradle +++ b/build.gradle @@ -41,11 +41,15 @@ repositories { maven { url "http://maven.epoxide.xyz" } + maven { + url "https://dl.bintray.com/cyclopsmc/dev/" + } } dependencies { compile "net.darkhax.tesla:Tesla:1.11-1.3.0.51" deobfCompile "mezz.jei:jei_1.11:4.1.1.206" + deobfCompile "org.cyclops.commoncapabilities:CommonCapabilities:1.11.2-1.3.0-81" } processResources { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyAdditions.java b/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyAdditions.java index f3cfd72a7..6c023a006 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyAdditions.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyAdditions.java @@ -68,6 +68,7 @@ public class ActuallyAdditions{ public static IProxy proxy; public static boolean teslaLoaded; + public static boolean commonCapsLoaded; static{ //For some reason, this has to be done here @@ -83,13 +84,8 @@ public class ActuallyAdditions{ Lenses.init(); InitBooklet.preInit(); - if(Loader.isModLoaded("tesla")){ - ModUtil.LOGGER.info("Tesla loaded... Activating Tesla Power System integration..."); - teslaLoaded = true; - } - else{ - ModUtil.LOGGER.info("Tesla not found! Skipping Tesla Power System integration."); - } + teslaLoaded = Loader.isModLoaded("tesla"); + commonCapsLoaded = Loader.isModLoaded("commoncapabilities"); new ConfigurationHandler(event.getSuggestedConfigurationFile()); PacketHandler.init(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInputter.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInputter.java index 2d2ee95a7..a69742391 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInputter.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInputter.java @@ -11,10 +11,12 @@ package de.ellpeck.actuallyadditions.mod.tile; +import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor; import de.ellpeck.actuallyadditions.mod.network.gui.INumberReactor; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.WorldUtil; +import de.ellpeck.actuallyadditions.mod.util.compat.SlotlessableItemHandlerWrapper; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -23,6 +25,10 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; +import org.cyclops.commoncapabilities.capability.itemhandler.SlotlessItemHandlerConfig; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; public class TileEntityInputter extends TileEntityInventoryBase implements IButtonReactor, INumberReactor{ @@ -30,11 +36,11 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt public int sideToPut = -1; public int slotToPutStart; public int slotToPutEnd; - public TileEntity placeToPut; + public Map placeToPut = new ConcurrentHashMap(); public int sideToPull = -1; public int slotToPullStart; public int slotToPullEnd; - public TileEntity placeToPull; + public Map placeToPull = new ConcurrentHashMap(); public boolean isAdvanced; public FilterSettings leftFilter = new FilterSettings(12, true, true, false, false, 0, -1000); public FilterSettings rightFilter = new FilterSettings(12, true, true, false, false, 0, -2000); @@ -44,6 +50,7 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt private int lastPullSide; private int lastPullStart; private int lastPullEnd; + private final SlotlessableItemHandlerWrapper wrapper = new SlotlessableItemHandlerWrapper(this.slots, null); public TileEntityInputter(int slots, String name){ super(slots, name); @@ -77,19 +84,8 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt } private boolean newPulling(){ - for(EnumFacing side : EnumFacing.values()){ - if(this.placeToPull.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side)){ - IItemHandler cap = this.placeToPull.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side); - if(cap != null){ - for(int i = Math.max(this.slotToPullStart, 0); i < Math.min(this.slotToPullEnd, cap.getSlots()); i++){ - if(this.checkBothFilters(cap.getStackInSlot(i), false)){ - if(WorldUtil.doItemInteraction(i, 0, cap, this.slots, Integer.MAX_VALUE)){ - return true; - } - } - } - } - } + for(EnumFacing side : this.placeToPull.keySet()){ + WorldUtil.doItemInteraction(this.placeToPull.get(side), this.wrapper, Integer.MAX_VALUE, this.slotToPullStart, this.slotToPullEnd, !this.isAdvanced ? null : this.leftFilter); if(this.placeToPull instanceof TileEntityItemViewer){ break; @@ -99,18 +95,9 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt } private boolean newPutting(){ - if(this.checkBothFilters(this.slots.getStackInSlot(0), true)){ - for(EnumFacing side : EnumFacing.values()){ - if(this.placeToPut.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side)){ - IItemHandler cap = this.placeToPut.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side); - if(cap != null){ - for(int i = Math.max(this.slotToPutStart, 0); i < Math.min(this.slotToPutEnd, cap.getSlots()); i++){ - if(WorldUtil.doItemInteraction(0, i, this.slots, cap, Integer.MAX_VALUE)){ - return true; - } - } - } - } + if(!this.isAdvanced || this.rightFilter.check(this.slots.getStackInSlot(0))){ + for(EnumFacing side : this.placeToPut.keySet()){ + WorldUtil.doItemInteraction(this.wrapper, this.placeToPut.get(side), Integer.MAX_VALUE, this.slotToPutStart, this.slotToPutEnd, null); if(this.placeToPut instanceof TileEntityItemViewer){ break; @@ -120,16 +107,6 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt return false; } - /** - * Checks if one of the filters contains the ItemStack - * - * @param stack The ItemStack - * @return If the Item is filtered correctly - */ - private boolean checkBothFilters(ItemStack stack, boolean output){ - return !this.isAdvanced || (output ? this.rightFilter : this.leftFilter).check(stack); - } - @Override public boolean shouldSaveDataOnChangeOrWorldStart(){ return true; @@ -140,21 +117,39 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt */ @Override public void saveDataOnChangeOrWorldStart(){ - this.placeToPull = null; - this.placeToPut = null; + this.placeToPull.clear(); + this.placeToPut.clear(); if(this.sideToPull != -1){ EnumFacing side = WorldUtil.getDirectionBySidesInOrder(this.sideToPull); BlockPos offset = this.pos.offset(side); if(this.world.isBlockLoaded(offset)){ - this.placeToPull = this.world.getTileEntity(offset); + TileEntity tile = this.world.getTileEntity(offset); - if(this.slotToPullEnd <= 0 && this.placeToPull != null){ - if(this.placeToPull.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null)){ - IItemHandler cap = this.placeToPull.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); - if(cap != null){ - this.slotToPullEnd = cap.getSlots(); + if(tile != null){ + for(EnumFacing facing : EnumFacing.values()){ + IItemHandler normal = null; + if(tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing)){ + normal = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing); + } + + Object slotless = null; + if(ActuallyAdditions.commonCapsLoaded){ + if(tile.hasCapability(SlotlessItemHandlerConfig.CAPABILITY, facing)){ + slotless = tile.getCapability(SlotlessItemHandlerConfig.CAPABILITY, facing); + } + } + + this.placeToPull.put(facing.getOpposite(), new SlotlessableItemHandlerWrapper(normal, slotless)); + } + + if(this.slotToPullEnd <= 0){ + if(tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null)){ + IItemHandler cap = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); + if(cap != null){ + this.slotToPullEnd = cap.getSlots(); + } } } } @@ -166,13 +161,31 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt BlockPos offset = this.pos.offset(side); if(this.world.isBlockLoaded(offset)){ - this.placeToPut = this.world.getTileEntity(offset); + TileEntity tile = this.world.getTileEntity(offset); - if(this.slotToPutEnd <= 0 && this.placeToPut != null){ - if(this.placeToPut.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null)){ - IItemHandler cap = this.placeToPut.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); - if(cap != null){ - this.slotToPutEnd = cap.getSlots(); + if(tile != null){ + for(EnumFacing facing : EnumFacing.values()){ + IItemHandler normal = null; + if(tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing)){ + normal = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing); + } + + Object slotless = null; + if(ActuallyAdditions.commonCapsLoaded){ + if(tile.hasCapability(SlotlessItemHandlerConfig.CAPABILITY, facing)){ + slotless = tile.getCapability(SlotlessItemHandlerConfig.CAPABILITY, facing); + } + } + + this.placeToPut.put(facing.getOpposite(), new SlotlessableItemHandlerWrapper(normal, slotless)); + } + + if(this.slotToPutEnd <= 0){ + if(tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null)){ + IItemHandler cap = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); + if(cap != null){ + this.slotToPutEnd = cap.getSlots(); + } } } } 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 d25c61793..a17443b55 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemViewer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemViewer.java @@ -11,32 +11,39 @@ package de.ellpeck.actuallyadditions.mod.tile; import de.ellpeck.actuallyadditions.api.laser.Network; +import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.network.PacketHandler; import de.ellpeck.actuallyadditions.mod.network.PacketServerToClient; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.WorldUtil; +import de.ellpeck.actuallyadditions.mod.util.compat.CommonCapsUtil; +import de.ellpeck.actuallyadditions.mod.util.compat.SlotlessableItemHandlerWrapper; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; +import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint; import net.minecraftforge.items.IItemHandler; +import org.cyclops.commoncapabilities.api.capability.itemhandler.ISlotlessItemHandler; +import org.cyclops.commoncapabilities.capability.itemhandler.SlotlessItemHandlerConfig; import java.util.*; public class TileEntityItemViewer extends TileEntityBase{ - protected final IItemHandler itemHandler; - private final List genericInfos = new ArrayList(); - private final Map specificInfos = new HashMap(); + protected final SlotlessableItemHandlerWrapper itemHandler; + public final List genericInfos = new ArrayList(); + public final Map itemHandlerInfos = new HashMap(); + public final List slotlessInfos = new ArrayList(); public TileEntityLaserRelayItem connectedRelay; private int lastNetworkChangeAmount = -1; public TileEntityItemViewer(String name){ super(name); - this.itemHandler = new IItemHandler(){ + IItemHandler normalHandler = new IItemHandler(){ @Override public int getSlots(){ int size = 0; @@ -44,8 +51,11 @@ public class TileEntityItemViewer extends TileEntityBase{ if(infos != null){ for(GenericItemHandlerInfo info : infos){ if(info.isLoaded()){ - for(IItemHandler handler : info.handlers){ - size += handler.getSlots(); + for(SlotlessableItemHandlerWrapper handler : info.handlers){ + IItemHandler normalHandler = handler.getNormalHandler(); + if(normalHandler != null){ + size += normalHandler.getSlots(); + } } } } @@ -55,7 +65,7 @@ public class TileEntityItemViewer extends TileEntityBase{ @Override public ItemStack getStackInSlot(int slot){ - SpecificItemHandlerInfo handler = TileEntityItemViewer.this.getSwitchedIndexHandler(slot); + IItemHandlerInfo handler = TileEntityItemViewer.this.getSwitchedIndexHandler(slot); if(handler != null && handler.isLoaded()){ return handler.handler.getStackInSlot(handler.switchedIndex); } @@ -64,7 +74,7 @@ public class TileEntityItemViewer extends TileEntityBase{ @Override public ItemStack insertItem(int slot, ItemStack stack, boolean simulate){ - SpecificItemHandlerInfo info = TileEntityItemViewer.this.getSwitchedIndexHandler(slot); + IItemHandlerInfo info = TileEntityItemViewer.this.getSwitchedIndexHandler(slot); if(info != null && info.isLoaded() && TileEntityItemViewer.this.isWhitelisted(info, stack, false)){ ItemStack remain = info.handler.insertItem(info.switchedIndex, stack, simulate); if(!ItemStack.areItemStacksEqual(remain, stack) && !simulate){ @@ -80,7 +90,7 @@ public class TileEntityItemViewer extends TileEntityBase{ public ItemStack extractItem(int slot, int amount, boolean simulate){ ItemStack stackIn = this.getStackInSlot(slot); if(StackUtil.isValid(stackIn)){ - SpecificItemHandlerInfo info = TileEntityItemViewer.this.getSwitchedIndexHandler(slot); + IItemHandlerInfo info = TileEntityItemViewer.this.getSwitchedIndexHandler(slot); if(info != null && info.isLoaded() && TileEntityItemViewer.this.isWhitelisted(info, stackIn, true)){ ItemStack extracted = info.handler.extractItem(info.switchedIndex, amount, simulate); if(StackUtil.isValid(extracted) && !simulate){ @@ -95,7 +105,7 @@ public class TileEntityItemViewer extends TileEntityBase{ @Override public int getSlotLimit(int slot){ - SpecificItemHandlerInfo info = TileEntityItemViewer.this.getSwitchedIndexHandler(slot); + IItemHandlerInfo info = TileEntityItemViewer.this.getSwitchedIndexHandler(slot); if(info != null && info.isLoaded()){ return info.handler.getSlotLimit(info.switchedIndex); } @@ -104,6 +114,13 @@ public class TileEntityItemViewer extends TileEntityBase{ } } }; + + Object slotlessHandler = null; + if(ActuallyAdditions.commonCapsLoaded){ + slotlessHandler = CommonCapsUtil.createSlotlessItemViewerHandler(this, normalHandler); + } + + this.itemHandler = new SlotlessableItemHandlerWrapper(normalHandler, slotlessHandler); } public TileEntityItemViewer(){ @@ -112,7 +129,20 @@ public class TileEntityItemViewer extends TileEntityBase{ @Override public IItemHandler getItemHandler(EnumFacing facing){ - return this.itemHandler; + return this.itemHandler.getNormalHandler(); + } + + @Override + public T getCapability(Capability capability, EnumFacing facing){ + if(ActuallyAdditions.commonCapsLoaded){ + if(capability == SlotlessItemHandlerConfig.CAPABILITY){ + Object handler = this.itemHandler.getSlotlessHandler(); + if(handler != null){ + return (T)handler; + } + } + } + return super.getCapability(capability, facing); } private List getItemHandlerInfos(){ @@ -120,7 +150,7 @@ public class TileEntityItemViewer extends TileEntityBase{ return this.genericInfos; } - private void doItemParticle(ItemStack stack, BlockPos input, BlockPos output){ + public void doItemParticle(ItemStack stack, BlockPos input, BlockPos output){ if(!this.world.isRemote){ NBTTagCompound compound = new NBTTagCompound(); stack.writeToNBT(compound); @@ -150,10 +180,20 @@ public class TileEntityItemViewer extends TileEntityBase{ int slotsQueried = 0; for(GenericItemHandlerInfo info : this.genericInfos){ - for(IItemHandler handler : info.handlers){ - for(int i = 0; i < handler.getSlots(); i++){ - this.specificInfos.put(slotsQueried, new SpecificItemHandlerInfo(handler, i, info.relayInQuestion)); - slotsQueried++; + for(SlotlessableItemHandlerWrapper handler : info.handlers){ + IItemHandler normalHandler = handler.getNormalHandler(); + if(normalHandler != null){ + for(int i = 0; i < normalHandler.getSlots(); i++){ + this.itemHandlerInfos.put(slotsQueried, new IItemHandlerInfo(normalHandler, i, info.relayInQuestion)); + slotsQueried++; + } + } + + if(ActuallyAdditions.commonCapsLoaded){ + Object slotlessHandler = handler.getSlotlessHandler(); + if(slotlessHandler instanceof ISlotlessItemHandler){ + this.slotlessInfos.add(new SlotlessItemHandlerInfo(slotlessHandler, info.relayInQuestion)); + } } } } @@ -174,14 +214,18 @@ public class TileEntityItemViewer extends TileEntityBase{ this.genericInfos.clear(); } - if(!this.specificInfos.isEmpty()){ - this.specificInfos.clear(); + if(!this.itemHandlerInfos.isEmpty()){ + this.itemHandlerInfos.clear(); + } + + if(!this.slotlessInfos.isEmpty()){ + this.slotlessInfos.clear(); } } - private SpecificItemHandlerInfo getSwitchedIndexHandler(int i){ + private IItemHandlerInfo getSwitchedIndexHandler(int i){ this.queryAndSaveData(); - return this.specificInfos.get(i); + return this.itemHandlerInfos.get(i); } @Override @@ -215,7 +259,7 @@ public class TileEntityItemViewer extends TileEntityBase{ this.connectedRelay = tileFound; } - private boolean isWhitelisted(SpecificItemHandlerInfo handler, ItemStack stack, boolean output){ + public boolean isWhitelisted(SpecificItemHandlerInfo handler, ItemStack stack, boolean output){ boolean whitelisted = handler.relayInQuestion.isWhitelisted(stack, output); TileEntityLaserRelayItem connected = this.connectedRelay; if(connected != null && connected != handler.relayInQuestion){ @@ -226,15 +270,33 @@ public class TileEntityItemViewer extends TileEntityBase{ } } - private static class SpecificItemHandlerInfo{ + public static class SlotlessItemHandlerInfo extends SpecificItemHandlerInfo{ + + public final Object handler; + + public SlotlessItemHandlerInfo(Object handler, TileEntityLaserRelayItem relayInQuestion){ + super(relayInQuestion); + this.handler = handler; + } + } + + private static class IItemHandlerInfo extends SpecificItemHandlerInfo{ public final IItemHandler handler; public final int switchedIndex; - public final TileEntityLaserRelayItem relayInQuestion; - public SpecificItemHandlerInfo(IItemHandler handler, int switchedIndex, TileEntityLaserRelayItem relayInQuestion){ + public IItemHandlerInfo(IItemHandler handler, int switchedIndex, TileEntityLaserRelayItem relayInQuestion){ + super(relayInQuestion); this.handler = handler; this.switchedIndex = switchedIndex; + } + } + + private static class SpecificItemHandlerInfo{ + + public final TileEntityLaserRelayItem relayInQuestion; + + public SpecificItemHandlerInfo(TileEntityLaserRelayItem relayInQuestion){ this.relayInQuestion = relayInQuestion; } @@ -245,7 +307,7 @@ public class TileEntityItemViewer extends TileEntityBase{ public static class GenericItemHandlerInfo implements Comparable{ - public final List handlers = new ArrayList(); + public final List handlers = new ArrayList(); public final TileEntityLaserRelayItem relayInQuestion; public GenericItemHandlerInfo(TileEntityLaserRelayItem relayInQuestion){ diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemViewerHopping.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemViewerHopping.java index ad56f203f..1b6baca95 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemViewerHopping.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemViewerHopping.java @@ -10,8 +10,10 @@ package de.ellpeck.actuallyadditions.mod.tile; +import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.WorldUtil; +import de.ellpeck.actuallyadditions.mod.util.compat.SlotlessableItemHandlerWrapper; import net.minecraft.block.BlockHopper; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.item.EntityItem; @@ -22,13 +24,15 @@ import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; +import org.cyclops.commoncapabilities.api.capability.itemhandler.ISlotlessItemHandler; +import org.cyclops.commoncapabilities.capability.itemhandler.SlotlessItemHandlerConfig; import java.util.List; public class TileEntityItemViewerHopping extends TileEntityItemViewer{ - private IItemHandler handlerToPullFrom; - private IItemHandler handlerToPushTo; + private SlotlessableItemHandlerWrapper handlerToPullFrom; + private SlotlessableItemHandlerWrapper handlerToPushTo; public TileEntityItemViewerHopping(){ super("itemViewerHopping"); @@ -40,16 +44,7 @@ public class TileEntityItemViewerHopping extends TileEntityItemViewer{ if(!this.world.isRemote && this.world.getTotalWorldTime()%10 == 0){ if(this.handlerToPullFrom != null){ - outer: - for(int i = 0; i < this.handlerToPullFrom.getSlots(); i++){ - if(StackUtil.isValid(this.handlerToPullFrom.getStackInSlot(i))){ - for(int j = 0; j < this.itemHandler.getSlots(); j++){ - if(WorldUtil.doItemInteraction(i, j, this.handlerToPullFrom, this.itemHandler, 4)){ - break outer; - } - } - } - } + WorldUtil.doItemInteraction(this.handlerToPullFrom, this.itemHandler, 4); } else{ if(this.world.getTotalWorldTime()%20 == 0){ @@ -57,13 +52,29 @@ public class TileEntityItemViewerHopping extends TileEntityItemViewer{ if(items != null && !items.isEmpty()){ for(EntityItem item : items){ if(item != null && !item.isDead){ - for(int i = 0; i < this.itemHandler.getSlots(); i++){ - ItemStack left = this.itemHandler.insertItem(i, item.getEntityItem(), false); - item.setEntityItemStack(left); + if(ActuallyAdditions.commonCapsLoaded){ + Object slotless = this.itemHandler.getSlotlessHandler(); + if(slotless instanceof ISlotlessItemHandler){ + ItemStack left = ((ISlotlessItemHandler)slotless).insertItem(item.getEntityItem(), false); + item.setEntityItemStack(left); - if(!StackUtil.isValid(left)){ - item.setDead(); - break; + if(!StackUtil.isValid(left)){ + item.setDead(); + continue; + } + } + } + + IItemHandler handler = this.itemHandler.getNormalHandler(); + if(handler != null){ + for(int i = 0; i < handler.getSlots(); i++){ + ItemStack left = handler.insertItem(i, item.getEntityItem(), false); + item.setEntityItemStack(left); + + if(!StackUtil.isValid(left)){ + item.setDead(); + break; + } } } } @@ -73,16 +84,7 @@ public class TileEntityItemViewerHopping extends TileEntityItemViewer{ } if(this.handlerToPushTo != null){ - outer: - for(int i = 0; i < this.itemHandler.getSlots(); i++){ - if(StackUtil.isValid(this.itemHandler.getStackInSlot(i))){ - for(int j = 0; j < this.handlerToPushTo.getSlots(); j++){ - if(WorldUtil.doItemInteraction(i, j, this.itemHandler, this.handlerToPushTo, 4)){ - break outer; - } - } - } - } + WorldUtil.doItemInteraction(this.itemHandler, this.handlerToPushTo, 4); } } } @@ -95,8 +97,20 @@ public class TileEntityItemViewerHopping extends TileEntityItemViewer{ this.handlerToPushTo = null; TileEntity from = this.world.getTileEntity(this.pos.offset(EnumFacing.UP)); - if(from != null && !(from instanceof TileEntityItemViewer) && from.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN)){ - this.handlerToPullFrom = from.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN); + if(from != null && !(from instanceof TileEntityItemViewer)){ + IItemHandler normal = null; + if(from.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN)){ + normal = from.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN); + } + + Object slotless = null; + if(ActuallyAdditions.commonCapsLoaded){ + if(from.hasCapability(SlotlessItemHandlerConfig.CAPABILITY, EnumFacing.DOWN)){ + slotless = from.getCapability(SlotlessItemHandlerConfig.CAPABILITY, EnumFacing.DOWN); + } + } + + this.handlerToPullFrom = new SlotlessableItemHandlerWrapper(normal, slotless); } IBlockState state = this.world.getBlockState(this.pos); @@ -105,8 +119,20 @@ public class TileEntityItemViewerHopping extends TileEntityItemViewer{ BlockPos toPos = this.pos.offset(facing); if(this.world.isBlockLoaded(toPos)){ TileEntity to = this.world.getTileEntity(toPos); - if(to != null && !(to instanceof TileEntityItemViewer) && to.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite())){ - this.handlerToPushTo = to.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite()); + if(to != null && !(to instanceof TileEntityItemViewer)){ + IItemHandler normal = null; + if(from.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite())){ + normal = from.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite()); + } + + Object slotless = null; + if(ActuallyAdditions.commonCapsLoaded){ + if(from.hasCapability(SlotlessItemHandlerConfig.CAPABILITY, facing.getOpposite())){ + slotless = from.getCapability(SlotlessItemHandlerConfig.CAPABILITY, facing.getOpposite()); + } + } + + this.handlerToPushTo = new SlotlessableItemHandlerWrapper(normal, slotless); } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItem.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItem.java index 25fbd175c..84e0b773c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItem.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItem.java @@ -13,8 +13,10 @@ package de.ellpeck.actuallyadditions.mod.tile; import de.ellpeck.actuallyadditions.api.laser.IConnectionPair; import de.ellpeck.actuallyadditions.api.laser.LaserType; import de.ellpeck.actuallyadditions.api.laser.Network; +import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.tile.TileEntityItemViewer.GenericItemHandlerInfo; import de.ellpeck.actuallyadditions.mod.util.WorldUtil; +import de.ellpeck.actuallyadditions.mod.util.compat.SlotlessableItemHandlerWrapper; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -26,6 +28,7 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; +import org.cyclops.commoncapabilities.capability.itemhandler.SlotlessItemHandlerConfig; import java.util.ArrayList; import java.util.HashMap; @@ -35,7 +38,7 @@ import java.util.concurrent.ConcurrentHashMap; public class TileEntityLaserRelayItem extends TileEntityLaserRelay{ - public final Map handlersAround = new ConcurrentHashMap(); + public final Map handlersAround = new ConcurrentHashMap(); public int priority; public TileEntityLaserRelayItem(String name){ @@ -61,7 +64,7 @@ public class TileEntityLaserRelayItem extends TileEntityLaserRelay{ @Override public void saveDataOnChangeOrWorldStart(){ - Map old = new HashMap(this.handlersAround); + Map old = new HashMap(this.handlersAround); boolean change = false; this.handlersAround.clear(); @@ -71,11 +74,23 @@ public class TileEntityLaserRelayItem extends TileEntityLaserRelay{ if(this.world.isBlockLoaded(pos)){ TileEntity tile = this.world.getTileEntity(pos); if(tile != null && !(tile instanceof TileEntityItemViewer) && !(tile instanceof TileEntityLaserRelay)){ - IItemHandler handler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side.getOpposite()); - if(handler != null){ + IItemHandler itemHandler = null; + if(tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side.getOpposite())){ + itemHandler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side.getOpposite()); + } + + Object slotlessHandler = null; + if(ActuallyAdditions.commonCapsLoaded){ + if(tile.hasCapability(SlotlessItemHandlerConfig.CAPABILITY, side.getOpposite())){ + slotlessHandler = tile.getCapability(SlotlessItemHandlerConfig.CAPABILITY, side.getOpposite()); + } + } + + if(itemHandler != null || slotlessHandler != null){ + SlotlessableItemHandlerWrapper handler = new SlotlessableItemHandlerWrapper(itemHandler, slotlessHandler); this.handlersAround.put(pos, handler); - IItemHandler oldHandler = old.get(pos); + SlotlessableItemHandlerWrapper oldHandler = old.get(pos); if(oldHandler == null || !handler.equals(oldHandler)){ change = true; } @@ -105,7 +120,7 @@ public class TileEntityLaserRelayItem extends TileEntityLaserRelay{ TileEntityLaserRelayItem relayTile = (TileEntityLaserRelayItem)aRelayTile; GenericItemHandlerInfo info = new GenericItemHandlerInfo(relayTile); - for(Map.Entry handler : relayTile.handlersAround.entrySet()){ + for(Map.Entry handler : relayTile.handlersAround.entrySet()){ if(!alreadyChecked.contains(handler.getKey())){ alreadyChecked.add(handler.getKey()); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItemWhitelist.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItemWhitelist.java index bf3d0cb71..2d54968f6 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItemWhitelist.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItemWhitelist.java @@ -16,6 +16,7 @@ import de.ellpeck.actuallyadditions.mod.items.ItemDrill; import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerCustom; import de.ellpeck.actuallyadditions.mod.util.StackUtil; +import de.ellpeck.actuallyadditions.mod.util.compat.SlotlessableItemHandlerWrapper; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -69,44 +70,51 @@ public class TileEntityLaserRelayItemWhitelist extends TileEntityLaserRelayItem } private void addWhitelistSmart(boolean output){ + for(SlotlessableItemHandlerWrapper handler : this.handlersAround.values()){ + IItemHandler itemHandler = handler.getNormalHandler(); + if(itemHandler != null){ + for(int i = 0; i < itemHandler.getSlots(); i++){ + ItemStack stack = itemHandler.getStackInSlot(i); + if(StackUtil.isValid(stack)){ + this.addWhitelistSmart(output, stack); + } + } + } + } + } + + private void addWhitelistSmart(boolean output, ItemStack stack){ FilterSettings usedSettings = output ? this.rightFilter : this.leftFilter; - for(IItemHandler handler : this.handlersAround.values()){ - for(int i = 0; i < handler.getSlots(); i++){ - ItemStack stack = handler.getStackInSlot(i); - if(StackUtil.isValid(stack)){ - ItemStack copy = stack.copy(); - copy = StackUtil.setStackSize(copy, 1); + ItemStack copy = stack.copy(); + copy = StackUtil.setStackSize(copy, 1); - if(!FilterSettings.check(copy, usedSettings.filterInventory, true, usedSettings.respectMeta, usedSettings.respectNBT, usedSettings.respectMod, usedSettings.respectOredict)){ - for(int k = 0; k < usedSettings.filterInventory.getSlots(); k++){ - ItemStack slot = usedSettings.filterInventory.getStackInSlot(k); - if(StackUtil.isValid(slot)){ - if(SlotFilter.isFilter(slot)){ - ItemStackHandlerCustom inv = new ItemStackHandlerCustom(ContainerFilter.SLOT_AMOUNT); - ItemDrill.loadSlotsFromNBT(inv, slot); + if(!FilterSettings.check(copy, usedSettings.filterInventory, true, usedSettings.respectMeta, usedSettings.respectNBT, usedSettings.respectMod, usedSettings.respectOredict)){ + for(int k = 0; k < usedSettings.filterInventory.getSlots(); k++){ + ItemStack slot = usedSettings.filterInventory.getStackInSlot(k); + if(StackUtil.isValid(slot)){ + if(SlotFilter.isFilter(slot)){ + ItemStackHandlerCustom inv = new ItemStackHandlerCustom(ContainerFilter.SLOT_AMOUNT); + ItemDrill.loadSlotsFromNBT(inv, slot); - boolean did = false; - for(int j = 0; j < inv.getSlots(); j++){ - if(!StackUtil.isValid(inv.getStackInSlot(j))){ - inv.setStackInSlot(j, copy); - did = true; - break; - } - } - - if(did){ - ItemDrill.writeSlotsToNBT(inv, slot); - break; - } - } - } - else{ - usedSettings.filterInventory.setStackInSlot(k, copy); + boolean did = false; + for(int j = 0; j < inv.getSlots(); j++){ + if(!StackUtil.isValid(inv.getStackInSlot(j))){ + inv.setStackInSlot(j, copy); + did = true; break; } } + + if(did){ + ItemDrill.writeSlotsToNBT(inv, slot); + break; + } } } + else{ + usedSettings.filterInventory.setStackInSlot(k, copy); + break; + } } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/WorldUtil.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/WorldUtil.java index 2028fbf92..d9d787fdd 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/WorldUtil.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/WorldUtil.java @@ -12,6 +12,8 @@ package de.ellpeck.actuallyadditions.mod.util; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues; +import de.ellpeck.actuallyadditions.mod.tile.FilterSettings; +import de.ellpeck.actuallyadditions.mod.util.compat.SlotlessableItemHandlerWrapper; import de.ellpeck.actuallyadditions.mod.util.compat.TeslaUtil; import net.darkhax.tesla.api.ITeslaConsumer; import net.darkhax.tesla.api.ITeslaProducer; @@ -47,25 +49,99 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.items.IItemHandler; +import org.cyclops.commoncapabilities.api.capability.itemhandler.ISlotlessItemHandler; import java.util.ArrayList; import java.util.List; public final class WorldUtil{ - public static boolean doItemInteraction(int slotExtract, int slotInsert, IItemHandler extract, IItemHandler insert, int maxExtract){ - ItemStack theoreticalExtract = extract.extractItem(slotExtract, maxExtract, true); + public static boolean doItemInteraction(SlotlessableItemHandlerWrapper extractWrapper, SlotlessableItemHandlerWrapper insertWrapper, int maxExtract){ + return doItemInteraction(extractWrapper, insertWrapper, maxExtract, null); + } + + public static boolean doItemInteraction(SlotlessableItemHandlerWrapper extractWrapper, SlotlessableItemHandlerWrapper insertWrapper, int maxExtract, FilterSettings filter){ + return doItemInteraction(extractWrapper, insertWrapper, maxExtract, 0, Integer.MAX_VALUE, filter); + } + + public static boolean doItemInteraction(SlotlessableItemHandlerWrapper extractWrapper, SlotlessableItemHandlerWrapper insertWrapper, int maxExtract, int slotStart, int slotEnd, FilterSettings filter){ + ItemStack theoreticalExtract = extractItem(extractWrapper, maxExtract, true, slotStart, slotEnd, filter); if(StackUtil.isValid(theoreticalExtract)){ - ItemStack remaining = insert.insertItem(slotInsert, theoreticalExtract, false); + ItemStack remaining = insertItem(insertWrapper, theoreticalExtract, false, slotStart, slotEnd); if(!ItemStack.areItemStacksEqual(remaining, theoreticalExtract)){ int toExtract = !StackUtil.isValid(remaining) ? StackUtil.getStackSize(theoreticalExtract) : StackUtil.getStackSize(theoreticalExtract)-StackUtil.getStackSize(remaining); - extract.extractItem(slotExtract, toExtract, false); + extractItem(extractWrapper, toExtract, false, slotStart, slotEnd, filter); return true; } } return false; } + public static ItemStack extractItem(SlotlessableItemHandlerWrapper extractWrapper, int maxExtract, boolean simulate, int slotStart, int slotEnd, FilterSettings filter){ + ItemStack extracted = StackUtil.getNull(); + + if(ActuallyAdditions.commonCapsLoaded){ + Object handler = extractWrapper.getSlotlessHandler(); + if(handler instanceof ISlotlessItemHandler){ + ISlotlessItemHandler slotless = (ISlotlessItemHandler)handler; + + if(filter == null){ + extracted = slotless.extractItem(maxExtract, simulate); + } + else{ + ItemStack would = slotless.extractItem(maxExtract, true); + if(filter.check(would)){ + if(simulate){ + extracted = would; + } + else{ + extracted = slotless.extractItem(maxExtract, false); + } + } + } + } + } + + if(!StackUtil.isValid(extracted)){ + IItemHandler handler = extractWrapper.getNormalHandler(); + if(handler != null){ + for(int i = Math.max(0, slotStart); i < Math.min(slotEnd, handler.getSlots()); i++){ + if(filter == null || filter.check(handler.getStackInSlot(i))){ + extracted = handler.extractItem(i, maxExtract, simulate); + + if(StackUtil.isValid(extracted)){ + break; + } + } + } + } + } + + return extracted; + } + + public static ItemStack insertItem(SlotlessableItemHandlerWrapper insertWrapper, ItemStack stack, boolean simulate, int slotStart, int slotEnd){ + ItemStack remain = StackUtil.validateCopy(stack); + + if(ActuallyAdditions.commonCapsLoaded){ + Object handler = insertWrapper.getSlotlessHandler(); + if(handler instanceof ISlotlessItemHandler){ + remain = ((ISlotlessItemHandler)handler).insertItem(remain, simulate); + } + } + + if(StackUtil.isValid(remain)){ + IItemHandler handler = insertWrapper.getNormalHandler(); + if(handler != null){ + for(int i = Math.max(0, slotStart); i < Math.min(slotEnd, handler.getSlots()); i++){ + remain = handler.insertItem(i, remain, simulate); + } + } + } + + return remain; + } + public static void doEnergyInteraction(TileEntity tileFrom, TileEntity tileTo, EnumFacing sideTo, int maxTransfer){ if(maxTransfer > 0){ EnumFacing opp = sideTo == null ? null : sideTo.getOpposite(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/CommonCapsUtil.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/CommonCapsUtil.java new file mode 100644 index 000000000..fd9bdb501 --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/CommonCapsUtil.java @@ -0,0 +1,105 @@ +/* + * This file ("CommonCapsUtil.java") is part of the Actually Additions mod for Minecraft. + * It is created and owned by Ellpeck and distributed + * under the Actually Additions License to be found at + * http://ellpeck.de/actaddlicense + * View the source code at https://github.com/Ellpeck/ActuallyAdditions + * + * © 2015-2017 Ellpeck + */ + +package de.ellpeck.actuallyadditions.mod.util.compat; + +import de.ellpeck.actuallyadditions.mod.tile.TileEntityItemViewer; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityItemViewer.SlotlessItemHandlerInfo; +import de.ellpeck.actuallyadditions.mod.util.StackUtil; +import net.minecraft.item.ItemStack; +import net.minecraftforge.items.IItemHandler; +import org.cyclops.commoncapabilities.api.capability.itemhandler.DefaultSlotlessItemHandlerWrapper; +import org.cyclops.commoncapabilities.api.capability.itemhandler.ISlotlessItemHandler; + +public final class CommonCapsUtil{ + + public static ISlotlessItemHandler createSlotlessItemViewerHandler(final TileEntityItemViewer tile, IItemHandler normalHandler){ + return new DefaultSlotlessItemHandlerWrapper(normalHandler){ + @Override + public ItemStack insertItem(ItemStack stack, boolean simulate){ + ItemStack remain = StackUtil.validateCopy(stack); + for(SlotlessItemHandlerInfo handler : tile.slotlessInfos){ + if(handler.isLoaded() && tile.isWhitelisted(handler, stack, false)){ + if(handler.handler instanceof ISlotlessItemHandler){ + remain = ((ISlotlessItemHandler)handler.handler).insertItem(stack, simulate); + + if(!ItemStack.areItemStacksEqual(remain, stack) && !simulate){ + tile.markDirty(); + tile.doItemParticle(stack, handler.relayInQuestion.getPos(), tile.connectedRelay.getPos()); + } + + if(!StackUtil.isValid(remain)){ + return StackUtil.getNull(); + } + } + } + } + return super.insertItem(remain, simulate); + } + + @Override + public ItemStack extractItem(int amount, boolean simulate){ + for(SlotlessItemHandlerInfo handler : tile.slotlessInfos){ + if(handler.isLoaded()){ + if(handler.handler instanceof ISlotlessItemHandler){ + ISlotlessItemHandler slotless = (ISlotlessItemHandler)handler.handler; + + ItemStack would = slotless.extractItem(amount, true); + if(StackUtil.isValid(would)){ + if(tile.isWhitelisted(handler, would, true)){ + ItemStack has; + if(simulate){ + has = would; + } + else{ + has = slotless.extractItem(amount, false); + } + + if(StackUtil.isValid(has) && !simulate){ + tile.markDirty(); + tile.doItemParticle(has, tile.connectedRelay.getPos(), handler.relayInQuestion.getPos()); + } + + return has; + } + } + } + } + } + return super.extractItem(amount, simulate); + } + + @Override + public ItemStack extractItem(ItemStack matchStack, int matchFlags, boolean simulate){ + for(SlotlessItemHandlerInfo handler : tile.slotlessInfos){ + if(handler.isLoaded()){ + if(handler.handler instanceof ISlotlessItemHandler){ + ISlotlessItemHandler slotless = (ISlotlessItemHandler)handler.handler; + + ItemStack would = slotless.extractItem(matchStack, matchFlags, true); + if(StackUtil.isValid(would)){ + if(tile.isWhitelisted(handler, would, true)){ + if(simulate){ + return would; + } + else{ + return slotless.extractItem(matchStack, matchFlags, false); + } + } + } + } + } + } + return super.extractItem(matchStack, matchFlags, simulate); + } + }; + } + +} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/SlotlessableItemHandlerWrapper.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/SlotlessableItemHandlerWrapper.java new file mode 100644 index 000000000..a01d17ff4 --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/SlotlessableItemHandlerWrapper.java @@ -0,0 +1,32 @@ +/* + * This file ("SlotlessableItemHandler.java") is part of the Actually Additions mod for Minecraft. + * It is created and owned by Ellpeck and distributed + * under the Actually Additions License to be found at + * http://ellpeck.de/actaddlicense + * View the source code at https://github.com/Ellpeck/ActuallyAdditions + * + * © 2015-2017 Ellpeck + */ + +package de.ellpeck.actuallyadditions.mod.util.compat; + +import net.minecraftforge.items.IItemHandler; + +public class SlotlessableItemHandlerWrapper{ + + private final IItemHandler normalHandler; + private final Object slotlessHandler; + + public SlotlessableItemHandlerWrapper(IItemHandler normalHandler, Object slotlessHandler){ + this.normalHandler = normalHandler; + this.slotlessHandler = slotlessHandler; + } + + public IItemHandler getNormalHandler(){ + return this.normalHandler; + } + + public Object getSlotlessHandler(){ + return this.slotlessHandler; + } +}