Made the Interface sideless, fixes #427
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
package com.raoulvdberge.refinedstorage.inventory;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class ItemHandlerInterface implements IItemHandler {
|
||||
private IItemHandler importItems;
|
||||
private IItemHandler exportItems;
|
||||
|
||||
public ItemHandlerInterface(IItemHandler importItems, IItemHandler exportItems) {
|
||||
this.importItems = importItems;
|
||||
this.exportItems = exportItems;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlots() {
|
||||
return importItems.getSlots() + exportItems.getSlots();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
return slot < 9 ? importItems.getStackInSlot(slot) : exportItems.getStackInSlot(slot - 9);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
|
||||
return slot < 9 ? importItems.insertItem(slot, stack, simulate) : stack;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack extractItem(int slot, int amount, boolean simulate) {
|
||||
return slot >= 9 ? exportItems.extractItem(slot - 9, amount, simulate) : ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotLimit(int slot) {
|
||||
return slot < 9 ? importItems.getSlotLimit(slot) : exportItems.getSlotLimit(slot - 9);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import com.raoulvdberge.refinedstorage.RS;
|
||||
import com.raoulvdberge.refinedstorage.RSUtils;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBasic;
|
||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerInterface;
|
||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerUpgrade;
|
||||
import com.raoulvdberge.refinedstorage.item.ItemUpgrade;
|
||||
import com.raoulvdberge.refinedstorage.tile.config.IComparable;
|
||||
@@ -16,7 +17,6 @@ import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.wrapper.CombinedInvWrapper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class TileInterface extends TileNode implements IComparable {
|
||||
@@ -27,13 +27,9 @@ public class TileInterface extends TileNode implements IComparable {
|
||||
private ItemHandlerBasic importItems = new ItemHandlerBasic(9, this);
|
||||
|
||||
private ItemHandlerBasic exportSpecimenItems = new ItemHandlerBasic(9, this);
|
||||
private ItemHandlerBasic exportItems = new ItemHandlerBasic(9, this) {
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
|
||||
return stack;
|
||||
}
|
||||
};
|
||||
private ItemHandlerBasic exportItems = new ItemHandlerBasic(9, this);
|
||||
|
||||
private ItemHandlerInterface items = new ItemHandlerInterface(importItems, exportItems);
|
||||
|
||||
private ItemHandlerUpgrade upgrades = new ItemHandlerUpgrade(4, this, ItemUpgrade.TYPE_SPEED, ItemUpgrade.TYPE_STACK, ItemUpgrade.TYPE_CRAFTING);
|
||||
|
||||
@@ -193,7 +189,7 @@ public class TileInterface extends TileNode implements IComparable {
|
||||
@Override
|
||||
public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) {
|
||||
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
|
||||
return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(facing == EnumFacing.DOWN ? exportItems : importItems);
|
||||
return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(items);
|
||||
}
|
||||
|
||||
return super.getCapability(capability, facing);
|
||||
|
||||
Reference in New Issue
Block a user