diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidTankRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidTankRenderer.java index 61ae12e2f..452de1254 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidTankRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidTankRenderer.java @@ -16,8 +16,8 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraftforge.fluids.IFluidTank; -import java.util.Collection; import java.util.Collections; +import java.util.List; public class FluidTankRenderer extends SafeTileEntityRenderer { @@ -37,31 +37,29 @@ public class FluidTankRenderer extends SafeTileEntityRenderer getTanksToRender(FluidTankTileEntity te) { - FluidTankTileEntity upTE = te.getOtherFluidTankTileEntity(Direction.UP); - FluidTankTileEntity downTE = te.getOtherFluidTankTileEntity(Direction.DOWN); - FluidTankTileEntity eastTE = te.getOtherFluidTankTileEntity(Direction.EAST); - FluidTankTileEntity westTE = te.getOtherFluidTankTileEntity(Direction.WEST); - FluidTankTileEntity northTE = te.getOtherFluidTankTileEntity(Direction.NORTH); - FluidTankTileEntity southTE = te.getOtherFluidTankTileEntity(Direction.SOUTH); - - boolean up = upTE != null && ( upTE.getTank().getFluidAmount() == 0 || te.getTank().getFluid().getRawFluid() != upTE.getTank().getFluid().getRawFluid()); - boolean down = downTE != null && (downTE.getTank().getFluidAmount() < downTE.getTank().getCapacity() || te.getTank().getFluid().getRawFluid() != downTE.getTank().getFluid().getRawFluid()); - boolean east = eastTE == null || te.getTank().getFluid().getRawFluid() != eastTE.getTank().getFluid().getRawFluid(); - boolean west = westTE == null || te.getTank().getFluid().getRawFluid() != westTE.getTank().getFluid().getRawFluid(); - boolean north = northTE == null || te.getTank().getFluid().getRawFluid() != northTE.getTank().getFluid().getRawFluid(); - boolean south = southTE == null || te.getTank().getFluid().getRawFluid() != southTE.getTank().getFluid().getRawFluid(); - - return Collections.singletonList(new FluidTankRenderInfo(te.getTank(), up, down, east, west, north, south, ((FluidTankBlock) te.getBlockState().getBlock()).getTankBodyShape(te.getWorld(), te.getPos()))); + private List getTanksToRender(FluidTankTileEntity te) { + return Collections.singletonList(new FluidTankRenderInfo(te, ((FluidTankBlock) te.getBlockState().getBlock()).getTankBodyShape(te.getWorld(), te.getPos()))); } - private static class FluidTankRenderInfo extends TankRenderInfo { - private final boolean up; - private final boolean down; - private final boolean east; - private final boolean west; - private final boolean north; - private final boolean south; + private static class FluidTankRenderInfo { + private final IFluidTank tank; + private final AxisAlignedBB bounds; + private final FluidTankTileEntity te; - FluidTankRenderInfo(IFluidTank tank, boolean up, boolean down, boolean east, boolean west, boolean north, boolean south, AxisAlignedBB bounds) { - super(tank, bounds); - this.up = up; - this.down = down; - this.east = east; - this.west = west; - this.north = north; - this.south = south; + FluidTankRenderInfo(FluidTankTileEntity te, AxisAlignedBB bounds) { + this.te = te; + this.bounds = bounds; + this.tank = te.getTank(); } - @Override public boolean shouldRender(Direction face) { + FluidTankTileEntity offsetTE = te.getOtherFluidTankTileEntity(face); switch (face) { case UP: - return up - || getTank().getFluid().getAmount() < getTank().getCapacity() + return (offsetTE != null && (offsetTE.getTank().getFluidAmount() == 0 || te.getTank().getFluid().getRawFluid() != offsetTE.getTank().getFluid().getRawFluid())) + || getTank().getFluidAmount() < getTank().getCapacity() && !getTank().getFluid().getFluid().getAttributes().isLighterThanAir(); case DOWN: - return down - || getTank().getFluid().getAmount() < getTank().getCapacity() + return (offsetTE != null && (offsetTE.getTank().getFluidAmount() < offsetTE.getTank().getCapacity() || te.getTank().getFluid().getRawFluid() != offsetTE.getTank().getFluid().getRawFluid())) + || getTank().getFluidAmount() < getTank().getCapacity() && getTank().getFluid().getFluid().getAttributes().isLighterThanAir(); - case EAST: - return east; - case WEST: - return west; - case NORTH: - return north; - case SOUTH: - return south; default: - return true; + return offsetTE == null || te.getTank().getFluid().getRawFluid() != offsetTE.getTank().getFluid().getRawFluid(); } } + + public IFluidTank getTank() { + return tank; + } + + public AxisAlignedBB getBounds() { + return bounds; + } } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/TankRenderInfo.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/TankRenderInfo.java deleted file mode 100644 index a3284acea..000000000 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/TankRenderInfo.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.simibubi.create.content.contraptions.fluids; - -import net.minecraft.util.Direction; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.IFluidTank; -import net.minecraftforge.fluids.capability.templates.FluidTank; - -import java.util.BitSet; - -public class TankRenderInfo { - private final IFluidTank tank; - private final AxisAlignedBB bounds; - private final BitSet faces = new BitSet(6); - - public TankRenderInfo(FluidStack stack, int capacity, AxisAlignedBB bounds, Direction... renderFaces) { - FluidTank tank = new FluidTank(capacity); - tank.setFluid(stack); - this.tank = tank; - this.bounds = bounds; - if (renderFaces.length == 0) { - faces.set(0, 6, true); - } else { - for (Direction face : renderFaces) { - faces.set(face.getIndex(), true); - } - } - } - - public TankRenderInfo(IFluidTank tank, AxisAlignedBB bounds, Direction... renderFaces) { - this(tank.getFluid(), tank.getCapacity(), bounds, renderFaces); - } - - public TankRenderInfo without(Direction face) { - faces.clear(face.getIndex()); - return this; - } - - public boolean shouldRender(Direction face) { - return faces.get(face.getIndex()); - } - - public IFluidTank getTank() { - return tank; - } - - public AxisAlignedBB getBounds() { - return bounds; - } - - public BitSet getFaces() { - return faces; - } -} \ No newline at end of file