From 51db53c74f8497a486a30e1ce4a01f092f2194bf Mon Sep 17 00:00:00 2001 From: IThundxr Date: Fri, 22 Mar 2024 09:27:35 -0400 Subject: [PATCH] Fix Copycat step placement helper (#6267) --- .../decoration/copycat/CopycatStepBlock.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/decoration/copycat/CopycatStepBlock.java b/src/main/java/com/simibubi/create/content/decoration/copycat/CopycatStepBlock.java index 11af92da6..6d8954177 100644 --- a/src/main/java/com/simibubi/create/content/decoration/copycat/CopycatStepBlock.java +++ b/src/main/java/com/simibubi/create/content/decoration/copycat/CopycatStepBlock.java @@ -4,8 +4,10 @@ import java.util.function.Predicate; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllShapes; +import com.simibubi.create.content.kinetics.steamEngine.PoweredShaftBlock; import com.simibubi.create.foundation.placement.IPlacementHelper; import com.simibubi.create.foundation.placement.PlacementHelpers; +import com.simibubi.create.foundation.placement.PlacementOffset; import com.simibubi.create.foundation.placement.PoleHelper; import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.VoxelShaper; @@ -36,6 +38,8 @@ import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; +import org.jetbrains.annotations.NotNull; + public class CopycatStepBlock extends WaterloggedCopycatBlock { public static final EnumProperty HALF = BlockStateProperties.HALF; @@ -134,7 +138,7 @@ public class CopycatStepBlock extends WaterloggedCopycatBlock { return (state.getValue(HALF) == Half.TOP) == (face == Direction.UP); return state.getValue(FACING) == face; } - + @Override public boolean shouldFaceAlwaysRender(BlockState state, Direction face) { return canFaceBeOccluded(state, face.getOpposite()); @@ -222,10 +226,21 @@ public class CopycatStepBlock extends WaterloggedCopycatBlock { } @Override - public Predicate getItemPredicate() { + public @NotNull Predicate getItemPredicate() { return AllBlocks.COPYCAT_STEP::isIn; } + @Override + public @NotNull PlacementOffset getOffset(Player player, Level world, BlockState state, BlockPos pos, + BlockHitResult ray) { + PlacementOffset offset = super.getOffset(player, world, state, pos, ray); + + if (offset.isSuccessful()) + offset.withTransform(offset.getTransform() + .andThen(s -> s.setValue(HALF, state.getValue(HALF)))); + + return offset; + } } }