aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrepo-alt <wvk17@yandex.ru>2022-08-26 23:19:14 +0300
committerGitHub <noreply@github.com>2022-08-26 22:19:14 +0200
commit735d35d5fda3d10e95ae0263c74eb8a09d3c7ef1 (patch)
tree10aeded61d5d8e7154270ea4ddfebc8c1b9dc30a
parent6f48ff3d6b10b6a4f225cecea461cb60854f5fd7 (diff)
downloadGT5-Unofficial-735d35d5fda3d10e95ae0263c74eb8a09d3c7ef1.tar.gz
GT5-Unofficial-735d35d5fda3d10e95ae0263c74eb8a09d3c7ef1.tar.bz2
GT5-Unofficial-735d35d5fda3d10e95ae0263c74eb8a09d3c7ef1.zip
Fix Stocking ME Input bus item amount client side display on dedicated server (#1304)
-rw-r--r--src/main/java/gregtech/common/gui/GT_Container_InputBus_ME.java43
1 files changed, 42 insertions, 1 deletions
diff --git a/src/main/java/gregtech/common/gui/GT_Container_InputBus_ME.java b/src/main/java/gregtech/common/gui/GT_Container_InputBus_ME.java
index b815856fe4..0f7b26eea7 100644
--- a/src/main/java/gregtech/common/gui/GT_Container_InputBus_ME.java
+++ b/src/main/java/gregtech/common/gui/GT_Container_InputBus_ME.java
@@ -2,13 +2,15 @@ package gregtech.common.gui;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
import gregtech.api.gui.GT_ContainerMetaTile_Machine;
import gregtech.api.gui.GT_Slot_Holo;
import gregtech.api.gui.GT_Slot_Holo_ME;
-import gregtech.api.gui.GT_Slot_Render;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.util.GT_Utility;
import gregtech.common.tileentities.machines.GT_MetaTileEntity_Hatch_InputBus_ME;
@@ -45,6 +47,45 @@ public class GT_Container_InputBus_ME extends GT_ContainerMetaTile_Machine {
return false;
}
+ private final static int PROGRESS_PACKET_INDEX_OFFSET = 200;
+
+ @Override
+ public void detectAndSendChanges() {
+ super.detectAndSendChanges();
+ if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null)
+ return;
+ for (Object crafter : this.crafters) {
+ ICrafting player = (ICrafting) crafter;
+ for (int i = 0; i < 16; ++i) {
+ ItemStack s = ((Slot) this.inventorySlots.get(i + 16)).getStack();
+ if (s == null)
+ continue;
+ player.sendProgressBarUpdate(this, PROGRESS_PACKET_INDEX_OFFSET + 2 * i, s.stackSize & 65535);
+ player.sendProgressBarUpdate(this, PROGRESS_PACKET_INDEX_OFFSET + 2 * i + 1, s.stackSize >>> 16);
+ }
+ }
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void updateProgressBar(int id, int value) {
+ super.updateProgressBar(id, value);
+ if (id >= PROGRESS_PACKET_INDEX_OFFSET && id < (PROGRESS_PACKET_INDEX_OFFSET + 32)) {
+ int index = (id - PROGRESS_PACKET_INDEX_OFFSET) / 2;
+ ItemStack s = ((Slot) this.inventorySlots.get(index + 16)).getStack();
+ if (s != null) {
+ if ((id - PROGRESS_PACKET_INDEX_OFFSET) % 2 == 0) {
+ s.stackSize &= 0xFFFF0000;
+ s.stackSize += (value & 0xFFFF);
+ }
+ else {
+ s.stackSize &= 0xFFFF;
+ s.stackSize += value << 16;
+ }
+ }
+ }
+ }
+
@Override
public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) {
if (aSlotIndex >= 0 && aSlotIndex < 16) {