From 43e02f8c7050aa00abdf3f53f446d129409bdbd3 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 15 May 2022 14:18:56 +0700 Subject: [PATCH] Storage power supplier block shape --- .../mc/otm/shapes/BlockShapes.java | 22 +++++++++++++ .../mc/otm/block/PlatePressBlock.kt | 1 - .../mc/otm/block/StoragePowerSupplierBlock.kt | 31 +++++++++++++++++++ 3 files changed, 53 insertions(+), 1 deletion(-) 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 29056fa29..8b95bccd0 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java +++ b/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java @@ -417,4 +417,26 @@ public class BlockShapes { new SimpleCuboid(0.125d, 0.875d, 0.75d, 0.875d, 0.9375d, 0.875d), new SimpleCuboid(0.125d, 0.0625d, 0.75d, 0.875d, 0.125d, 0.875d) ); + + public static final BlockShape STORAGE_POWER_SUPPLIER = new BlockShape( + new SimpleCuboid(0.5d, 0d, 0d, 1d, 0.1875d, 1d), + new SimpleCuboid(0.5d, 0.8125d, 0d, 1d, 1d, 1d), + new SimpleCuboid(0d, 0d, 0.375d, 0.5d, 0.875d, 0.9375d), + new SimpleCuboid(0.1875d, 0.5d, 0.25d, 0.3125d, 0.8125d, 0.375d), + new SimpleCuboid(0.125d, 0d, 0.1875d, 0.375d, 0.5d, 0.375d), + new SimpleCuboid(0.0625d, 0.875d, 0.46875d, 0.5d, 0.9375d, 0.59375d), + new SimpleCuboid(0.0625d, 0.875d, 0.71875d, 0.5d, 0.9375d, 0.84375d), + new SimpleCuboid(0.5625d, 0.1875d, 0.5625d, 0.9375d, 0.25d, 0.9375d), + new SimpleCuboid(0.5625d, 0.3125d, 0.5625d, 0.9375d, 0.375d, 0.9375d), + new SimpleCuboid(0.5625d, 0.4375d, 0.5625d, 0.9375d, 0.5d, 0.9375d), + new SimpleCuboid(0.5625d, 0.5625d, 0.5625d, 0.9375d, 0.625d, 0.9375d), + new SimpleCuboid(0.625d, 0.1875d, 0.625d, 0.875d, 0.8125d, 0.875d), + new SimpleCuboid(0.5625d, 0.6875d, 0.5625d, 0.9375d, 0.75d, 0.9375d), + new SimpleCuboid(0.5625d, 0.1875d, 0.0625d, 0.9375d, 0.25d, 0.4375d), + new SimpleCuboid(0.5625d, 0.3125d, 0.0625d, 0.9375d, 0.375d, 0.4375d), + new SimpleCuboid(0.5625d, 0.4375d, 0.0625d, 0.9375d, 0.5d, 0.4375d), + new SimpleCuboid(0.5625d, 0.5625d, 0.0625d, 0.9375d, 0.625d, 0.4375d), + new SimpleCuboid(0.625d, 0.1875d, 0.125d, 0.875d, 0.8125d, 0.375d), + new SimpleCuboid(0.5625d, 0.6875d, 0.0625d, 0.9375d, 0.75d, 0.4375d) + ); } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/PlatePressBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/PlatePressBlock.kt index f2b25cc0f..31fedcad5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/PlatePressBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/PlatePressBlock.kt @@ -39,7 +39,6 @@ class PlatePressBlock(properties: Properties = DEFAULT_PROPERTIES) : RotatableMa builder.add(WorkerState.WORKER_STATE) } - override fun getShape( p_60555_: BlockState, p_60556_: BlockGetter, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/StoragePowerSupplierBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/StoragePowerSupplierBlock.kt index 50595834d..ce6135c66 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/StoragePowerSupplierBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/StoragePowerSupplierBlock.kt @@ -1,14 +1,19 @@ 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 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.entity.StoragePowerSupplierBlockEntity import ru.dbotthepony.mc.otm.registry.MBlockEntities +import ru.dbotthepony.mc.otm.shapes.BlockShapes class StoragePowerSupplierBlock : RotatableMatteryBlock(), EntityBlock { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { @@ -25,4 +30,30 @@ class StoragePowerSupplierBlock : RotatableMatteryBlock(), EntityBlock { return BlockEntityTicker { _, _, _, tile -> if (tile is StoragePowerSupplierBlockEntity) tile.tick() } } + + 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.STORAGE_POWER_SUPPLIER.computeShape() + + SHAPES = arrayOf( + def, + def, + def, + BlockShapes.STORAGE_POWER_SUPPLIER.rotate(Direction.NORTH).computeShape(), + BlockShapes.STORAGE_POWER_SUPPLIER.rotate(Direction.WEST).computeShape(), + BlockShapes.STORAGE_POWER_SUPPLIER.rotate(Direction.EAST).computeShape() + ) + } + } }