diff --git a/CHANGELOG.md b/CHANGELOG.md index e389f817b..8977d9461 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,8 @@ ### 0.6.11 **Bugfixes** - Fixed crafting patterns crashing when item of an input or output no longer exists -- Fixed importer / exporter / crafter not being able to interact with some inventories +- Fixed Grid letting the current held item flicker +- Converted all inventories in the mod to Forge's item handler capability system ### 0.6.10 **Bugfixes** diff --git a/src/main/java/refinedstorage/container/ContainerGrid.java b/src/main/java/refinedstorage/container/ContainerGrid.java index 664a1c2a7..29a46b647 100755 --- a/src/main/java/refinedstorage/container/ContainerGrid.java +++ b/src/main/java/refinedstorage/container/ContainerGrid.java @@ -3,16 +3,12 @@ package refinedstorage.container; import net.minecraft.client.gui.GuiScreen; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ClickType; -import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraftforge.items.SlotItemHandler; import refinedstorage.RefinedStorage; import refinedstorage.block.EnumGridType; -import refinedstorage.container.slot.SlotDisabled; -import refinedstorage.container.slot.SlotGridCraftingResult; -import refinedstorage.container.slot.SlotOutput; -import refinedstorage.container.slot.SlotSpecimenLegacy; +import refinedstorage.container.slot.*; import refinedstorage.network.MessageGridCraftingShift; import refinedstorage.tile.grid.IGrid; import refinedstorage.tile.grid.TileGrid; @@ -22,9 +18,11 @@ import java.util.ArrayList; import java.util.List; public class ContainerGrid extends ContainerBase { - private List craftingSlots = new ArrayList(); + private List craftingSlots = new ArrayList(); private SlotGridCraftingResult craftingResultSlot; + private SlotDisabled patternResultSlot; + private IGrid grid; public ContainerGrid(EntityPlayer player, IGrid grid) { @@ -39,7 +37,7 @@ public class ContainerGrid extends ContainerBase { int y = 106; for (int i = 0; i < 9; ++i) { - Slot slot = new Slot(((TileGrid) grid).getMatrix(), i, x, y); + SlotGridCrafting slot = new SlotGridCrafting(((TileGrid) grid).getMatrix(), i, x, y); craftingSlots.add(slot); @@ -80,7 +78,7 @@ public class ContainerGrid extends ContainerBase { return (TileGrid) grid; } - public List getCraftingSlots() { + public List getCraftingSlots() { return craftingSlots; } @@ -91,15 +89,24 @@ public class ContainerGrid extends ContainerBase { That is why we override here to get rid of the check and ALWAYS send slot changes. */ @Override public void detectAndSendChanges() { - for (int i = 0; i < this.inventorySlots.size(); ++i) { - ItemStack itemstack = ((Slot) this.inventorySlots.get(i)).getStack(); - ItemStack itemstack1 = (ItemStack) this.inventoryItemStacks.get(i); + for (int i = 0; i < inventorySlots.size(); ++i) { + if (inventorySlots.get(i) instanceof SlotGridCrafting || inventorySlots.get(i) == craftingResultSlot) { + for (int j = 0; j < crafters.size(); ++j) { + crafters.get(j).sendSlotContents(this, i, inventorySlots.get(i).getStack()); + } + } else { + ItemStack current = inventorySlots.get(i).getStack(); + ItemStack cached = inventoryItemStacks.get(i); - itemstack1 = itemstack == null ? null : itemstack.copy(); - this.inventoryItemStacks.set(i, itemstack1); + if (!ItemStack.areItemStacksEqual(cached, current)) { + cached = current == null ? null : current.copy(); - for (int j = 0; j < this.crafters.size(); ++j) { - ((ICrafting) this.crafters.get(j)).sendSlotContents(this, i, itemstack1); + inventoryItemStacks.set(i, cached); + + for (int j = 0; j < crafters.size(); ++j) { + crafters.get(j).sendSlotContents(this, i, cached); + } + } } } } diff --git a/src/main/java/refinedstorage/container/slot/SlotGridCrafting.java b/src/main/java/refinedstorage/container/slot/SlotGridCrafting.java new file mode 100755 index 000000000..108e54b9e --- /dev/null +++ b/src/main/java/refinedstorage/container/slot/SlotGridCrafting.java @@ -0,0 +1,10 @@ +package refinedstorage.container.slot; + +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; + +public class SlotGridCrafting extends Slot { + public SlotGridCrafting(IInventory inventory, int index, int x, int y) { + super(inventory, index, x, y); + } +} diff --git a/src/main/java/refinedstorage/tile/grid/TileGrid.java b/src/main/java/refinedstorage/tile/grid/TileGrid.java index ca9300978..80456840e 100755 --- a/src/main/java/refinedstorage/tile/grid/TileGrid.java +++ b/src/main/java/refinedstorage/tile/grid/TileGrid.java @@ -169,6 +169,8 @@ public class TileGrid extends TileMachine implements IGrid { } } } + + container.detectAndSendChanges(); } public void onCreatePattern() {