Skip to content

Commit

Permalink
Revert "start test change fluid save ID to name"
Browse files Browse the repository at this point in the history
This reverts commit a787510.
  • Loading branch information
aagrishankov committed Oct 28, 2020
1 parent de2c5e4 commit f24da8d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 29 deletions.
37 changes: 21 additions & 16 deletions src/main/scala/extracells/container/ContainerFluidInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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]));
}
}
}
Expand All @@ -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:
Expand All @@ -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);
Expand Down

0 comments on commit f24da8d

Please sign in to comment.