Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Does not save pipe buffer #1357

Open
eve0415 opened this issue Dec 19, 2020 · 4 comments · May be fixed by #1399
Open

[BUG] Does not save pipe buffer #1357

eve0415 opened this issue Dec 19, 2020 · 4 comments · May be fixed by #1399
Labels
status: accepted type: bug Something isn't working

Comments

@eve0415
Copy link

eve0415 commented Dec 19, 2020

Describe the bug
When the server restarted / reloading the world or chunk, the pipe buffer gets empty.

This make it hard for people like me when you are using steam boiler, with two pipes (In: water from pump, Out: steam)
When I reload the world (entering the game), the pipe buffer get empty resulting back-flow of steam where it should be water.

Versions
Forge: forge-14.23.5.2854
GTCE:
Modpack: ArchitPack Greg
Modified:

  1. Remove GTCE Bees & Greg's Construct & Shadows of Greg.
  2. Update GregTech Community Edition & gtce2oc to the latest version.

Setup
Played both, multiplayer and solo.

Steps To Reproduce

  1. Place some pipes.
  2. Input something (steam, water, can be anything I hope).
  3. Remove the source of input (just make the pipe alone with full of liquid).
  4. Re-enter the world (solo) or restart the server.
  5. See empty pipes which was full before re-entering.

Expected behavior
The pipe's buffer should not be empty when reloading the chunks/world.

Screenshots
Before:
image
After:
image

@eve0415 eve0415 added status: unverified type: bug Something isn't working labels Dec 19, 2020
@warjort
Copy link
Contributor

warjort commented Jan 11, 2021

Looking at the code, the fluid in the pipes is never persisted.

This is a simple patch that fixes the immediate problem, by storing the FluidNetTank in the world saved data:
'''
diff --git a/src/main/java/gregtech/common/pipelike/fluidpipe/net/FluidPipeNet.java b/src/main/java/gregtech/common/pipelike/fluidpipe/net/FluidPipeNet.java
old mode 100644
new mode 100755
index db8cb1be..e70d8955
--- a/src/main/java/gregtech/common/pipelike/fluidpipe/net/FluidPipeNet.java
+++ b/src/main/java/gregtech/common/pipelike/fluidpipe/net/FluidPipeNet.java
@@ -154,4 +154,19 @@ public class FluidPipeNet extends MonolithicPipeNet {
return new FluidPipeProperties(maxTemperature, throughput, gasProof);
}

  • @OverRide
  • public NBTTagCompound serializeNBT() {
  •    final NBTTagCompound nbt = super.serializeNBT();
    
  •    nbt.setTag("FluidNetTank", this.fluidNetTank.writeToNBT(new NBTTagCompound()));
    
  •    return nbt;
    
  • }
  • @OverRide
  • public void deserializeNBT(final NBTTagCompound nbt) {
  •    super.deserializeNBT(nbt);
    
  •    final NBTTagCompound tankData = nbt.getCompoundTag("FluidNetTank");
    
  •    if (tankData != null)
    
  •        this.fluidNetTank.readFromNBT(tankData);
    
  • }

}
'''

This fixes the immediate problem for single player and on the server.

But the client will always see the wrong amounts in the pipes since there is no mechanism to synchronize the FluidNetTank between the server and client.

If the client has TOP like in the above image, they will still see an empty pipe after relogging or unloading chunks, etc.
But connecting it to a tank will magically make the missing fluid reappear when the tank is filled on the server and resyncs with the client.

This is still better than what happens now, which is the fluid disappearing into the void when restarting single player or the server.

@warjort
Copy link
Contributor

warjort commented Jan 11, 2021

Better formatted patch?

diff --git a/src/main/java/gregtech/common/pipelike/fluidpipe/net/FluidPipeNet.java b/src/main/java/gregtech/common/pipelike/fluidpipe/net/FluidPipeNet.java
old mode 100644
new mode 100755
index db8cb1be..e70d8955
--- a/src/main/java/gregtech/common/pipelike/fluidpipe/net/FluidPipeNet.java
+++ b/src/main/java/gregtech/common/pipelike/fluidpipe/net/FluidPipeNet.java
@@ -154,4 +154,19 @@ public class FluidPipeNet extends MonolithicPipeNet<FluidPipeProperties> {
         return new FluidPipeProperties(maxTemperature, throughput, gasProof);
     }
 
+    @Override
+    public NBTTagCompound serializeNBT() {
+        final NBTTagCompound nbt = super.serializeNBT();
+        nbt.setTag("FluidNetTank", this.fluidNetTank.writeToNBT(new NBTTagCompound()));
+        return nbt;
+    }
+
+    @Override
+    public void deserializeNBT(final NBTTagCompound nbt) {
+        super.deserializeNBT(nbt);
+        final NBTTagCompound tankData = nbt.getCompoundTag("FluidNetTank");
+        if (tankData != null)
+            this.fluidNetTank.readFromNBT(tankData);
+    }
+
 }

@LAGIdiot
Copy link
Member

Accepted based on provided information and current code.

@warjort Seems like you already try fixing it. Why don't you create PR with provided code?

@warjort
Copy link
Contributor

warjort commented Jan 11, 2021

PR seems like a lot of work for a 10 line fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: accepted type: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants