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 f65311c6b..9417abf28 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java +++ b/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java @@ -541,4 +541,32 @@ public class BlockShapes { new SimpleCuboid(0.875d, 1.25d, 0.3125d, 1d, 2d, 0.6875d), new SimpleCuboid(0d, 1.25d, 0.3125d, 0.125d, 2d, 0.6875d) ); + + public static final BlockShape ENERGY_SERVO = new BlockShape( + new SimpleCuboid(0d, 0d, 0d, 1d, 0.625d, 0.6875d), + new SimpleCuboid(0.25d, 0.625d, 0d, 0.75d, 1d, 0.4375d), + new SimpleCuboid(0d, 0.625d, 0.4375d, 1d, 1d, 1d), + new SimpleCuboid(0.3125d, 0.125d, 0.6875d, 0.6875d, 0.625d, 1d), + new SimpleCuboid(0d, 0d, 0.6875d, 1d, 0.125d, 1d), + new SimpleCuboid(0.0625d, 0.125d, 0.6875d, 0.3125d, 0.1875d, 0.9375d), + new SimpleCuboid(0.0625d, 0.25d, 0.6875d, 0.3125d, 0.3125d, 0.9375d), + new SimpleCuboid(0.0625d, 0.375d, 0.6875d, 0.3125d, 0.4375d, 0.9375d), + new SimpleCuboid(0.0625d, 0.5d, 0.6875d, 0.3125d, 0.5625d, 0.9375d), + new SimpleCuboid(0.6875d, 0.125d, 0.6875d, 0.9375d, 0.1875d, 0.9375d), + new SimpleCuboid(0.6875d, 0.25d, 0.6875d, 0.9375d, 0.3125d, 0.9375d), + new SimpleCuboid(0.6875d, 0.375d, 0.6875d, 0.9375d, 0.4375d, 0.9375d), + new SimpleCuboid(0.6875d, 0.5d, 0.6875d, 0.9375d, 0.5625d, 0.9375d), + new SimpleCuboid(0.125d, 0.125d, 0.75d, 0.25d, 0.625d, 0.875d), + new SimpleCuboid(0.75d, 0.125d, 0.75d, 0.875d, 0.625d, 0.875d), + new SimpleCuboid(0d, 0.625d, 0d, 0.0625d, 1d, 0.0625d), + new SimpleCuboid(0.9375d, 0.625d, 0d, 1d, 1d, 0.0625d), + new SimpleCuboid(0.95d, 0.6875d, 0.0625d, 0.98125d, 0.75d, 0.4375d), + new SimpleCuboid(0.95d, 0.875d, 0.0625d, 0.98125d, 0.9375d, 0.4375d), + new SimpleCuboid(0.01875d, 0.875d, 0.0625d, 0.05d, 0.9375d, 0.4375d), + new SimpleCuboid(0.01875d, 0.6875d, 0.0625d, 0.05d, 0.75d, 0.4375d), + new SimpleCuboid(0.09375d, 0.625d, 0.0625d, 0.28125d, 0.875d, 0.4375d), + new SimpleCuboid(0.71875d, 0.625d, 0.0625d, 0.90625d, 0.875d, 0.4375d), + new SimpleCuboid(0.03125d, 0.125d, 0.65625d, 0.34375d, 0.625d, 0.96875d), + new SimpleCuboid(0.65625d, 0.125d, 0.65625d, 0.96875d, 0.625d, 0.96875d) + ); } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/EnergyServoBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/EnergyServoBlock.kt index 5e66f9092..d81a6e62c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/EnergyServoBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/EnergyServoBlock.kt @@ -1,6 +1,8 @@ package ru.dbotthepony.mc.otm.block import net.minecraft.core.BlockPos +import net.minecraft.core.Direction +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 @@ -9,8 +11,11 @@ import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.material.Material import net.minecraft.world.level.material.MaterialColor +import net.minecraft.world.phys.shapes.CollisionContext +import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.entity.EnergyServoBlockEntity import ru.dbotthepony.mc.otm.registry.MBlockEntities +import ru.dbotthepony.mc.otm.shapes.BlockShapes class EnergyServoBlock : RotatableMatteryBlock(Properties.of(Material.METAL, MaterialColor.COLOR_BLUE).explosionResistance(12f).destroyTime(2f)), EntityBlock { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { @@ -28,4 +33,30 @@ class EnergyServoBlock : RotatableMatteryBlock(Properties.of(Material.METAL, Mat return null } + + override fun getShape( + p_60555_: BlockState, + p_60556_: BlockGetter, + p_60557_: BlockPos, + p_60558_: CollisionContext + ): VoxelShape { + return SHAPES[p_60555_.getValue(FACING).ordinal] + } + + companion object { + private val SHAPES: Array + + init { + val def = BlockShapes.ENERGY_SERVO.computeShape() + + SHAPES = arrayOf( + def, + def, + def, + BlockShapes.ENERGY_SERVO.rotate(Direction.NORTH).computeShape(), + BlockShapes.ENERGY_SERVO.rotate(Direction.WEST).computeShape(), + BlockShapes.ENERGY_SERVO.rotate(Direction.EAST).computeShape() + ) + } + } }