Fixed Grid letting the current held item flicker
This commit is contained in:
@@ -3,7 +3,8 @@
|
|||||||
### 0.6.11
|
### 0.6.11
|
||||||
**Bugfixes**
|
**Bugfixes**
|
||||||
- Fixed crafting patterns crashing when item of an input or output no longer exists
|
- 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
|
### 0.6.10
|
||||||
**Bugfixes**
|
**Bugfixes**
|
||||||
|
|||||||
@@ -3,16 +3,12 @@ package refinedstorage.container;
|
|||||||
import net.minecraft.client.gui.GuiScreen;
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.ClickType;
|
import net.minecraft.inventory.ClickType;
|
||||||
import net.minecraft.inventory.ICrafting;
|
|
||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.Slot;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.items.SlotItemHandler;
|
import net.minecraftforge.items.SlotItemHandler;
|
||||||
import refinedstorage.RefinedStorage;
|
import refinedstorage.RefinedStorage;
|
||||||
import refinedstorage.block.EnumGridType;
|
import refinedstorage.block.EnumGridType;
|
||||||
import refinedstorage.container.slot.SlotDisabled;
|
import refinedstorage.container.slot.*;
|
||||||
import refinedstorage.container.slot.SlotGridCraftingResult;
|
|
||||||
import refinedstorage.container.slot.SlotOutput;
|
|
||||||
import refinedstorage.container.slot.SlotSpecimenLegacy;
|
|
||||||
import refinedstorage.network.MessageGridCraftingShift;
|
import refinedstorage.network.MessageGridCraftingShift;
|
||||||
import refinedstorage.tile.grid.IGrid;
|
import refinedstorage.tile.grid.IGrid;
|
||||||
import refinedstorage.tile.grid.TileGrid;
|
import refinedstorage.tile.grid.TileGrid;
|
||||||
@@ -22,9 +18,11 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ContainerGrid extends ContainerBase {
|
public class ContainerGrid extends ContainerBase {
|
||||||
private List<Slot> craftingSlots = new ArrayList<Slot>();
|
private List<SlotGridCrafting> craftingSlots = new ArrayList<SlotGridCrafting>();
|
||||||
private SlotGridCraftingResult craftingResultSlot;
|
private SlotGridCraftingResult craftingResultSlot;
|
||||||
|
|
||||||
private SlotDisabled patternResultSlot;
|
private SlotDisabled patternResultSlot;
|
||||||
|
|
||||||
private IGrid grid;
|
private IGrid grid;
|
||||||
|
|
||||||
public ContainerGrid(EntityPlayer player, IGrid grid) {
|
public ContainerGrid(EntityPlayer player, IGrid grid) {
|
||||||
@@ -39,7 +37,7 @@ public class ContainerGrid extends ContainerBase {
|
|||||||
int y = 106;
|
int y = 106;
|
||||||
|
|
||||||
for (int i = 0; i < 9; ++i) {
|
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);
|
craftingSlots.add(slot);
|
||||||
|
|
||||||
@@ -80,7 +78,7 @@ public class ContainerGrid extends ContainerBase {
|
|||||||
return (TileGrid) grid;
|
return (TileGrid) grid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Slot> getCraftingSlots() {
|
public List<SlotGridCrafting> getCraftingSlots() {
|
||||||
return craftingSlots;
|
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. */
|
That is why we override here to get rid of the check and ALWAYS send slot changes. */
|
||||||
@Override
|
@Override
|
||||||
public void detectAndSendChanges() {
|
public void detectAndSendChanges() {
|
||||||
for (int i = 0; i < this.inventorySlots.size(); ++i) {
|
for (int i = 0; i < inventorySlots.size(); ++i) {
|
||||||
ItemStack itemstack = ((Slot) this.inventorySlots.get(i)).getStack();
|
if (inventorySlots.get(i) instanceof SlotGridCrafting || inventorySlots.get(i) == craftingResultSlot) {
|
||||||
ItemStack itemstack1 = (ItemStack) this.inventoryItemStacks.get(i);
|
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();
|
if (!ItemStack.areItemStacksEqual(cached, current)) {
|
||||||
this.inventoryItemStacks.set(i, itemstack1);
|
cached = current == null ? null : current.copy();
|
||||||
|
|
||||||
for (int j = 0; j < this.crafters.size(); ++j) {
|
inventoryItemStacks.set(i, cached);
|
||||||
((ICrafting) this.crafters.get(j)).sendSlotContents(this, i, itemstack1);
|
|
||||||
|
for (int j = 0; j < crafters.size(); ++j) {
|
||||||
|
crafters.get(j).sendSlotContents(this, i, cached);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
10
src/main/java/refinedstorage/container/slot/SlotGridCrafting.java
Executable file
10
src/main/java/refinedstorage/container/slot/SlotGridCrafting.java
Executable file
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -169,6 +169,8 @@ public class TileGrid extends TileMachine implements IGrid {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
container.detectAndSendChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onCreatePattern() {
|
public void onCreatePattern() {
|
||||||
|
|||||||
Reference in New Issue
Block a user