From bcf871bf44f5dd123b4ad9fa4cab497437b9298c Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Sat, 12 Mar 2022 16:23:06 +0800 Subject: fix pss gui & make average IO actually an average (#157) --- .../gregtech/api/gui/CONTAINER_PowerSubStation.java | 17 ++++++++++++++--- .../gtPlusPlus/xmod/gregtech/api/gui/SyncedLong.java | 13 +++++++++---- 2 files changed, 23 insertions(+), 7 deletions(-) (limited to 'src/main/java/gtPlusPlus/xmod/gregtech/api/gui') diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_PowerSubStation.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_PowerSubStation.java index b00af39d91..c42fa98cd3 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_PowerSubStation.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_PowerSubStation.java @@ -26,13 +26,18 @@ public class CONTAINER_PowerSubStation extends GT_Container_MultiMachine { } public void addSlots(final InventoryPlayer aInventoryPlayer) { - this.addSlotToContainer(new Slot((IInventory) this.mTileEntity, 1, 155, 5)); - this.addSlotToContainer(new SlotNoInput((IInventory) this.mTileEntity, 2, 155, 23)); + this.addSlotToContainer(new Slot(this.mTileEntity, 1, 155, 5)); + this.addSlotToContainer(new SlotNoInput(this.mTileEntity, 2, 155, 23)); - for (int i = 0; i < 9; ++i) { this.addSlotToContainer(new Slot((IInventory) aInventoryPlayer, i, 8 + i * 18, 167)); } + for (int i = 0; i < 9; ++i) { this.addSlotToContainer(new Slot(aInventoryPlayer, i, 8 + i * 18, 167)); } } + @Override + public boolean doesBindPlayerInventory() { + return false; + } + public int getSlotCount() { return 10; } @@ -45,6 +50,12 @@ public class CONTAINER_PowerSubStation extends GT_Container_MultiMachine { public void detectAndSendChanges() { super.detectAndSendChanges(); + if (manager == null) + // maybe not yet initialized + // stupid java + // ask greg why he wants to call a method that's definitely going to be overridden in subclass in constructor + return; + GregtechMetaTileEntity_PowerSubStationController aPSS = (GregtechMetaTileEntity_PowerSubStationController) mTileEntity.getMetaTileEntity(); mStoredEU.setValue(mTileEntity.getStoredEU()); mMaxStoredEU.setValue(mTileEntity.getEUCapacity()); diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/SyncedLong.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/SyncedLong.java index 4430631e07..4214d32469 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/SyncedLong.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/SyncedLong.java @@ -24,19 +24,24 @@ class SyncedLong { } public void setValue(long value) { - if (this.value != value) + if (this.value != value) { dirty = true; - this.value = value; + this.value = value; + } } void detectAndSendChanges(SendChanges func, int timer) { if (dirty || (timer & 0xff) == 0) { for (int i = 0; i < 4; i++) { - func.sendProgressBarUpdate(index + i, (int) ((value >> (16 * i)) & Short.MIN_VALUE)); + func.sendProgressBarUpdate(index + i, (int) ((value >> (16 * i)) & 0xffff)); } dirty = false; } } + + private long getPiece(int index) { + return ((long) pieces[index]) & 0xffff; + } boolean updateProgressBar(int short1, int short2) { int offset = short1 - index; @@ -44,7 +49,7 @@ class SyncedLong { pieces[offset] = (short) short2; received |= (1 << offset); if (received == 0b1111) { - value = ((long) pieces[0]) | ((long) pieces[1] << 16) | ((long) pieces[2] << 32) | ((long) pieces[3] << 48); + value = (getPiece(0)) | (getPiece(1) << 16) | (getPiece(2) << 32) | (getPiece(3) << 48); received = 0; } return true; -- cgit