From d6e90e4679f0c0bda61ac55f3119fe600d605573 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 15 May 2022 14:56:40 +0700 Subject: [PATCH] Drive viewer block shape --- .../mc/otm/shapes/BlockShapes.java | 17 +++++++++++ .../mc/otm/block/DriveViewerBlock.kt | 28 +++++++++++++++++++ 2 files changed, 45 insertions(+) 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 8b95bccd0..748c5ccb2 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java +++ b/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java @@ -439,4 +439,21 @@ public class BlockShapes { 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) ); + + public static final BlockShape DRIVE_VIEWER = new BlockShape( + new SimpleCuboid(0d, 0d, 0d, 1d, 0.5d, 1d), + new SimpleCuboid(0.125d, 0.5d, 0.125d, 0.875d, 0.875d, 0.875d), + new SimpleCuboid(0.25d, 0.5d, 0.8125d, 0.75d, 0.9375d, 0.9375d), + new SimpleCuboid(0.875d, 0.5d, 0.375d, 0.9375d, 0.8125d, 0.5d), + new SimpleCuboid(0.875d, 0.5d, 0.5625d, 0.9375d, 0.8125d, 0.6875d), + new SimpleCuboid(0d, 0.5d, 0d, 0.0625d, 1d, 0.0625d), + new SimpleCuboid(0.9375d, 0.5d, 0d, 1d, 1d, 0.0625d), + new SimpleCuboid(0.3125d, 0.5d, 0d, 0.6875d, 0.9375d, 0.1875d), + new SimpleCuboid(0.9375d, 0.5d, 0.9375d, 1d, 1d, 1d), + new SimpleCuboid(0.03125d, 0.875d, 0.0625d, 0.0625d, 0.9375d, 0.9375d), + new SimpleCuboid(0.03125d, 0.5625d, 0.0625d, 0.0625d, 0.625d, 0.9375d), + new SimpleCuboid(0.9375d, 0.5625d, 0.0625d, 0.96875d, 0.625d, 0.9375d), + new SimpleCuboid(0.9375d, 0.875d, 0.0625d, 0.96875d, 0.9375d, 0.9375d), + new SimpleCuboid(0d, 0.5d, 0.9375d, 0.0625d, 1d, 1d) + ); } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/DriveViewerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/DriveViewerBlock.kt index 87146e2a9..06150edce 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/DriveViewerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/DriveViewerBlock.kt @@ -1,7 +1,9 @@ package ru.dbotthepony.mc.otm.block import net.minecraft.core.BlockPos +import net.minecraft.core.Direction import net.minecraft.world.item.context.BlockPlaceContext +import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.EntityBlock @@ -11,9 +13,12 @@ import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.StateDefinition import net.minecraft.world.level.block.state.properties.BooleanProperty +import net.minecraft.world.phys.shapes.CollisionContext +import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.entity.DriveViewerBlockEntity import ru.dbotthepony.mc.otm.block.entity.worker.WorkerState import ru.dbotthepony.mc.otm.registry.MBlockEntities +import ru.dbotthepony.mc.otm.shapes.BlockShapes class DriveViewerBlock : RotatableMatteryBlock(), EntityBlock { override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { @@ -41,7 +46,30 @@ class DriveViewerBlock : RotatableMatteryBlock(), EntityBlock { return super.getStateForPlacement(context)!!.setValue(DRIVE_PRESENT, false) } + 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 { val DRIVE_PRESENT: BooleanProperty = BooleanProperty.create("drive") + private val SHAPES: Array + + init { + val def = BlockShapes.DRIVE_VIEWER.computeShape() + + SHAPES = arrayOf( + def, + def, + def, + BlockShapes.DRIVE_VIEWER.rotate(Direction.NORTH).computeShape(), + BlockShapes.DRIVE_VIEWER.rotate(Direction.WEST).computeShape(), + BlockShapes.DRIVE_VIEWER.rotate(Direction.EAST).computeShape() + ) + } } }