diff options
author | Glease <4586901+Glease@users.noreply.github.com> | 2022-10-22 16:22:19 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-22 10:22:19 +0200 |
commit | cd73c5e12bc75bb78b5ec0c956dd0b8146a44a4e (patch) | |
tree | 4a9afe387c879ea93dd25095865e9965b1b4eda1 /src/main/java/gregtech/api/gui | |
parent | 1584815cb2f82e79e86f72d2fdba3a13f59fe21e (diff) | |
download | GT5-Unofficial-cd73c5e12bc75bb78b5ec0c956dd0b8146a44a4e.tar.gz GT5-Unofficial-cd73c5e12bc75bb78b5ec0c956dd0b8146a44a4e.tar.bz2 GT5-Unofficial-cd73c5e12bc75bb78b5ec0c956dd0b8146a44a4e.zip |
fix client side not reading amount of fluid from correct slot (#1480)
Diffstat (limited to 'src/main/java/gregtech/api/gui')
3 files changed, 12 insertions, 17 deletions
diff --git a/src/main/java/gregtech/api/gui/GT_Container_2by2_Fluid.java b/src/main/java/gregtech/api/gui/GT_Container_2by2_Fluid.java index 35ed089c97..d2d6249e5b 100644 --- a/src/main/java/gregtech/api/gui/GT_Container_2by2_Fluid.java +++ b/src/main/java/gregtech/api/gui/GT_Container_2by2_Fluid.java @@ -6,6 +6,7 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Multi import gregtech.api.util.GT_Utility; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; @@ -30,20 +31,15 @@ public class GT_Container_2by2_Fluid extends GT_ContainerMetaTile_Machine { @Override public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { if (aSlotIndex < 4 && aSlotIndex >= 0 && aMouseclick < 2) { + GT_MetaTileEntity_Hatch_MultiInput tTank = + (GT_MetaTileEntity_Hatch_MultiInput) mTileEntity.getMetaTileEntity(); if (mTileEntity.isClientSide()) { /* - * While a logical client don't really need to process fluid cells upon click (it could have just wait - * for server side to send the result), doing so would result in every fluid interaction having a - * noticeable delay between clicking and changes happening even on single player. - * I'd imagine this lag to become only more severe when playing MP over ethernet, which would have much more latency - * than a memory connection + * See comment in gregtech.api.gui.GT_Container_BasicTank.slotClick on why this is necessary */ - GT_MetaTileEntity_Hatch_MultiInput tTank = - (GT_MetaTileEntity_Hatch_MultiInput) mTileEntity.getMetaTileEntity(); - tTank.setDrainableStack(GT_Utility.getFluidFromDisplayStack(tTank.getStackInSlot(2))); + Slot slot = (Slot) inventorySlots.get(aSlotIndex); + tTank.setFluid(GT_Utility.getFluidFromDisplayStack(slot.getStack()), aSlotIndex); } - GT_MetaTileEntity_Hatch_MultiInput tTank = - (GT_MetaTileEntity_Hatch_MultiInput) mTileEntity.getMetaTileEntity(); MultiFluidAccess tDrainableAccess = MultiFluidAccess.from(tTank, aSlotIndex); ItemStack tStackHeld = aPlayer.inventory.getItemStack(); FluidStack tFluidHeld = GT_Utility.getFluidForFilledItem(tStackHeld, true); diff --git a/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java b/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java index 590d406ca4..28779ada08 100644 --- a/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java +++ b/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java @@ -215,13 +215,12 @@ public class GT_Container_BasicMachine extends GT_Container_BasicTank { default: if (aSlotNumber == OTHER_SLOT_COUNT + 1 + machine.mInputSlotCount + machine.mOutputItems.length && aMouseclick < 2) { + GT_MetaTileEntity_BasicTank tTank = (GT_MetaTileEntity_BasicTank) mTileEntity.getMetaTileEntity(); if (mTileEntity.isClientSide()) { // see parent class slotClick for an explanation on why doing this - GT_MetaTileEntity_BasicTank tTank = - (GT_MetaTileEntity_BasicTank) mTileEntity.getMetaTileEntity(); - tTank.setFillableStack(GT_Utility.getFluidFromDisplayStack(tTank.getStackInSlot(2))); + Slot slot = (Slot) inventorySlots.get(aSlotNumber); + tTank.setFillableStack(GT_Utility.getFluidFromDisplayStack(slot.getStack())); } - GT_MetaTileEntity_BasicTank tTank = (GT_MetaTileEntity_BasicTank) mTileEntity.getMetaTileEntity(); IFluidAccess tFillableAccess = constructFluidAccess(tTank, true); GT_Recipe_Map recipes = machine.getRecipeList(); // If the machine has recipes but no fluid inputs, disallow filling this slot with fluids. diff --git a/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java b/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java index 27138511f0..dc306ec223 100644 --- a/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java +++ b/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java @@ -42,6 +42,7 @@ public class GT_Container_BasicTank extends GT_ContainerMetaTile_Machine { @Override public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { if (aSlotIndex == 2 && aMouseclick < 2) { + GT_MetaTileEntity_BasicTank tTank = (GT_MetaTileEntity_BasicTank) mTileEntity.getMetaTileEntity(); if (mTileEntity.isClientSide()) { /* * While a logical client don't really need to process fluid cells upon click (it could have just wait @@ -50,10 +51,9 @@ public class GT_Container_BasicTank extends GT_ContainerMetaTile_Machine { * I'd imagine this lag to become only more severe when playing MP over ethernet, which would have much more latency * than a memory connection */ - GT_MetaTileEntity_BasicTank tTank = (GT_MetaTileEntity_BasicTank) mTileEntity.getMetaTileEntity(); - tTank.setDrainableStack(GT_Utility.getFluidFromDisplayStack(tTank.getStackInSlot(2))); + Slot slot = (Slot) inventorySlots.get(aSlotIndex); + tTank.setDrainableStack(GT_Utility.getFluidFromDisplayStack(slot.getStack())); } - GT_MetaTileEntity_BasicTank tTank = (GT_MetaTileEntity_BasicTank) mTileEntity.getMetaTileEntity(); IFluidAccess tDrainableAccess = constructFluidAccess(tTank, false); return handleFluidSlotClick( tDrainableAccess, aPlayer, aMouseclick == 0, true, !tTank.isDrainableStackSeparate()); |