mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-11 04:22:00 +01:00
fix fluid tank voxel shape gap
This commit is contained in:
parent
7b64f06d79
commit
80e680eb9c
2 changed files with 110 additions and 97 deletions
|
@ -3,6 +3,7 @@ package com.simibubi.create.content.contraptions.fluids;
|
||||||
import com.simibubi.create.AllBlocks;
|
import com.simibubi.create.AllBlocks;
|
||||||
import com.simibubi.create.AllShapes;
|
import com.simibubi.create.AllShapes;
|
||||||
import com.simibubi.create.AllTileEntities;
|
import com.simibubi.create.AllTileEntities;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.item.BlockItemUseContext;
|
import net.minecraft.item.BlockItemUseContext;
|
||||||
|
@ -14,6 +15,7 @@ import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||||
import net.minecraft.util.math.shapes.VoxelShape;
|
import net.minecraft.util.math.shapes.VoxelShape;
|
||||||
|
import net.minecraft.util.math.shapes.VoxelShapes;
|
||||||
import net.minecraft.world.IBlockReader;
|
import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraft.world.ILightReader;
|
import net.minecraft.world.ILightReader;
|
||||||
import net.minecraft.world.IWorld;
|
import net.minecraft.world.IWorld;
|
||||||
|
@ -26,6 +28,7 @@ public class FluidTankBlock extends Block {
|
||||||
public static final BooleanProperty TOP = BooleanProperty.create("top");
|
public static final BooleanProperty TOP = BooleanProperty.create("top");
|
||||||
public static final BooleanProperty BOTTOM = BooleanProperty.create("bottom");
|
public static final BooleanProperty BOTTOM = BooleanProperty.create("bottom");
|
||||||
|
|
||||||
|
|
||||||
public FluidTankBlock(Properties p_i48440_1_) {
|
public FluidTankBlock(Properties p_i48440_1_) {
|
||||||
super(p_i48440_1_);
|
super(p_i48440_1_);
|
||||||
setDefaultState(getDefaultState().with(TOP, true)
|
setDefaultState(getDefaultState().with(TOP, true)
|
||||||
|
@ -86,13 +89,23 @@ public class FluidTankBlock extends Block {
|
||||||
return world.getBlockState(pos.offset(direction)).getBlock() instanceof FluidTankBlock;
|
return world.getBlockState(pos.offset(direction)).getBlock() instanceof FluidTankBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AxisAlignedBB getTankBodyShape(IBlockReader world, BlockPos pos) {
|
public AxisAlignedBB getTankShape(IBlockReader world, BlockPos pos) {
|
||||||
return new AxisAlignedBB((isTankToDirection(world, pos, Direction.WEST) ? 0 : 2) / 16f,
|
return new AxisAlignedBB((isTankToDirection(world, pos, Direction.WEST) ? 0 : 2) / 16f,
|
||||||
(isTankToDirection(world, pos, Direction.DOWN) ? 0 : 4) / 16f,
|
(isTankToDirection(world, pos, Direction.DOWN) ? 0 : 4) / 16f,
|
||||||
(isTankToDirection(world, pos, Direction.NORTH) ? 0 : 2) / 16f,
|
(isTankToDirection(world, pos, Direction.NORTH) ? 0 : 2) / 16f,
|
||||||
(isTankToDirection(world, pos, Direction.EAST) ? 16 : 14) / 16f,
|
(isTankToDirection(world, pos, Direction.EAST) ? 16 : 14) / 16f,
|
||||||
(isTankToDirection(world, pos, Direction.UP) ? 16 : 12) / 16f,
|
(isTankToDirection(world, pos, Direction.UP) ? 16 : 12) / 16f,
|
||||||
(isTankToDirection(world, pos, Direction.SOUTH) ? 16 : 14) / 16f);
|
(isTankToDirection(world, pos, Direction.SOUTH) ? 16 : 14) / 16f);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public AxisAlignedBB getBodyShape(IBlockReader world, BlockPos pos) {
|
||||||
|
return new AxisAlignedBB((isTankToDirection(world, pos, Direction.WEST) ? 0 : 1) / 16f,
|
||||||
|
0.25f,
|
||||||
|
(isTankToDirection(world, pos, Direction.NORTH) ? 0 : 1) / 16f,
|
||||||
|
(isTankToDirection(world, pos, Direction.EAST) ? 16 : 15) / 16f,
|
||||||
|
0.75f,
|
||||||
|
(isTankToDirection(world, pos, Direction.SOUTH) ? 16 : 15) / 16f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -100,8 +113,8 @@ public class FluidTankBlock extends Block {
|
||||||
ISelectionContext p_220053_4_) {
|
ISelectionContext p_220053_4_) {
|
||||||
boolean top = state.get(TOP);
|
boolean top = state.get(TOP);
|
||||||
boolean bottom = state.get(BOTTOM);
|
boolean bottom = state.get(BOTTOM);
|
||||||
return top ? bottom ? AllShapes.TANK_TOP_BOTTOM : AllShapes.TANK_TOP
|
return VoxelShapes.or(top ? bottom ? AllShapes.TANK_TOP_BOTTOM : AllShapes.TANK_TOP
|
||||||
: bottom ? AllShapes.TANK_BOTTOM : AllShapes.TANK;
|
: bottom ? AllShapes.TANK_BOTTOM : AllShapes.TANK, VoxelShapes.create(getBodyShape(world, pos)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -175,7 +175,7 @@ public class FluidTankRenderer extends SafeTileEntityRenderer<FluidTankTileEntit
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<FluidTankRenderInfo> getTanksToRender(FluidTankTileEntity te) {
|
private List<FluidTankRenderInfo> getTanksToRender(FluidTankTileEntity te) {
|
||||||
return Collections.singletonList(new FluidTankRenderInfo(te, ((FluidTankBlock) te.getBlockState().getBlock()).getTankBodyShape(te.getWorld(), te.getPos())));
|
return Collections.singletonList(new FluidTankRenderInfo(te, ((FluidTankBlock) te.getBlockState().getBlock()).getTankShape(te.getWorld(), te.getPos())));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class FluidTankRenderInfo {
|
private static class FluidTankRenderInfo {
|
||||||
|
|
Loading…
Reference in a new issue