From b87e707b49854088055c0ee85897cc849086725f Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Tue, 6 Jul 2021 01:16:44 +0200 Subject: [PATCH] Bell Voxelshapes --- .../java/com/simibubi/create/AllShapes.java | 10 +++- .../curiosities/bell/AbstractBellBlock.java | 48 +++++++++++-------- 2 files changed, 36 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/simibubi/create/AllShapes.java b/src/main/java/com/simibubi/create/AllShapes.java index 6ffb1c167..c642695e1 100644 --- a/src/main/java/com/simibubi/create/AllShapes.java +++ b/src/main/java/com/simibubi/create/AllShapes.java @@ -108,7 +108,15 @@ public class AllShapes { PUMP = shape(2, 0, 2, 14, 5, 14).add(4, 0, 4, 12, 16, 12) .add(3, 12, 3, 13, 16, 13) .forDirectional(Direction.UP), - CRUSHING_WHEEL_CONTROLLER_COLLISION = shape(0, 0, 0, 16, 13, 16).forDirectional(Direction.DOWN) + CRUSHING_WHEEL_CONTROLLER_COLLISION = shape(0, 0, 0, 16, 13, 16).forDirectional(Direction.DOWN), + + BELL_FLOOR = shape(0, 0, 2, 16, 12, 14).forHorizontal(SOUTH), + BELL_WALL = shape(4, 4, 8, 12, 12, 16).add(3, 1, 3, 13, 13, 13) + .forHorizontal(SOUTH), + BELL_DOUBLE_WALL = shape(4, 4, 0, 12, 12, 16).add(3, 1, 3, 13, 13, 13) + .forHorizontal(SOUTH), + BELL_CEILING = shape(0, 4, 2, 16, 16, 14).add(3, 1, 3, 13, 13, 13) + .forHorizontal(SOUTH) ; diff --git a/src/main/java/com/simibubi/create/content/curiosities/bell/AbstractBellBlock.java b/src/main/java/com/simibubi/create/content/curiosities/bell/AbstractBellBlock.java index 36d98baa4..2b74cdd75 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/bell/AbstractBellBlock.java +++ b/src/main/java/com/simibubi/create/content/curiosities/bell/AbstractBellBlock.java @@ -2,6 +2,7 @@ package com.simibubi.create.content.curiosities.bell; import javax.annotation.Nullable; +import com.simibubi.create.AllShapes; import com.simibubi.create.foundation.block.ITE; import net.minecraft.block.BellBlock; @@ -31,26 +32,31 @@ public abstract class AbstractBellBlock exten return null; } - protected VoxelShape getShape(BlockState state) { - return VoxelShapes.fullCube(); - } - - @Override - public VoxelShape getCollisionShape(BlockState state, IBlockReader reader, BlockPos pos, ISelectionContext selection) { - return this.getShape(state); - } - @Override public VoxelShape getShape(BlockState state, IBlockReader reader, BlockPos pos, ISelectionContext selection) { - return this.getShape(state); + Direction facing = state.get(field_220133_a); + switch (state.get(field_220134_b)) { + case CEILING: + return AllShapes.BELL_CEILING.get(facing); + case DOUBLE_WALL: + return AllShapes.BELL_DOUBLE_WALL.get(facing); + case FLOOR: + return AllShapes.BELL_FLOOR.get(facing); + case SINGLE_WALL: + return AllShapes.BELL_WALL.get(facing); + default: + return VoxelShapes.fullCube(); + } } @Override - public boolean ring(World world, BlockState state, BlockRayTraceResult hit, @Nullable PlayerEntity player, boolean flag) { + public boolean ring(World world, BlockState state, BlockRayTraceResult hit, @Nullable PlayerEntity player, + boolean flag) { BlockPos pos = hit.getPos(); Direction direction = hit.getFace(); if (direction == null) - direction = world.getBlockState(pos).get(field_220133_a); + direction = world.getBlockState(pos) + .get(field_220133_a); if (!this.canRingFrom(state, direction, hit.getHitVec().y - pos.getY())) return false; @@ -76,15 +82,15 @@ public abstract class AbstractBellBlock exten Direction direction = state.get(field_220133_a); BellAttachment bellAttachment = state.get(field_220134_b); - switch(bellAttachment) { - case FLOOR: - case CEILING: - return direction.getAxis() == hitDir.getAxis(); - case SINGLE_WALL: - case DOUBLE_WALL: - return direction.getAxis() != hitDir.getAxis(); - default: - return false; + switch (bellAttachment) { + case FLOOR: + case CEILING: + return direction.getAxis() == hitDir.getAxis(); + case SINGLE_WALL: + case DOUBLE_WALL: + return direction.getAxis() != hitDir.getAxis(); + default: + return false; } }