From cb433871be04f117b5b08705c49f727a96464f8b Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 28 Jan 2023 18:48:53 +0700 Subject: [PATCH] Holo sign shape --- .../dbotthepony/mc/otm/shapes/BlockShapes.java | 14 ++++++++++++++ .../mc/otm/block/decorative/HoloSignBlock.kt | 18 ++++++++++++++++++ .../render/blockentity/HoloSignRenderer.kt | 2 +- 3 files changed, 33 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 c260aba9c..6809d213d 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java +++ b/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java @@ -601,4 +601,18 @@ public class BlockShapes { new SimpleCuboid(0.4375d, 0.8125d, 1d, 0.5625d, 0.9375d, 1d), new SimpleCuboid(0.4375d, 0.8125d, 0d, 0.5625d, 0.9375d, 0d) ); + + public static final BlockShape HOLO_SIGN = new BlockShape( + new SimpleCuboid(0d, 0d, 0.875d, 1d, 1d, 1d), + new SimpleCuboid(0.0625d, 0.0625d, 0.8125d, 0.9375d, 0.9375d, 0.875d), + new SimpleCuboid(0d, 0d, 0.625d, 1d, 1d, 0.8125d), + new SimpleCuboid(0.875d, 0.3125d, 0.5625d, 1d, 0.6875d, 0.625d), + new SimpleCuboid(0d, 0.3125d, 0.5625d, 0.125d, 0.6875d, 0.625d), + new SimpleCuboid(0.0625d, 0.875d, 0.625d, 0.125d, 0.9375d, 0.625d), + new SimpleCuboid(0.0625d, 0.0625d, 0.625d, 0.125d, 0.125d, 0.625d), + new SimpleCuboid(0.875d, 0.0625d, 0.625d, 0.9375d, 0.125d, 0.625d), + new SimpleCuboid(0.875d, 0.875d, 0.625d, 0.9375d, 0.9375d, 0.625d), + new SimpleCuboid(0.875d, 0.375d, 0.5625d, 0.875d, 0.625d, 0.625d), + new SimpleCuboid(0.125d, 0.375d, 0.5625d, 0.125d, 0.625d, 0.625d) + ); } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt index f49adacbd..608461e44 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt @@ -1,11 +1,16 @@ package ru.dbotthepony.mc.otm.block.decorative import net.minecraft.core.BlockPos +import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.block.EntityBlock import net.minecraft.world.level.block.entity.BlockEntity 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.decorative.HoloSignBlockEntity +import ru.dbotthepony.mc.otm.core.get +import ru.dbotthepony.mc.otm.shapes.BlockShapes class HoloSignBlock : RotatableMatteryBlock(), EntityBlock { override val hasFreeRotation: Boolean @@ -14,4 +19,17 @@ class HoloSignBlock : RotatableMatteryBlock(), EntityBlock { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { return HoloSignBlockEntity(p_153215_, p_153216_) } + + private val shapes = getShapeForEachState { + BlockShapes.HOLO_SIGN.rotateInv(it[FACING_FULL]).computeShape() + } + + override fun getShape( + pState: BlockState, + pLevel: BlockGetter, + pPos: BlockPos, + pContext: CollisionContext + ): VoxelShape { + return shapes[pState]!! + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/HoloSignRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/HoloSignRenderer.kt index 59ede0d1a..7a99d84e6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/HoloSignRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/HoloSignRenderer.kt @@ -26,7 +26,7 @@ class HoloSignRenderer(private val context: BlockEntityRendererProvider.Context) ) { poseStack.pushPose() poseStack.rotateWithBlockFacing(tile.blockState[RotatableMatteryBlock.FACING_FULL]) - poseStack.translate(0.5f, 0.5f, -0.05f) + poseStack.translate(0.5f, 0.5f, 0.6f) poseStack.scale(0.01f, 0.01f, 0.01f) val sorse = DynamicBufferSource.WORLD