From f24da8d8f130e7a9529183018afdaf5d38951ec9 Mon Sep 17 00:00:00 2001 From: Lex Date: Thu, 29 Oct 2020 01:45:24 +0700 Subject: [PATCH] Revert "start test change fluid save ID to name" This reverts commit a78751024090b13b4cc7c5516c5b7331af258485. --- .../container/ContainerFluidInterface.java | 37 +++++++++++-------- .../packet/part/PacketFluidInterface.java | 24 ++++++------ 2 files changed, 32 insertions(+), 29 deletions(-) diff --git a/src/main/scala/extracells/container/ContainerFluidInterface.java b/src/main/scala/extracells/container/ContainerFluidInterface.java index 1b300cb..f4f2aa8 100644 --- a/src/main/scala/extracells/container/ContainerFluidInterface.java +++ b/src/main/scala/extracells/container/ContainerFluidInterface.java @@ -71,14 +71,6 @@ private int getFluidID(ForgeDirection side) { return fluid.getID(); } - private String getFluidName(ForgeDirection side) { - Fluid fluid = this.fluidInterface.getFilter(side); - if (fluid == null) { - return ""; - } - return fluid.getName(); - } - @Override public void onContainerClosed(EntityPlayer player) { super.onContainerClosed(player); @@ -147,14 +139,27 @@ public ItemStack transferStackInSlot(EntityPlayer player, int slotnumber) { @Override public void updateContainer() { - FluidStack[] fluidStacks = new FluidStack[6]; - String[] fluidNames = new String[6]; - for (int i = 0; i < 6; i++) { - ForgeDirection location = ForgeDirection.getOrientation(i); - fluidStacks[i] = fluidInterface.getFluidTank(location).getFluid(); - fluidNames[i] = getFluidName(location); - } - new PacketFluidInterface(fluidStacks, fluidNames, this.player).sendPacketToPlayer(this.player); + new PacketFluidInterface(new FluidStack[] { + this.fluidInterface.getFluidTank( + ForgeDirection.getOrientation(0)).getFluid(), + this.fluidInterface.getFluidTank( + ForgeDirection.getOrientation(1)).getFluid(), + this.fluidInterface.getFluidTank( + ForgeDirection.getOrientation(2)).getFluid(), + this.fluidInterface.getFluidTank( + ForgeDirection.getOrientation(3)).getFluid(), + this.fluidInterface.getFluidTank( + ForgeDirection.getOrientation(4)).getFluid(), + this.fluidInterface.getFluidTank( + ForgeDirection.getOrientation(5)).getFluid() }, + new Integer[] { getFluidID(ForgeDirection.getOrientation(0)), + getFluidID(ForgeDirection.getOrientation(1)), + getFluidID(ForgeDirection.getOrientation(2)), + getFluidID(ForgeDirection.getOrientation(3)), + getFluidID(ForgeDirection.getOrientation(4)), + getFluidID(ForgeDirection.getOrientation(5)) }, + this.player).sendPacketToPlayer(this.player); + } } diff --git a/src/main/scala/extracells/network/packet/part/PacketFluidInterface.java b/src/main/scala/extracells/network/packet/part/PacketFluidInterface.java index 16e576d..4d922c3 100644 --- a/src/main/scala/extracells/network/packet/part/PacketFluidInterface.java +++ b/src/main/scala/extracells/network/packet/part/PacketFluidInterface.java @@ -17,13 +17,13 @@ public class PacketFluidInterface extends AbstractPacket { FluidStack[] tank; - String[] filter; + Integer[] filter; int fluidID; int filterSlot; public PacketFluidInterface() {} - public PacketFluidInterface(FluidStack[] _tank, String[] _filter, + public PacketFluidInterface(FluidStack[] _tank, Integer[] _filter, EntityPlayer _player) { super(_player); this.mode = 0; @@ -73,11 +73,10 @@ private void mode0() { container.fluidInterface.setFluidTank( ForgeDirection.getOrientation(i), this.tank[i]); } - for (int i = 0; i < filter.length; i++) { - if (gui.filter[i] != null) { + for (int i = 0; i < this.filter.length; i++) { + if (gui.filter[i] != null) gui.filter[i].setFluid(FluidRegistry - .getFluid(filter[i])); - } + .getFluid(this.filter[i])); } } } @@ -96,13 +95,12 @@ public void readData(ByteBuf in) { else this.tank[i] = null; } - this.filter = new String[tag.getInteger("lengthFilter")]; + this.filter = new Integer[tag.getInteger("lengthFilter")]; for (int i = 0; i < this.filter.length; i++) { - if (tag.hasKey("filter#" + i)) { - this.filter[i] = tag.getString("filter#" + i); - } else { - this.filter[i] = ""; - } + if (tag.hasKey("filter#" + i)) + this.filter[i] = tag.getInteger("filter#" + i); + else + this.filter[i] = -1; } break; case 1: @@ -129,7 +127,7 @@ public void writeData(ByteBuf out) { tag.setInteger("lengthFilter", this.filter.length); for (int i = 0; i < this.filter.length; i++) { if (this.filter[i] != null) { - tag.setString("filter#" + i, this.filter[i]); + tag.setInteger("filter#" + i, this.filter[i]); } } ByteBufUtils.writeTag(out, tag);