Fix fluid tank render boxes

- Update render box on client TE initialization and update packet
- Resolves #1669
This commit is contained in:
PepperBell 2021-06-17 14:43:40 -07:00
parent c1d88bbad4
commit e55ae22d7d
4 changed files with 18 additions and 14 deletions

View file

@ -199,7 +199,7 @@ public class FluidTankConnectivityHandler {
if (simulate)
return amount;
boolean opaque = false;
for (int yOffset = 0; yOffset < height; yOffset++) {
@ -234,7 +234,7 @@ public class FluidTankConnectivityHandler {
}
}
}
te.setWindows(!opaque);
return amount;
@ -281,7 +281,7 @@ public class FluidTankConnectivityHandler {
if (!toDistribute.isEmpty() && tankAt != te) {
FluidStack copy = toDistribute.copy();
FluidTank tankInventory = tankAt.tankInventory;
if (tankInventory.isEmpty() && tankInventory instanceof CreativeSmartFluidTank)
if (tankInventory.isEmpty() && tankInventory instanceof CreativeSmartFluidTank)
((CreativeSmartFluidTank) tankInventory).setContainedFluid(toDistribute);
else {
int split = Math.min(maxCapacity, toDistribute.getAmount());

View file

@ -25,7 +25,7 @@ public class FluidTankRenderer extends SafeTileEntityRenderer<FluidTankTileEntit
if (!te.window)
return;
InterpolatedChasingValue fluidLevel = te.fluidLevel;
InterpolatedChasingValue fluidLevel = te.getFluidLevel();
if (fluidLevel == null)
return;

View file

@ -56,7 +56,8 @@ public class FluidTankTileEntity extends SmartTileEntity implements IHaveGoggleI
protected boolean queuedSync;
// For rendering purposes only
InterpolatedChasingValue fluidLevel;
private InterpolatedChasingValue fluidLevel;
private AxisAlignedBB renderBoundingBox;
public FluidTankTileEntity(TileEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
@ -114,6 +115,8 @@ public class FluidTankTileEntity extends SmartTileEntity implements IHaveGoggleI
public void initialize() {
super.initialize();
sendData();
if (world.isRemote)
updateRenderBoundingBox();
}
private void onPositionChanged() {
@ -286,18 +289,20 @@ public class FluidTankTileEntity extends SmartTileEntity implements IHaveGoggleI
return isController() ? pos : controller;
}
private AxisAlignedBB cachedBoundingBox;
public void updateRenderBoundingBox() {
if (isController())
renderBoundingBox = super.getRenderBoundingBox().expand(width - 1, height - 1, width - 1);
else
renderBoundingBox = super.getRenderBoundingBox();
}
@Override
@OnlyIn(Dist.CLIENT)
public AxisAlignedBB getRenderBoundingBox() {
if (cachedBoundingBox == null) {
if (isController())
cachedBoundingBox = super.getRenderBoundingBox().expand(width - 1, height - 1, width - 1);
else
cachedBoundingBox = super.getRenderBoundingBox();
if (renderBoundingBox == null) {
renderBoundingBox = super.getRenderBoundingBox();
}
return cachedBoundingBox;
return renderBoundingBox;
}
@Override
@ -367,6 +372,7 @@ public class FluidTankTileEntity extends SmartTileEntity implements IHaveGoggleI
world.notifyBlockUpdate(getPos(), getBlockState(), getBlockState(), 16);
if (isController())
tankInventory.setCapacity(getCapacityMultiplier() * getTotalTankSize());
updateRenderBoundingBox();
}
if (isController()) {
float fillState = getFillState();

View file

@ -8,13 +8,11 @@ import java.util.function.Consumer;
import com.simibubi.create.content.schematics.ItemRequirement;
import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType;
import com.simibubi.create.foundation.utility.IPartialSafeNBT;
import net.minecraft.block.BlockState;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;