diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt index 83e31826e..8a9319f1a 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt @@ -262,4 +262,7 @@ fun addDecorativeData(blockStateProvider: MatteryBlockStateProvider, itemModelPr val textureRailing = ResourceLocation(DataGen.MOD_ID, "block/decorative/industrial_glass_frame") DataGen.pane(glass, textureSide, textureRailing) } + + blockStateProvider.block(MBlocks.ENGINE) + itemModelProvider.block(MItems.ENGINE) } 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 9417abf28..bb82d114a 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java +++ b/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java @@ -569,4 +569,24 @@ public class BlockShapes { 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) ); + + public static final BlockShape ENGINE = new BlockShape( + new SimpleCuboid(0d, 0d, 0.875d, 1d, 1d, 1d), + new SimpleCuboid(0.0625d, 0.0625d, 0.625d, 0.9375d, 0.9375d, 0.875d), + new SimpleCuboid(0.25d, 0.25d, 0.4375d, 0.75d, 0.75d, 0.625d), + new SimpleCuboid(0.1875d, 0.1875d, 0.25d, 0.8125d, 0.8125d, 0.4375d), + new SimpleCuboid(0.125d, 0.125d, 0d, 0.875d, 0.875d, 0.25d), + new SimpleCuboid(0d, 0.875d, 0.5625d, 0.125d, 1d, 0.875d), + new SimpleCuboid(0.0625d, 0.875d, 0.25d, 0.125d, 0.9375d, 0.5625d), + new SimpleCuboid(0.0625d, 0.0625d, 0.25d, 0.125d, 0.125d, 0.5625d), + new SimpleCuboid(0.875d, 0.0625d, 0.25d, 0.9375d, 0.125d, 0.5625d), + new SimpleCuboid(0.875d, 0.875d, 0.25d, 0.9375d, 0.9375d, 0.5625d), + new SimpleCuboid(0.875d, 0.125d, 0.4375d, 0.9375d, 0.875d, 0.5625d), + new SimpleCuboid(0.0625d, 0.125d, 0.4375d, 0.125d, 0.875d, 0.5625d), + new SimpleCuboid(0.125d, 0.875d, 0.4375d, 0.875d, 0.9375d, 0.5625d), + new SimpleCuboid(0.125d, 0.0625d, 0.4375d, 0.875d, 0.125d, 0.5625d), + new SimpleCuboid(0.875d, 0.875d, 0.5625d, 1d, 1d, 0.875d), + new SimpleCuboid(0.875d, 0d, 0.5625d, 1d, 0.125d, 0.875d), + new SimpleCuboid(0d, 0d, 0.5625d, 0.125d, 0.125d, 0.875d) + ); } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt index 578fa6590..7797409ba 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt @@ -238,6 +238,29 @@ abstract class RotatableMatteryBlock @JvmOverloads constructor(properties: Prope } companion object { + /** + * Allows to instance [RotatableMatteryBlock] directly + */ + fun make(properties: Properties, hasFreeRotation: Boolean = false, faceToPlayer: Boolean = true): RotatableMatteryBlock { + if (hasFreeRotation) { // can't have one class for two cases - superclass (both in OTM and in Minecraft) are leaking "this" + return object : RotatableMatteryBlock(properties) { + override val hasFreeRotation get() = true // this is accessed from superclass constructor + + override fun faceToPlayer(context: BlockPlaceContext): Boolean { + return faceToPlayer + } + } + } else { + return object : RotatableMatteryBlock(properties) { + override val hasFreeRotation get() = false // this is accessed from superclass constructor + + override fun faceToPlayer(context: BlockPlaceContext): Boolean { + return faceToPlayer + } + } + } + } + val FACING: EnumProperty = EnumProperty.create( "facing", Direction::class.java, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt new file mode 100644 index 000000000..d7a569582 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt @@ -0,0 +1,30 @@ +package ru.dbotthepony.mc.otm.block.decorative + +import net.minecraft.core.BlockPos +import net.minecraft.world.item.DyeColor +import net.minecraft.world.level.BlockGetter +import net.minecraft.world.level.block.state.BlockState +import net.minecraft.world.level.material.Material +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.core.get +import ru.dbotthepony.mc.otm.shapes.BlockShapes + +class EngineBlock : RotatableMatteryBlock(Properties.of(Material.METAL, DyeColor.ORANGE).explosionResistance(14f).destroyTime(2.5f).requiresCorrectToolForDrops()) { + override val hasFreeRotation: Boolean + get() = true + + private val shapes = getShapeForEachState { + BlockShapes.ENGINE.rotateInv(it[FACING_FULL]).computeShape() + } + + override fun getShape( + p_60555_: BlockState, + p_60556_: BlockGetter, + p_60557_: BlockPos, + p_60558_: CollisionContext + ): VoxelShape { + return shapes[p_60555_]!! + } +} 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 7cf8c879e..60f27f23d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt @@ -42,8 +42,10 @@ import ru.dbotthepony.mc.otm.block.LaboratoryLampLight import ru.dbotthepony.mc.otm.block.MatterCableBlock import ru.dbotthepony.mc.otm.block.PhantomAttractorBlock import ru.dbotthepony.mc.otm.block.PlatePressBlock +import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.StorageCableBlock import ru.dbotthepony.mc.otm.block.TritaniumPressurePlate +import ru.dbotthepony.mc.otm.block.decorative.EngineBlock import ru.dbotthepony.mc.otm.block.matter.MatterBottlerBlock import ru.dbotthepony.mc.otm.block.matter.MatterCapacitorBankBlock import ru.dbotthepony.mc.otm.block.matter.MatterDecomposerBlock @@ -132,7 +134,7 @@ object MBlocks { val LABORATORY_LAMP_LIGHT: Block by registry.register(MNames.LABORATORY_LAMP_LIGHT) { LaboratoryLampLight() } val DANGER_STRIPE_BLOCK: Block by registry.register(MNames.DANGER_STRIPE_BLOCK) { Block(BlockBehaviour.Properties.of(Material.METAL, DyeColor.GRAY).explosionResistance(6f).destroyTime(1.5f).requiresCorrectToolForDrops()) } val METAL_BEAM: Block by registry.register(MNames.METAL_BEAM) { Block(BlockBehaviour.Properties.of(Material.METAL, DyeColor.GRAY).explosionResistance(14f).destroyTime(2.5f).requiresCorrectToolForDrops()) } - val ENGINE: Block by registry.register(MNames.ENGINE) { Block(BlockBehaviour.Properties.of(Material.METAL, DyeColor.ORANGE).explosionResistance(14f).destroyTime(2.5f).requiresCorrectToolForDrops()) } + val ENGINE: Block by registry.register(MNames.ENGINE) { EngineBlock() } val TRITANIUM_DOOR = registry.allColored(MNames.TRITANIUM_DOOR) { color, _ -> object : DoorBlock(Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE).explosionResistance(80f).noOcclusion().destroyTime(3f).requiresCorrectToolForDrops(), SoundEvents.IRON_DOOR_CLOSE, SoundEvents.IRON_DOOR_OPEN) {