Skip to content

Commit 51db53c

Browse files
authored
Fix Copycat step placement helper (#6267)
1 parent 41f957a commit 51db53c

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/main/java/com/simibubi/create/content/decoration/copycat/CopycatStepBlock.java

+17-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44

55
import com.simibubi.create.AllBlocks;
66
import com.simibubi.create.AllShapes;
7+
import com.simibubi.create.content.kinetics.steamEngine.PoweredShaftBlock;
78
import com.simibubi.create.foundation.placement.IPlacementHelper;
89
import com.simibubi.create.foundation.placement.PlacementHelpers;
10+
import com.simibubi.create.foundation.placement.PlacementOffset;
911
import com.simibubi.create.foundation.placement.PoleHelper;
1012
import com.simibubi.create.foundation.utility.Iterate;
1113
import com.simibubi.create.foundation.utility.VoxelShaper;
@@ -36,6 +38,8 @@
3638
import net.minecraft.world.phys.shapes.CollisionContext;
3739
import net.minecraft.world.phys.shapes.VoxelShape;
3840

41+
import org.jetbrains.annotations.NotNull;
42+
3943
public class CopycatStepBlock extends WaterloggedCopycatBlock {
4044

4145
public static final EnumProperty<Half> HALF = BlockStateProperties.HALF;
@@ -134,7 +138,7 @@ public boolean canFaceBeOccluded(BlockState state, Direction face) {
134138
return (state.getValue(HALF) == Half.TOP) == (face == Direction.UP);
135139
return state.getValue(FACING) == face;
136140
}
137-
141+
138142
@Override
139143
public boolean shouldFaceAlwaysRender(BlockState state, Direction face) {
140144
return canFaceBeOccluded(state, face.getOpposite());
@@ -222,10 +226,21 @@ public PlacementHelper() {
222226
}
223227

224228
@Override
225-
public Predicate<ItemStack> getItemPredicate() {
229+
public @NotNull Predicate<ItemStack> getItemPredicate() {
226230
return AllBlocks.COPYCAT_STEP::isIn;
227231
}
228232

233+
@Override
234+
public @NotNull PlacementOffset getOffset(Player player, Level world, BlockState state, BlockPos pos,
235+
BlockHitResult ray) {
236+
PlacementOffset offset = super.getOffset(player, world, state, pos, ray);
237+
238+
if (offset.isSuccessful())
239+
offset.withTransform(offset.getTransform()
240+
.andThen(s -> s.setValue(HALF, state.getValue(HALF))));
241+
242+
return offset;
243+
}
229244
}
230245

231246
}

0 commit comments

Comments
 (0)