mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 00:38:35 +01:00
Implemented slotless item handler compat (untested!)
This commit is contained in:
parent
23299bffc7
commit
4615a94339
10 changed files with 492 additions and 155 deletions
|
@ -41,11 +41,15 @@ repositories {
|
||||||
maven {
|
maven {
|
||||||
url "http://maven.epoxide.xyz"
|
url "http://maven.epoxide.xyz"
|
||||||
}
|
}
|
||||||
|
maven {
|
||||||
|
url "https://dl.bintray.com/cyclopsmc/dev/"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile "net.darkhax.tesla:Tesla:1.11-1.3.0.51"
|
compile "net.darkhax.tesla:Tesla:1.11-1.3.0.51"
|
||||||
deobfCompile "mezz.jei:jei_1.11:4.1.1.206"
|
deobfCompile "mezz.jei:jei_1.11:4.1.1.206"
|
||||||
|
deobfCompile "org.cyclops.commoncapabilities:CommonCapabilities:1.11.2-1.3.0-81"
|
||||||
}
|
}
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
|
|
|
@ -68,6 +68,7 @@ public class ActuallyAdditions{
|
||||||
public static IProxy proxy;
|
public static IProxy proxy;
|
||||||
|
|
||||||
public static boolean teslaLoaded;
|
public static boolean teslaLoaded;
|
||||||
|
public static boolean commonCapsLoaded;
|
||||||
|
|
||||||
static{
|
static{
|
||||||
//For some reason, this has to be done here
|
//For some reason, this has to be done here
|
||||||
|
@ -83,13 +84,8 @@ public class ActuallyAdditions{
|
||||||
Lenses.init();
|
Lenses.init();
|
||||||
InitBooklet.preInit();
|
InitBooklet.preInit();
|
||||||
|
|
||||||
if(Loader.isModLoaded("tesla")){
|
teslaLoaded = Loader.isModLoaded("tesla");
|
||||||
ModUtil.LOGGER.info("Tesla loaded... Activating Tesla Power System integration...");
|
commonCapsLoaded = Loader.isModLoaded("commoncapabilities");
|
||||||
teslaLoaded = true;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
ModUtil.LOGGER.info("Tesla not found! Skipping Tesla Power System integration.");
|
|
||||||
}
|
|
||||||
|
|
||||||
new ConfigurationHandler(event.getSuggestedConfigurationFile());
|
new ConfigurationHandler(event.getSuggestedConfigurationFile());
|
||||||
PacketHandler.init();
|
PacketHandler.init();
|
||||||
|
|
|
@ -11,10 +11,12 @@
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
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.IButtonReactor;
|
||||||
import de.ellpeck.actuallyadditions.mod.network.gui.INumberReactor;
|
import de.ellpeck.actuallyadditions.mod.network.gui.INumberReactor;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.compat.SlotlessableItemHandlerWrapper;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
@ -23,6 +25,10 @@ import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
import net.minecraftforge.items.CapabilityItemHandler;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
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{
|
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 sideToPut = -1;
|
||||||
public int slotToPutStart;
|
public int slotToPutStart;
|
||||||
public int slotToPutEnd;
|
public int slotToPutEnd;
|
||||||
public TileEntity placeToPut;
|
public Map<EnumFacing, SlotlessableItemHandlerWrapper> placeToPut = new ConcurrentHashMap<EnumFacing, SlotlessableItemHandlerWrapper>();
|
||||||
public int sideToPull = -1;
|
public int sideToPull = -1;
|
||||||
public int slotToPullStart;
|
public int slotToPullStart;
|
||||||
public int slotToPullEnd;
|
public int slotToPullEnd;
|
||||||
public TileEntity placeToPull;
|
public Map<EnumFacing, SlotlessableItemHandlerWrapper> placeToPull = new ConcurrentHashMap<EnumFacing, SlotlessableItemHandlerWrapper>();
|
||||||
public boolean isAdvanced;
|
public boolean isAdvanced;
|
||||||
public FilterSettings leftFilter = new FilterSettings(12, true, true, false, false, 0, -1000);
|
public FilterSettings leftFilter = new FilterSettings(12, true, true, false, false, 0, -1000);
|
||||||
public FilterSettings rightFilter = new FilterSettings(12, true, true, false, false, 0, -2000);
|
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 lastPullSide;
|
||||||
private int lastPullStart;
|
private int lastPullStart;
|
||||||
private int lastPullEnd;
|
private int lastPullEnd;
|
||||||
|
private final SlotlessableItemHandlerWrapper wrapper = new SlotlessableItemHandlerWrapper(this.slots, null);
|
||||||
|
|
||||||
public TileEntityInputter(int slots, String name){
|
public TileEntityInputter(int slots, String name){
|
||||||
super(slots, name);
|
super(slots, name);
|
||||||
|
@ -77,19 +84,8 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean newPulling(){
|
private boolean newPulling(){
|
||||||
for(EnumFacing side : EnumFacing.values()){
|
for(EnumFacing side : this.placeToPull.keySet()){
|
||||||
if(this.placeToPull.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side)){
|
WorldUtil.doItemInteraction(this.placeToPull.get(side), this.wrapper, Integer.MAX_VALUE, this.slotToPullStart, this.slotToPullEnd, !this.isAdvanced ? null : this.leftFilter);
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(this.placeToPull instanceof TileEntityItemViewer){
|
if(this.placeToPull instanceof TileEntityItemViewer){
|
||||||
break;
|
break;
|
||||||
|
@ -99,18 +95,9 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean newPutting(){
|
private boolean newPutting(){
|
||||||
if(this.checkBothFilters(this.slots.getStackInSlot(0), true)){
|
if(!this.isAdvanced || this.rightFilter.check(this.slots.getStackInSlot(0))){
|
||||||
for(EnumFacing side : EnumFacing.values()){
|
for(EnumFacing side : this.placeToPut.keySet()){
|
||||||
if(this.placeToPut.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side)){
|
WorldUtil.doItemInteraction(this.wrapper, this.placeToPut.get(side), Integer.MAX_VALUE, this.slotToPutStart, this.slotToPutEnd, null);
|
||||||
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.placeToPut instanceof TileEntityItemViewer){
|
if(this.placeToPut instanceof TileEntityItemViewer){
|
||||||
break;
|
break;
|
||||||
|
@ -120,16 +107,6 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt
|
||||||
return false;
|
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
|
@Override
|
||||||
public boolean shouldSaveDataOnChangeOrWorldStart(){
|
public boolean shouldSaveDataOnChangeOrWorldStart(){
|
||||||
return true;
|
return true;
|
||||||
|
@ -140,21 +117,39 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void saveDataOnChangeOrWorldStart(){
|
public void saveDataOnChangeOrWorldStart(){
|
||||||
this.placeToPull = null;
|
this.placeToPull.clear();
|
||||||
this.placeToPut = null;
|
this.placeToPut.clear();
|
||||||
|
|
||||||
if(this.sideToPull != -1){
|
if(this.sideToPull != -1){
|
||||||
EnumFacing side = WorldUtil.getDirectionBySidesInOrder(this.sideToPull);
|
EnumFacing side = WorldUtil.getDirectionBySidesInOrder(this.sideToPull);
|
||||||
BlockPos offset = this.pos.offset(side);
|
BlockPos offset = this.pos.offset(side);
|
||||||
|
|
||||||
if(this.world.isBlockLoaded(offset)){
|
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(tile != null){
|
||||||
if(this.placeToPull.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null)){
|
for(EnumFacing facing : EnumFacing.values()){
|
||||||
IItemHandler cap = this.placeToPull.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
|
IItemHandler normal = null;
|
||||||
if(cap != null){
|
if(tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing)){
|
||||||
this.slotToPullEnd = cap.getSlots();
|
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);
|
BlockPos offset = this.pos.offset(side);
|
||||||
|
|
||||||
if(this.world.isBlockLoaded(offset)){
|
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(tile != null){
|
||||||
if(this.placeToPut.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null)){
|
for(EnumFacing facing : EnumFacing.values()){
|
||||||
IItemHandler cap = this.placeToPut.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
|
IItemHandler normal = null;
|
||||||
if(cap != null){
|
if(tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing)){
|
||||||
this.slotToPutEnd = cap.getSlots();
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,32 +11,39 @@
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.laser.Network;
|
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.PacketHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.network.PacketServerToClient;
|
import de.ellpeck.actuallyadditions.mod.network.PacketServerToClient;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
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.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
import net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint;
|
import net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
import org.cyclops.commoncapabilities.api.capability.itemhandler.ISlotlessItemHandler;
|
||||||
|
import org.cyclops.commoncapabilities.capability.itemhandler.SlotlessItemHandlerConfig;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class TileEntityItemViewer extends TileEntityBase{
|
public class TileEntityItemViewer extends TileEntityBase{
|
||||||
|
|
||||||
protected final IItemHandler itemHandler;
|
protected final SlotlessableItemHandlerWrapper itemHandler;
|
||||||
private final List<GenericItemHandlerInfo> genericInfos = new ArrayList<GenericItemHandlerInfo>();
|
public final List<GenericItemHandlerInfo> genericInfos = new ArrayList<GenericItemHandlerInfo>();
|
||||||
private final Map<Integer, SpecificItemHandlerInfo> specificInfos = new HashMap<Integer, SpecificItemHandlerInfo>();
|
public final Map<Integer, IItemHandlerInfo> itemHandlerInfos = new HashMap<Integer, IItemHandlerInfo>();
|
||||||
|
public final List<SlotlessItemHandlerInfo> slotlessInfos = new ArrayList<SlotlessItemHandlerInfo>();
|
||||||
public TileEntityLaserRelayItem connectedRelay;
|
public TileEntityLaserRelayItem connectedRelay;
|
||||||
private int lastNetworkChangeAmount = -1;
|
private int lastNetworkChangeAmount = -1;
|
||||||
|
|
||||||
public TileEntityItemViewer(String name){
|
public TileEntityItemViewer(String name){
|
||||||
super(name);
|
super(name);
|
||||||
|
|
||||||
this.itemHandler = new IItemHandler(){
|
IItemHandler normalHandler = new IItemHandler(){
|
||||||
@Override
|
@Override
|
||||||
public int getSlots(){
|
public int getSlots(){
|
||||||
int size = 0;
|
int size = 0;
|
||||||
|
@ -44,8 +51,11 @@ public class TileEntityItemViewer extends TileEntityBase{
|
||||||
if(infos != null){
|
if(infos != null){
|
||||||
for(GenericItemHandlerInfo info : infos){
|
for(GenericItemHandlerInfo info : infos){
|
||||||
if(info.isLoaded()){
|
if(info.isLoaded()){
|
||||||
for(IItemHandler handler : info.handlers){
|
for(SlotlessableItemHandlerWrapper handler : info.handlers){
|
||||||
size += handler.getSlots();
|
IItemHandler normalHandler = handler.getNormalHandler();
|
||||||
|
if(normalHandler != null){
|
||||||
|
size += normalHandler.getSlots();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,7 +65,7 @@ public class TileEntityItemViewer extends TileEntityBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getStackInSlot(int slot){
|
public ItemStack getStackInSlot(int slot){
|
||||||
SpecificItemHandlerInfo handler = TileEntityItemViewer.this.getSwitchedIndexHandler(slot);
|
IItemHandlerInfo handler = TileEntityItemViewer.this.getSwitchedIndexHandler(slot);
|
||||||
if(handler != null && handler.isLoaded()){
|
if(handler != null && handler.isLoaded()){
|
||||||
return handler.handler.getStackInSlot(handler.switchedIndex);
|
return handler.handler.getStackInSlot(handler.switchedIndex);
|
||||||
}
|
}
|
||||||
|
@ -64,7 +74,7 @@ public class TileEntityItemViewer extends TileEntityBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate){
|
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)){
|
if(info != null && info.isLoaded() && TileEntityItemViewer.this.isWhitelisted(info, stack, false)){
|
||||||
ItemStack remain = info.handler.insertItem(info.switchedIndex, stack, simulate);
|
ItemStack remain = info.handler.insertItem(info.switchedIndex, stack, simulate);
|
||||||
if(!ItemStack.areItemStacksEqual(remain, 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){
|
public ItemStack extractItem(int slot, int amount, boolean simulate){
|
||||||
ItemStack stackIn = this.getStackInSlot(slot);
|
ItemStack stackIn = this.getStackInSlot(slot);
|
||||||
if(StackUtil.isValid(stackIn)){
|
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)){
|
if(info != null && info.isLoaded() && TileEntityItemViewer.this.isWhitelisted(info, stackIn, true)){
|
||||||
ItemStack extracted = info.handler.extractItem(info.switchedIndex, amount, simulate);
|
ItemStack extracted = info.handler.extractItem(info.switchedIndex, amount, simulate);
|
||||||
if(StackUtil.isValid(extracted) && !simulate){
|
if(StackUtil.isValid(extracted) && !simulate){
|
||||||
|
@ -95,7 +105,7 @@ public class TileEntityItemViewer extends TileEntityBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSlotLimit(int slot){
|
public int getSlotLimit(int slot){
|
||||||
SpecificItemHandlerInfo info = TileEntityItemViewer.this.getSwitchedIndexHandler(slot);
|
IItemHandlerInfo info = TileEntityItemViewer.this.getSwitchedIndexHandler(slot);
|
||||||
if(info != null && info.isLoaded()){
|
if(info != null && info.isLoaded()){
|
||||||
return info.handler.getSlotLimit(info.switchedIndex);
|
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(){
|
public TileEntityItemViewer(){
|
||||||
|
@ -112,7 +129,20 @@ public class TileEntityItemViewer extends TileEntityBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IItemHandler getItemHandler(EnumFacing facing){
|
public IItemHandler getItemHandler(EnumFacing facing){
|
||||||
return this.itemHandler;
|
return this.itemHandler.getNormalHandler();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> T getCapability(Capability<T> 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<GenericItemHandlerInfo> getItemHandlerInfos(){
|
private List<GenericItemHandlerInfo> getItemHandlerInfos(){
|
||||||
|
@ -120,7 +150,7 @@ public class TileEntityItemViewer extends TileEntityBase{
|
||||||
return this.genericInfos;
|
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){
|
if(!this.world.isRemote){
|
||||||
NBTTagCompound compound = new NBTTagCompound();
|
NBTTagCompound compound = new NBTTagCompound();
|
||||||
stack.writeToNBT(compound);
|
stack.writeToNBT(compound);
|
||||||
|
@ -150,10 +180,20 @@ public class TileEntityItemViewer extends TileEntityBase{
|
||||||
|
|
||||||
int slotsQueried = 0;
|
int slotsQueried = 0;
|
||||||
for(GenericItemHandlerInfo info : this.genericInfos){
|
for(GenericItemHandlerInfo info : this.genericInfos){
|
||||||
for(IItemHandler handler : info.handlers){
|
for(SlotlessableItemHandlerWrapper handler : info.handlers){
|
||||||
for(int i = 0; i < handler.getSlots(); i++){
|
IItemHandler normalHandler = handler.getNormalHandler();
|
||||||
this.specificInfos.put(slotsQueried, new SpecificItemHandlerInfo(handler, i, info.relayInQuestion));
|
if(normalHandler != null){
|
||||||
slotsQueried++;
|
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();
|
this.genericInfos.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!this.specificInfos.isEmpty()){
|
if(!this.itemHandlerInfos.isEmpty()){
|
||||||
this.specificInfos.clear();
|
this.itemHandlerInfos.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!this.slotlessInfos.isEmpty()){
|
||||||
|
this.slotlessInfos.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private SpecificItemHandlerInfo getSwitchedIndexHandler(int i){
|
private IItemHandlerInfo getSwitchedIndexHandler(int i){
|
||||||
this.queryAndSaveData();
|
this.queryAndSaveData();
|
||||||
return this.specificInfos.get(i);
|
return this.itemHandlerInfos.get(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -215,7 +259,7 @@ public class TileEntityItemViewer extends TileEntityBase{
|
||||||
this.connectedRelay = tileFound;
|
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);
|
boolean whitelisted = handler.relayInQuestion.isWhitelisted(stack, output);
|
||||||
TileEntityLaserRelayItem connected = this.connectedRelay;
|
TileEntityLaserRelayItem connected = this.connectedRelay;
|
||||||
if(connected != null && connected != handler.relayInQuestion){
|
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 IItemHandler handler;
|
||||||
public final int switchedIndex;
|
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.handler = handler;
|
||||||
this.switchedIndex = switchedIndex;
|
this.switchedIndex = switchedIndex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class SpecificItemHandlerInfo{
|
||||||
|
|
||||||
|
public final TileEntityLaserRelayItem relayInQuestion;
|
||||||
|
|
||||||
|
public SpecificItemHandlerInfo(TileEntityLaserRelayItem relayInQuestion){
|
||||||
this.relayInQuestion = relayInQuestion;
|
this.relayInQuestion = relayInQuestion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,7 +307,7 @@ public class TileEntityItemViewer extends TileEntityBase{
|
||||||
|
|
||||||
public static class GenericItemHandlerInfo implements Comparable<GenericItemHandlerInfo>{
|
public static class GenericItemHandlerInfo implements Comparable<GenericItemHandlerInfo>{
|
||||||
|
|
||||||
public final List<IItemHandler> handlers = new ArrayList<IItemHandler>();
|
public final List<SlotlessableItemHandlerWrapper> handlers = new ArrayList<SlotlessableItemHandlerWrapper>();
|
||||||
public final TileEntityLaserRelayItem relayInQuestion;
|
public final TileEntityLaserRelayItem relayInQuestion;
|
||||||
|
|
||||||
public GenericItemHandlerInfo(TileEntityLaserRelayItem relayInQuestion){
|
public GenericItemHandlerInfo(TileEntityLaserRelayItem relayInQuestion){
|
||||||
|
|
|
@ -10,8 +10,10 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
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.StackUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.compat.SlotlessableItemHandlerWrapper;
|
||||||
import net.minecraft.block.BlockHopper;
|
import net.minecraft.block.BlockHopper;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
|
@ -22,13 +24,15 @@ import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
import net.minecraftforge.items.CapabilityItemHandler;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
import org.cyclops.commoncapabilities.api.capability.itemhandler.ISlotlessItemHandler;
|
||||||
|
import org.cyclops.commoncapabilities.capability.itemhandler.SlotlessItemHandlerConfig;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TileEntityItemViewerHopping extends TileEntityItemViewer{
|
public class TileEntityItemViewerHopping extends TileEntityItemViewer{
|
||||||
|
|
||||||
private IItemHandler handlerToPullFrom;
|
private SlotlessableItemHandlerWrapper handlerToPullFrom;
|
||||||
private IItemHandler handlerToPushTo;
|
private SlotlessableItemHandlerWrapper handlerToPushTo;
|
||||||
|
|
||||||
public TileEntityItemViewerHopping(){
|
public TileEntityItemViewerHopping(){
|
||||||
super("itemViewerHopping");
|
super("itemViewerHopping");
|
||||||
|
@ -40,16 +44,7 @@ public class TileEntityItemViewerHopping extends TileEntityItemViewer{
|
||||||
|
|
||||||
if(!this.world.isRemote && this.world.getTotalWorldTime()%10 == 0){
|
if(!this.world.isRemote && this.world.getTotalWorldTime()%10 == 0){
|
||||||
if(this.handlerToPullFrom != null){
|
if(this.handlerToPullFrom != null){
|
||||||
outer:
|
WorldUtil.doItemInteraction(this.handlerToPullFrom, this.itemHandler, 4);
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if(this.world.getTotalWorldTime()%20 == 0){
|
if(this.world.getTotalWorldTime()%20 == 0){
|
||||||
|
@ -57,13 +52,29 @@ public class TileEntityItemViewerHopping extends TileEntityItemViewer{
|
||||||
if(items != null && !items.isEmpty()){
|
if(items != null && !items.isEmpty()){
|
||||||
for(EntityItem item : items){
|
for(EntityItem item : items){
|
||||||
if(item != null && !item.isDead){
|
if(item != null && !item.isDead){
|
||||||
for(int i = 0; i < this.itemHandler.getSlots(); i++){
|
if(ActuallyAdditions.commonCapsLoaded){
|
||||||
ItemStack left = this.itemHandler.insertItem(i, item.getEntityItem(), false);
|
Object slotless = this.itemHandler.getSlotlessHandler();
|
||||||
item.setEntityItemStack(left);
|
if(slotless instanceof ISlotlessItemHandler){
|
||||||
|
ItemStack left = ((ISlotlessItemHandler)slotless).insertItem(item.getEntityItem(), false);
|
||||||
|
item.setEntityItemStack(left);
|
||||||
|
|
||||||
if(!StackUtil.isValid(left)){
|
if(!StackUtil.isValid(left)){
|
||||||
item.setDead();
|
item.setDead();
|
||||||
break;
|
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){
|
if(this.handlerToPushTo != null){
|
||||||
outer:
|
WorldUtil.doItemInteraction(this.itemHandler, this.handlerToPushTo, 4);
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,8 +97,20 @@ public class TileEntityItemViewerHopping extends TileEntityItemViewer{
|
||||||
this.handlerToPushTo = null;
|
this.handlerToPushTo = null;
|
||||||
|
|
||||||
TileEntity from = this.world.getTileEntity(this.pos.offset(EnumFacing.UP));
|
TileEntity from = this.world.getTileEntity(this.pos.offset(EnumFacing.UP));
|
||||||
if(from != null && !(from instanceof TileEntityItemViewer) && from.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN)){
|
if(from != null && !(from instanceof TileEntityItemViewer)){
|
||||||
this.handlerToPullFrom = from.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN);
|
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);
|
IBlockState state = this.world.getBlockState(this.pos);
|
||||||
|
@ -105,8 +119,20 @@ public class TileEntityItemViewerHopping extends TileEntityItemViewer{
|
||||||
BlockPos toPos = this.pos.offset(facing);
|
BlockPos toPos = this.pos.offset(facing);
|
||||||
if(this.world.isBlockLoaded(toPos)){
|
if(this.world.isBlockLoaded(toPos)){
|
||||||
TileEntity to = this.world.getTileEntity(toPos);
|
TileEntity to = this.world.getTileEntity(toPos);
|
||||||
if(to != null && !(to instanceof TileEntityItemViewer) && to.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite())){
|
if(to != null && !(to instanceof TileEntityItemViewer)){
|
||||||
this.handlerToPushTo = to.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite());
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,10 @@ package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
import de.ellpeck.actuallyadditions.api.laser.IConnectionPair;
|
import de.ellpeck.actuallyadditions.api.laser.IConnectionPair;
|
||||||
import de.ellpeck.actuallyadditions.api.laser.LaserType;
|
import de.ellpeck.actuallyadditions.api.laser.LaserType;
|
||||||
import de.ellpeck.actuallyadditions.api.laser.Network;
|
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.tile.TileEntityItemViewer.GenericItemHandlerInfo;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.compat.SlotlessableItemHandlerWrapper;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
@ -26,6 +28,7 @@ import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
import net.minecraftforge.items.CapabilityItemHandler;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
import org.cyclops.commoncapabilities.capability.itemhandler.SlotlessItemHandlerConfig;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -35,7 +38,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
public class TileEntityLaserRelayItem extends TileEntityLaserRelay{
|
public class TileEntityLaserRelayItem extends TileEntityLaserRelay{
|
||||||
|
|
||||||
public final Map<BlockPos, IItemHandler> handlersAround = new ConcurrentHashMap<BlockPos, IItemHandler>();
|
public final Map<BlockPos, SlotlessableItemHandlerWrapper> handlersAround = new ConcurrentHashMap<BlockPos, SlotlessableItemHandlerWrapper>();
|
||||||
public int priority;
|
public int priority;
|
||||||
|
|
||||||
public TileEntityLaserRelayItem(String name){
|
public TileEntityLaserRelayItem(String name){
|
||||||
|
@ -61,7 +64,7 @@ public class TileEntityLaserRelayItem extends TileEntityLaserRelay{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveDataOnChangeOrWorldStart(){
|
public void saveDataOnChangeOrWorldStart(){
|
||||||
Map<BlockPos, IItemHandler> old = new HashMap<BlockPos, IItemHandler>(this.handlersAround);
|
Map<BlockPos, SlotlessableItemHandlerWrapper> old = new HashMap<BlockPos, SlotlessableItemHandlerWrapper>(this.handlersAround);
|
||||||
boolean change = false;
|
boolean change = false;
|
||||||
|
|
||||||
this.handlersAround.clear();
|
this.handlersAround.clear();
|
||||||
|
@ -71,11 +74,23 @@ public class TileEntityLaserRelayItem extends TileEntityLaserRelay{
|
||||||
if(this.world.isBlockLoaded(pos)){
|
if(this.world.isBlockLoaded(pos)){
|
||||||
TileEntity tile = this.world.getTileEntity(pos);
|
TileEntity tile = this.world.getTileEntity(pos);
|
||||||
if(tile != null && !(tile instanceof TileEntityItemViewer) && !(tile instanceof TileEntityLaserRelay)){
|
if(tile != null && !(tile instanceof TileEntityItemViewer) && !(tile instanceof TileEntityLaserRelay)){
|
||||||
IItemHandler handler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side.getOpposite());
|
IItemHandler itemHandler = null;
|
||||||
if(handler != 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);
|
this.handlersAround.put(pos, handler);
|
||||||
|
|
||||||
IItemHandler oldHandler = old.get(pos);
|
SlotlessableItemHandlerWrapper oldHandler = old.get(pos);
|
||||||
if(oldHandler == null || !handler.equals(oldHandler)){
|
if(oldHandler == null || !handler.equals(oldHandler)){
|
||||||
change = true;
|
change = true;
|
||||||
}
|
}
|
||||||
|
@ -105,7 +120,7 @@ public class TileEntityLaserRelayItem extends TileEntityLaserRelay{
|
||||||
TileEntityLaserRelayItem relayTile = (TileEntityLaserRelayItem)aRelayTile;
|
TileEntityLaserRelayItem relayTile = (TileEntityLaserRelayItem)aRelayTile;
|
||||||
GenericItemHandlerInfo info = new GenericItemHandlerInfo(relayTile);
|
GenericItemHandlerInfo info = new GenericItemHandlerInfo(relayTile);
|
||||||
|
|
||||||
for(Map.Entry<BlockPos, IItemHandler> handler : relayTile.handlersAround.entrySet()){
|
for(Map.Entry<BlockPos, SlotlessableItemHandlerWrapper> handler : relayTile.handlersAround.entrySet()){
|
||||||
if(!alreadyChecked.contains(handler.getKey())){
|
if(!alreadyChecked.contains(handler.getKey())){
|
||||||
alreadyChecked.add(handler.getKey());
|
alreadyChecked.add(handler.getKey());
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ import de.ellpeck.actuallyadditions.mod.items.ItemDrill;
|
||||||
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerCustom;
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerCustom;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.compat.SlotlessableItemHandlerWrapper;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
@ -69,44 +70,51 @@ public class TileEntityLaserRelayItemWhitelist extends TileEntityLaserRelayItem
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addWhitelistSmart(boolean output){
|
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;
|
FilterSettings usedSettings = output ? this.rightFilter : this.leftFilter;
|
||||||
for(IItemHandler handler : this.handlersAround.values()){
|
ItemStack copy = stack.copy();
|
||||||
for(int i = 0; i < handler.getSlots(); i++){
|
copy = StackUtil.setStackSize(copy, 1);
|
||||||
ItemStack stack = handler.getStackInSlot(i);
|
|
||||||
if(StackUtil.isValid(stack)){
|
|
||||||
ItemStack copy = stack.copy();
|
|
||||||
copy = StackUtil.setStackSize(copy, 1);
|
|
||||||
|
|
||||||
if(!FilterSettings.check(copy, usedSettings.filterInventory, true, usedSettings.respectMeta, usedSettings.respectNBT, usedSettings.respectMod, usedSettings.respectOredict)){
|
if(!FilterSettings.check(copy, usedSettings.filterInventory, true, usedSettings.respectMeta, usedSettings.respectNBT, usedSettings.respectMod, usedSettings.respectOredict)){
|
||||||
for(int k = 0; k < usedSettings.filterInventory.getSlots(); k++){
|
for(int k = 0; k < usedSettings.filterInventory.getSlots(); k++){
|
||||||
ItemStack slot = usedSettings.filterInventory.getStackInSlot(k);
|
ItemStack slot = usedSettings.filterInventory.getStackInSlot(k);
|
||||||
if(StackUtil.isValid(slot)){
|
if(StackUtil.isValid(slot)){
|
||||||
if(SlotFilter.isFilter(slot)){
|
if(SlotFilter.isFilter(slot)){
|
||||||
ItemStackHandlerCustom inv = new ItemStackHandlerCustom(ContainerFilter.SLOT_AMOUNT);
|
ItemStackHandlerCustom inv = new ItemStackHandlerCustom(ContainerFilter.SLOT_AMOUNT);
|
||||||
ItemDrill.loadSlotsFromNBT(inv, slot);
|
ItemDrill.loadSlotsFromNBT(inv, slot);
|
||||||
|
|
||||||
boolean did = false;
|
boolean did = false;
|
||||||
for(int j = 0; j < inv.getSlots(); j++){
|
for(int j = 0; j < inv.getSlots(); j++){
|
||||||
if(!StackUtil.isValid(inv.getStackInSlot(j))){
|
if(!StackUtil.isValid(inv.getStackInSlot(j))){
|
||||||
inv.setStackInSlot(j, copy);
|
inv.setStackInSlot(j, copy);
|
||||||
did = true;
|
did = true;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(did){
|
|
||||||
ItemDrill.writeSlotsToNBT(inv, slot);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
usedSettings.filterInventory.setStackInSlot(k, copy);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(did){
|
||||||
|
ItemDrill.writeSlotsToNBT(inv, slot);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
usedSettings.filterInventory.setStackInSlot(k, copy);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,8 @@ package de.ellpeck.actuallyadditions.mod.util;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
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 de.ellpeck.actuallyadditions.mod.util.compat.TeslaUtil;
|
||||||
import net.darkhax.tesla.api.ITeslaConsumer;
|
import net.darkhax.tesla.api.ITeslaConsumer;
|
||||||
import net.darkhax.tesla.api.ITeslaProducer;
|
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.CapabilityFluidHandler;
|
||||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
import org.cyclops.commoncapabilities.api.capability.itemhandler.ISlotlessItemHandler;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public final class WorldUtil{
|
public final class WorldUtil{
|
||||||
|
|
||||||
public static boolean doItemInteraction(int slotExtract, int slotInsert, IItemHandler extract, IItemHandler insert, int maxExtract){
|
public static boolean doItemInteraction(SlotlessableItemHandlerWrapper extractWrapper, SlotlessableItemHandlerWrapper insertWrapper, int maxExtract){
|
||||||
ItemStack theoreticalExtract = extract.extractItem(slotExtract, maxExtract, true);
|
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)){
|
if(StackUtil.isValid(theoreticalExtract)){
|
||||||
ItemStack remaining = insert.insertItem(slotInsert, theoreticalExtract, false);
|
ItemStack remaining = insertItem(insertWrapper, theoreticalExtract, false, slotStart, slotEnd);
|
||||||
if(!ItemStack.areItemStacksEqual(remaining, theoreticalExtract)){
|
if(!ItemStack.areItemStacksEqual(remaining, theoreticalExtract)){
|
||||||
int toExtract = !StackUtil.isValid(remaining) ? StackUtil.getStackSize(theoreticalExtract) : StackUtil.getStackSize(theoreticalExtract)-StackUtil.getStackSize(remaining);
|
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 true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
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){
|
public static void doEnergyInteraction(TileEntity tileFrom, TileEntity tileTo, EnumFacing sideTo, int maxTransfer){
|
||||||
if(maxTransfer > 0){
|
if(maxTransfer > 0){
|
||||||
EnumFacing opp = sideTo == null ? null : sideTo.getOpposite();
|
EnumFacing opp = sideTo == null ? null : sideTo.getOpposite();
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue