Merge pull request #2011 from MellowArpeggiation/master

fix switching barrel types not updating fluid net
This commit is contained in:
HbmMods 2025-03-24 10:34:27 +01:00 committed by GitHub
commit 659bd662bf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 8 deletions

View File

@ -48,6 +48,7 @@ import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityBarrel extends TileEntityMachineBase implements SimpleComponent, IFluidStandardTransceiverMK2, IPersistentNBT, IGUIProvider, CompatHandler.OCComponent, IFluidCopiable {
protected FluidNode node;
protected FluidType lastType;
public FluidTank tank;
public short mode = 0;
@ -102,18 +103,21 @@ public class TileEntityBarrel extends TileEntityMachineBase implements SimpleCom
// In buffer mode, acts like a pipe block, providing fluid to its own node
// otherwise, it is a regular providing/receiving machine, blocking further propagation
if(mode == 1) {
if(this.node == null || this.node.expired) {
if(this.node == null || this.node.expired || tank.getTankType() != lastType) {
this.node = (FluidNode) UniNodespace.getNode(worldObj, xCoord, yCoord, zCoord, tank.getTankType().getNetworkProvider());
if(this.node == null || this.node.expired) {
if(this.node == null || this.node.expired || tank.getTankType() != lastType) {
this.node = this.createNode(tank.getTankType());
UniNodespace.createNode(worldObj, this.node);
lastType = tank.getTankType();
}
}
this.tryProvide(tank, worldObj, xCoord, yCoord, zCoord, ForgeDirection.UNKNOWN);
if(node != null && node.hasValidNet()) node.net.addReceiver(this);
if(node != null && node.hasValidNet()) {
node.net.addProvider(this);
node.net.addReceiver(this);
}
} else {
if(this.node != null) {
UniNodespace.destroyNode(worldObj, xCoord, yCoord, zCoord, tank.getTankType().getNetworkProvider());

View File

@ -57,6 +57,7 @@ import java.util.Random;
public class TileEntityMachineFluidTank extends TileEntityMachineBase implements SimpleComponent, OCComponent, IFluidStandardTransceiverMK2, IPersistentNBT, IOverpressurable, IGUIProvider, IRepairable, IFluidCopiable {
protected FluidNode node;
protected FluidType lastType;
public FluidTank tank;
public short mode = 0;
@ -116,18 +117,21 @@ public class TileEntityMachineFluidTank extends TileEntityMachineBase implements
// In buffer mode, acts like a pipe block, providing fluid to its own node
// otherwise, it is a regular providing/receiving machine, blocking further propagation
if(mode == 1) {
if(this.node == null || this.node.expired) {
if(this.node == null || this.node.expired || tank.getTankType() != lastType) {
this.node = (FluidNode) UniNodespace.getNode(worldObj, xCoord, yCoord, zCoord, tank.getTankType().getNetworkProvider());
if(this.node == null || this.node.expired) {
if(this.node == null || this.node.expired || tank.getTankType() != lastType) {
this.node = this.createNode(tank.getTankType());
UniNodespace.createNode(worldObj, this.node);
lastType = tank.getTankType();
}
}
this.tryProvide(tank, worldObj, xCoord, yCoord, zCoord, ForgeDirection.UNKNOWN);
if(node != null && node.hasValidNet()) node.net.addReceiver(this);
if(node != null && node.hasValidNet()) {
node.net.addProvider(this);
node.net.addReceiver(this);
}
} else {
if(this.node != null) {
UniNodespace.destroyNode(worldObj, xCoord, yCoord, zCoord, tank.getTankType().getNetworkProvider());