diff --git a/build.gradle b/build.gradle index 2799444..c105b1d 100644 --- a/build.gradle +++ b/build.gradle @@ -33,7 +33,7 @@ repositories { apply plugin: 'net.minecraftforge.gradle.forge' -version = "2.1.0" +version = "2.1.1" group= "gigaherz.enderRift" archivesBaseName = "EnderRift-1.11.0" diff --git a/src/main/java/gigaherz/enderRift/EnderRiftMod.java b/src/main/java/gigaherz/enderRift/EnderRiftMod.java index 7c73850..cdcffb8 100644 --- a/src/main/java/gigaherz/enderRift/EnderRiftMod.java +++ b/src/main/java/gigaherz/enderRift/EnderRiftMod.java @@ -37,6 +37,7 @@ import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.oredict.RecipeSorter; +import org.apache.commons.io.IOUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; diff --git a/src/main/java/gigaherz/enderRift/automation/iface/ContainerInterface.java b/src/main/java/gigaherz/enderRift/automation/iface/ContainerInterface.java index 2ddb507..39e2e16 100644 --- a/src/main/java/gigaherz/enderRift/automation/iface/ContainerInterface.java +++ b/src/main/java/gigaherz/enderRift/automation/iface/ContainerInterface.java @@ -76,9 +76,9 @@ public ItemStack slotClick(int slotId, int clickedButton, ClickType mode, Entity copy.setCount(1); slot.putStack(copy); } - else if (slot.getStack() != null) + else if (slot.getStack().getCount() > 0) { - slot.putStack(null); + slot.putStack(ItemStack.EMPTY); } return slot.getStack().copy(); diff --git a/src/main/java/gigaherz/enderRift/automation/iface/TileInterface.java b/src/main/java/gigaherz/enderRift/automation/iface/TileInterface.java index 34e9a1b..b1c85b5 100644 --- a/src/main/java/gigaherz/enderRift/automation/iface/TileInterface.java +++ b/src/main/java/gigaherz/enderRift/automation/iface/TileInterface.java @@ -10,6 +10,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.util.EnumFacing; +import net.minecraft.util.NonNullList; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.Constants; import net.minecraftforge.items.CapabilityItemHandler; @@ -111,7 +112,7 @@ public void update() ItemStack inSlot = outputs.getStackInSlot(i); if (inFilter.getCount() > 0) { - if (inSlot.getCount() > 0) + if (inSlot.getCount() <= 0) { int free = 64; inSlot = AutomationHelper.extractItems(getCombinedInventory(), inFilter, free, false); @@ -237,11 +238,11 @@ public boolean isUseableByPlayer(EntityPlayer player) private class FilterInventory implements IItemHandlerModifiable { - final ItemStack[] filters; + final NonNullList filters; public FilterInventory(int slotCount) { - filters = new ItemStack[slotCount]; + filters = NonNullList.withSize(slotCount,ItemStack.EMPTY); } @Override @@ -253,21 +254,22 @@ public int getSlots() @Override public ItemStack getStackInSlot(int slot) { - if (slot < 0 || slot >= filters.length) + if (slot < 0 || slot >= filters.size()) return ItemStack.EMPTY; - return filters[slot]; + return filters.get(slot); } @Override public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) { - if (slot < 0 || slot >= filters.length) + if (slot < 0 || slot >= filters.size()) return stack; if (!simulate) { - filters[slot] = stack.copy(); - filters[slot].setCount(1); + ItemStack cp = stack.copy(); + cp.setCount(1); + filters.set(slot, cp); } return stack; @@ -288,27 +290,12 @@ public int getSlotLimit(int slot) @Override public void setStackInSlot(int index, ItemStack stack) { - filters[index] = stack; + stack = stack.copy(); + stack.setCount(1); - if (stack.getCount() > this.getInventoryStackLimit()) - { - stack.setCount(this.getInventoryStackLimit()); - } + filters.set(index, stack); markDirty(); } - - public int getInventoryStackLimit() - { - return 1; - } - - public void clear() - { - for (int i = 0; i < filters.length; ++i) - { - filters[i] = null; - } - } } }