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)
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;