diff --git a/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java b/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java index d87f1ef00..87609a632 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java +++ b/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java @@ -649,4 +649,12 @@ public class BlockShapes { new SimpleCuboid(0.36875d, 0.65625d, 0.5875d, 0.44375d, 0.78125d, 0.9d), new SimpleCuboid(0.4375d, 0.5d, 0.1875d, 0.5625d, 0.625d, 0.3125d) ); + + public static final BlockShape FLUID_TANK = new BlockShape( + new SimpleCuboid(0d, 0d, 0d, 1d, 0.125d, 1d), + new SimpleCuboid(0d, 0.875d, 0d, 1d, 1d, 1d), + new SimpleCuboid(0.03125d, 0.125d, 0.03125d, 0.96875d, 0.1875d, 0.96875d), + new SimpleCuboid(0.03125d, 0.8125d, 0.03125d, 0.96875d, 0.875d, 0.96875d), + new SimpleCuboid(0d, 0.1875d, 0d, 1d, 0.8125d, 1d) + ); } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/FluidTankBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/FluidTankBlock.kt index 113cb43ae..37e5483ac 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/FluidTankBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/FluidTankBlock.kt @@ -4,6 +4,7 @@ import net.minecraft.core.BlockPos import net.minecraft.world.InteractionHand import net.minecraft.world.InteractionResult import net.minecraft.world.entity.player.Player +import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.Level import net.minecraft.world.level.block.EntityBlock import net.minecraft.world.level.block.entity.BlockEntity @@ -11,9 +12,14 @@ import net.minecraft.world.level.block.entity.BlockEntityTicker import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.phys.BlockHitResult +import net.minecraft.world.phys.shapes.CollisionContext +import net.minecraft.world.phys.shapes.VoxelShape import net.minecraftforge.fluids.FluidUtil import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.decorative.FluidTankBlockEntity +import ru.dbotthepony.mc.otm.block.getShapeForEachState +import ru.dbotthepony.mc.otm.core.get +import ru.dbotthepony.mc.otm.shapes.BlockShapes class FluidTankBlock : RotatableMatteryBlock(), EntityBlock { override fun newBlockEntity(pPos: BlockPos, pState: BlockState): BlockEntity { @@ -35,4 +41,16 @@ class FluidTankBlock : RotatableMatteryBlock(), EntityBlock { return super.use(blockState, level, blockPos, ply, hand, blockHitResult) } + + private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.FLUID_TANK.rotateFromNorth(it[rotationProperty]).computeShape() } + + @Suppress("override_deprecation") + override fun getShape( + state: BlockState, + blockGetter: BlockGetter, + pos: BlockPos, + context: CollisionContext + ): VoxelShape { + return shapes[state]!! + } }