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 b1f97bd01..d87f1ef00 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java +++ b/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java @@ -633,4 +633,20 @@ public class BlockShapes { new SimpleCuboid(0.0625d, 0.3125d, 0.875d, 0.9375d, 0.625d, 0.9375d), new SimpleCuboid(0.0625d, 0.3125d, 0.0625d, 0.5625d, 0.9375d, 0.5625d) ); + + public static final BlockShape MATTER_RECONSTRUCTOR = new BlockShape( + new SimpleCuboid(0d, 0.25d, 0d, 1d, 0.5d, 1d), + new SimpleCuboid(0d, 0d, 0d, 1d, 0.25d, 0.6875d), + new SimpleCuboid(0.8125d, 0.5d, 0d, 1d, 1d, 1d), + new SimpleCuboid(0d, 0.5d, 0d, 0.1875d, 1d, 1d), + new SimpleCuboid(0.1875d, 0.5d, 0.0625d, 0.8125d, 0.9375d, 0.9375d), + new SimpleCuboid(-0.0625d, 0.5d, 0.0625d, 0d, 0.9375d, 0.9375d), + new SimpleCuboid(1d, 0.5d, 0.0625d, 1.0625d, 0.9375d, 0.9375d), + new SimpleCuboid(0.25d, 0.5d, 0.25d, 0.75d, 0.5625d, 0.75d), + new SimpleCuboid(0.875d, 0d, 0.6875d, 0.9375d, 0.25d, 0.9375d), + new SimpleCuboid(0.0625d, 0d, 0.6875d, 0.1875d, 0.25d, 0.9375d), + new SimpleCuboid(0.1875d, 0d, 0.6875d, 0.875d, 0.25d, 0.9375d), + 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) + ); } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/ItemRepairerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReconstructorBlock.kt similarity index 58% rename from src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/ItemRepairerBlock.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReconstructorBlock.kt index d3fc0928b..d46b0e414 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/ItemRepairerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReconstructorBlock.kt @@ -1,16 +1,22 @@ package ru.dbotthepony.mc.otm.block.matter import net.minecraft.core.BlockPos +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 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.shapes.CollisionContext +import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.matter.MatterReconstructorBlockEntity +import ru.dbotthepony.mc.otm.block.getShapeForEachState +import ru.dbotthepony.mc.otm.core.get +import ru.dbotthepony.mc.otm.shapes.BlockShapes -class ItemRepairerBlock : RotatableMatteryBlock(), EntityBlock { +class MatterReconstructorBlock : RotatableMatteryBlock(), EntityBlock { override fun newBlockEntity(pPos: BlockPos, pState: BlockState): BlockEntity { return MatterReconstructorBlockEntity(pPos, pState) } @@ -21,4 +27,16 @@ class ItemRepairerBlock : RotatableMatteryBlock(), EntityBlock { return BlockEntityTicker { _, _, _, pBlockEntity -> if (pBlockEntity is MatterReconstructorBlockEntity) pBlockEntity.tick() } } + + private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.MATTER_RECONSTRUCTOR.rotateFromNorth(it[rotationProperty]).computeShape() } + + @Suppress("override_deprecation") + 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/registry/MBlocks.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt index afe8b208c..90de2a4e3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt @@ -47,7 +47,7 @@ import ru.dbotthepony.mc.otm.block.tech.PlatePressBlock import ru.dbotthepony.mc.otm.block.StorageCableBlock import ru.dbotthepony.mc.otm.block.decorative.EngineBlock import ru.dbotthepony.mc.otm.block.decorative.HoloSignBlock -import ru.dbotthepony.mc.otm.block.matter.ItemRepairerBlock +import ru.dbotthepony.mc.otm.block.matter.MatterReconstructorBlock import ru.dbotthepony.mc.otm.block.matter.MatterBottlerBlock import ru.dbotthepony.mc.otm.block.matter.MatterCapacitorBankBlock import ru.dbotthepony.mc.otm.block.matter.MatterDecomposerBlock @@ -92,7 +92,7 @@ object MBlocks { val ENERGY_SERVO: Block by registry.register(MNames.ENERGY_SERVO) { EnergyServoBlock() } val COBBLESTONE_GENERATOR: Block by registry.register(MNames.COBBLESTONE_GENERATOR) { CobblerBlock() } val ESSENCE_STORAGE: EssenceStorageBlock by registry.register(MNames.ESSENCE_STORAGE) { EssenceStorageBlock() } - val MATTER_RECONSTRUCTOR: ItemRepairerBlock by registry.register(MNames.MATTER_RECONSTRUCTOR) { ItemRepairerBlock() } + val MATTER_RECONSTRUCTOR: MatterReconstructorBlock by registry.register(MNames.MATTER_RECONSTRUCTOR) { MatterReconstructorBlock() } val STORAGE_BUS: Block by registry.register(MNames.STORAGE_BUS) { StorageBusBlock() } val STORAGE_IMPORTER: Block by registry.register(MNames.STORAGE_IMPORTER) { StorageImporterBlock() }