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

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

View file

@ -56,7 +56,8 @@ public class FluidTankTileEntity extends SmartTileEntity implements IHaveGoggleI
protected boolean queuedSync; protected boolean queuedSync;
// For rendering purposes only // For rendering purposes only
InterpolatedChasingValue fluidLevel; private InterpolatedChasingValue fluidLevel;
private AxisAlignedBB renderBoundingBox;
public FluidTankTileEntity(TileEntityType<?> tileEntityTypeIn) { public FluidTankTileEntity(TileEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn); super(tileEntityTypeIn);
@ -114,6 +115,8 @@ public class FluidTankTileEntity extends SmartTileEntity implements IHaveGoggleI
public void initialize() { public void initialize() {
super.initialize(); super.initialize();
sendData(); sendData();
if (world.isRemote)
updateRenderBoundingBox();
} }
private void onPositionChanged() { private void onPositionChanged() {
@ -286,18 +289,20 @@ public class FluidTankTileEntity extends SmartTileEntity implements IHaveGoggleI
return isController() ? pos : controller; 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 @Override
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public AxisAlignedBB getRenderBoundingBox() { public AxisAlignedBB getRenderBoundingBox() {
if (cachedBoundingBox == null) { if (renderBoundingBox == null) {
if (isController()) renderBoundingBox = super.getRenderBoundingBox();
cachedBoundingBox = super.getRenderBoundingBox().expand(width - 1, height - 1, width - 1);
else
cachedBoundingBox = super.getRenderBoundingBox();
} }
return cachedBoundingBox; return renderBoundingBox;
} }
@Override @Override
@ -367,6 +372,7 @@ public class FluidTankTileEntity extends SmartTileEntity implements IHaveGoggleI
world.notifyBlockUpdate(getPos(), getBlockState(), getBlockState(), 16); world.notifyBlockUpdate(getPos(), getBlockState(), getBlockState(), 16);
if (isController()) if (isController())
tankInventory.setCapacity(getCapacityMultiplier() * getTotalTankSize()); tankInventory.setCapacity(getCapacityMultiplier() * getTotalTankSize());
updateRenderBoundingBox();
} }
if (isController()) { if (isController()) {
float fillState = getFillState(); 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.content.schematics.ItemRequirement;
import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType; import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType;
import com.simibubi.create.foundation.utility.IPartialSafeNBT; import com.simibubi.create.foundation.utility.IPartialSafeNBT;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType; import net.minecraft.tileentity.TileEntityType;
import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.CapabilityFluidHandler;