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 1bc232038..f3fa11787 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java +++ b/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java @@ -804,4 +804,33 @@ public class BlockShapes { new SimpleCuboid(0.125d, 0.3125d, 0.25d, 0.875d, 0.9375d, 0.875d), new SimpleCuboid(0.1875d, 0.5d, 0.875d, 0.8125d, 0.875d, 0.9375d) ); + + public static final BlockShape INFINITE_WATER_SOURCE = new BlockShape( + new SimpleCuboid(0.625d, 0d, 0d, 1d, 1d, 0.5625d), + new SimpleCuboid(0d, 0.625d, 0d, 0.625d, 1d, 0.5625d), + new SimpleCuboid(0d, 0d, 0d, 0.625d, 0.375d, 0.5625d), + new SimpleCuboid(0d, 0.375d, 0.3125d, 0.625d, 0.625d, 0.5625d), + new SimpleCuboid(0.5625d, 0.0625d, 0.5625d, 0.9375d, 0.875d, 0.9375d), + new SimpleCuboid(0.0625d, 0.0625d, 0.5625d, 0.4375d, 0.875d, 0.9375d), + new SimpleCuboid(0.125d, 0.875d, 0.625d, 0.875d, 0.9375d, 0.875d), + new SimpleCuboid(0d, 0d, 0.5625d, 1d, 1d, 1d), + new SimpleCuboid(0d, 1d, 0.5625d, 1d, 0d, 1d), + new SimpleCuboid(0.0625d, 0.375d, 0.0625d, 0.625d, 0.625d, 0.3125d) + ); + + public static final BlockShape PAINTER = new BlockShape( + new SimpleCuboid(0d, 0.5d, 0d, 1d, 0.625d, 1d), + new SimpleCuboid(0d, 0d, 0d, 1d, 0.125d, 0.9375d), + new SimpleCuboid(0d, 0.125d, 0.3125d, 1d, 0.5d, 0.9375d), + new SimpleCuboid(0d, 0.625d, 0.5625d, 1d, 1d, 1d), + new SimpleCuboid(0.625d, 0.125d, 0.0625d, 0.75d, 0.5d, 0.3125d), + new SimpleCuboid(0.4375d, 0.125d, 0.0625d, 0.5625d, 0.5d, 0.3125d), + new SimpleCuboid(0.8125d, 0.125d, 0.0625d, 0.9375d, 0.5d, 0.3125d), + new SimpleCuboid(0.0625d, 0.125d, 0.0625d, 0.375d, 0.5d, 0.3125d), + new SimpleCuboid(0.0625d, 0.59375d, 0.0625d, 0.9375d, 0.65625d, 0.5d), + new SimpleCuboid(0.0625d, 0d, 0.9375d, 0.3125d, 0.5d, 1d), + new SimpleCuboid(0.6875d, 0d, 0.9375d, 0.9375d, 0.5d, 1d), + new SimpleCuboid(0d, 0.625d, 0d, 0d, 0.8125d, 0.5625d), + new SimpleCuboid(1d, 0.625d, 0d, 1d, 0.8125d, 0.5625d) + ); } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/InfiniteWaterSourceBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/InfiniteWaterSourceBlock.kt index 97e482b91..e36834fde 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/InfiniteWaterSourceBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/InfiniteWaterSourceBlock.kt @@ -6,6 +6,7 @@ import net.minecraft.world.InteractionResult import net.minecraft.world.ItemInteractionResult import net.minecraft.world.entity.player.Player import net.minecraft.world.item.ItemStack +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 @@ -15,9 +16,14 @@ import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.material.MapColor import net.minecraft.world.level.material.PushReaction import net.minecraft.world.phys.BlockHitResult +import net.minecraft.world.phys.shapes.CollisionContext +import net.minecraft.world.phys.shapes.VoxelShape import net.neoforged.neoforge.fluids.FluidUtil import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.decorative.InfiniteWaterSourceBlockEntity +import ru.dbotthepony.mc.otm.block.getShapeForEachState +import ru.dbotthepony.mc.otm.core.get +import ru.dbotthepony.mc.otm.shapes.BlockShapes class InfiniteWaterSourceBlock : RotatableMatteryBlock(Properties.of().destroyTime(1.5f).explosionResistance(10f).pushReaction(PushReaction.NORMAL).requiresCorrectToolForDrops().mapColor(MapColor.WATER)), EntityBlock { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { @@ -46,4 +52,15 @@ class InfiniteWaterSourceBlock : RotatableMatteryBlock(Properties.of().destroyTi return BlockEntityTicker { _, _, _, p_155256_ -> if (p_155256_ is InfiniteWaterSourceBlockEntity) p_155256_.tick() } } + + private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.INFINITE_WATER_SOURCE.rotateFromNorth(it[rotationProperty]).computeShape() } + + override fun getShape( + state: BlockState, + blockGetter: BlockGetter, + pos: BlockPos, + context: CollisionContext + ): VoxelShape { + return shapes[state]!! + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/PainterBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/PainterBlock.kt index a112f959d..5aa3710e0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/PainterBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/PainterBlock.kt @@ -6,6 +6,7 @@ import net.minecraft.world.InteractionResult import net.minecraft.world.ItemInteractionResult import net.minecraft.world.entity.player.Player import net.minecraft.world.item.ItemStack +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 @@ -13,9 +14,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.neoforged.neoforge.fluids.FluidUtil import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.decorative.PainterBlockEntity +import ru.dbotthepony.mc.otm.block.getShapeForEachState +import ru.dbotthepony.mc.otm.core.get +import ru.dbotthepony.mc.otm.shapes.BlockShapes class PainterBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { @@ -42,4 +48,15 @@ class PainterBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBl if (p_153212_.isClientSide) return null return BlockEntityTicker { p_155253_, p_155254_, p_155255_, p_155256_ -> if (p_155256_ is PainterBlockEntity) p_155256_.tick() } } + + private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.PAINTER.rotateFromNorth(it[rotationProperty]).computeShape() } + + override fun getShape( + state: BlockState, + blockGetter: BlockGetter, + pos: BlockPos, + context: CollisionContext + ): VoxelShape { + return shapes[state]!! + } }