mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2024-11-22 19:58:35 +01:00
fixed pipe tabs not updating occasionally
This commit is contained in:
parent
d46858507f
commit
c0c69807c0
1 changed files with 17 additions and 9 deletions
|
@ -23,6 +23,7 @@ public abstract class AbstractPipeGui<T extends AbstractPipeContainer<?>> extend
|
||||||
|
|
||||||
private static final ResourceLocation TEXTURE = new ResourceLocation(PrettyPipes.ID, "textures/gui/pipe.png");
|
private static final ResourceLocation TEXTURE = new ResourceLocation(PrettyPipes.ID, "textures/gui/pipe.png");
|
||||||
private final List<Tab> tabs = new ArrayList<>();
|
private final List<Tab> tabs = new ArrayList<>();
|
||||||
|
private final ItemStack[] lastItems = new ItemStack[this.container.tile.modules.getSlots()];
|
||||||
|
|
||||||
public AbstractPipeGui(T screenContainer, PlayerInventory inv, ITextComponent titleIn) {
|
public AbstractPipeGui(T screenContainer, PlayerInventory inv, ITextComponent titleIn) {
|
||||||
super(screenContainer, inv, titleIn);
|
super(screenContainer, inv, titleIn);
|
||||||
|
@ -36,6 +37,22 @@ public abstract class AbstractPipeGui<T extends AbstractPipeContainer<?>> extend
|
||||||
this.initTabs();
|
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
|
@Override
|
||||||
public void render(int mouseX, int mouseY, float partialTicks) {
|
public void render(int mouseX, int mouseY, float partialTicks) {
|
||||||
this.renderBackground();
|
this.renderBackground();
|
||||||
|
@ -71,15 +88,6 @@ public abstract class AbstractPipeGui<T extends AbstractPipeContainer<?>> 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
|
@Override
|
||||||
public boolean mouseClicked(double x, double y, int button) {
|
public boolean mouseClicked(double x, double y, int button) {
|
||||||
for (Tab tab : this.tabs) {
|
for (Tab tab : this.tabs) {
|
||||||
|
|
Loading…
Reference in a new issue