diff --git a/src/main/java/de/ellpeck/prettypipes/pipe/modules/containers/AbstractPipeGui.java b/src/main/java/de/ellpeck/prettypipes/pipe/modules/containers/AbstractPipeGui.java index fac88e7..054c2ac 100644 --- a/src/main/java/de/ellpeck/prettypipes/pipe/modules/containers/AbstractPipeGui.java +++ b/src/main/java/de/ellpeck/prettypipes/pipe/modules/containers/AbstractPipeGui.java @@ -23,6 +23,7 @@ public abstract class AbstractPipeGui> extend private static final ResourceLocation TEXTURE = new ResourceLocation(PrettyPipes.ID, "textures/gui/pipe.png"); private final List tabs = new ArrayList<>(); + private final ItemStack[] lastItems = new ItemStack[this.container.tile.modules.getSlots()]; public AbstractPipeGui(T screenContainer, PlayerInventory inv, ITextComponent titleIn) { super(screenContainer, inv, titleIn); @@ -36,6 +37,22 @@ public abstract class AbstractPipeGui> extend this.initTabs(); } + @Override + public void tick() { + super.tick(); + + boolean changed = false; + for (int i = 0; i < this.container.tile.modules.getSlots(); i++) { + ItemStack stack = this.container.tile.modules.getStackInSlot(i); + if (stack != this.lastItems[i]) { + this.lastItems[i] = stack; + changed = true; + } + } + if (changed) + this.initTabs(); + } + @Override public void render(int mouseX, int mouseY, float partialTicks) { this.renderBackground(); @@ -71,15 +88,6 @@ public abstract class AbstractPipeGui> extend } } - @Override - protected void handleMouseClick(Slot slotIn, int slotId, int mouseButton, ClickType type) { - super.handleMouseClick(slotIn, slotId, mouseButton, type); - // this might cause unnecessary tab initializations, but - // it's a pretty cheap operation so it should be fine - if (slotIn != null) - this.initTabs(); - } - @Override public boolean mouseClicked(double x, double y, int button) { for (Tab tab : this.tabs) {