|
4 | 4 |
|
5 | 5 | import com.simibubi.create.AllBlocks;
|
6 | 6 | import com.simibubi.create.AllShapes;
|
| 7 | +import com.simibubi.create.content.kinetics.steamEngine.PoweredShaftBlock; |
7 | 8 | import com.simibubi.create.foundation.placement.IPlacementHelper;
|
8 | 9 | import com.simibubi.create.foundation.placement.PlacementHelpers;
|
| 10 | +import com.simibubi.create.foundation.placement.PlacementOffset; |
9 | 11 | import com.simibubi.create.foundation.placement.PoleHelper;
|
10 | 12 | import com.simibubi.create.foundation.utility.Iterate;
|
11 | 13 | import com.simibubi.create.foundation.utility.VoxelShaper;
|
|
36 | 38 | import net.minecraft.world.phys.shapes.CollisionContext;
|
37 | 39 | import net.minecraft.world.phys.shapes.VoxelShape;
|
38 | 40 |
|
| 41 | +import org.jetbrains.annotations.NotNull; |
| 42 | + |
39 | 43 | public class CopycatStepBlock extends WaterloggedCopycatBlock {
|
40 | 44 |
|
41 | 45 | public static final EnumProperty<Half> HALF = BlockStateProperties.HALF;
|
@@ -134,7 +138,7 @@ public boolean canFaceBeOccluded(BlockState state, Direction face) {
|
134 | 138 | return (state.getValue(HALF) == Half.TOP) == (face == Direction.UP);
|
135 | 139 | return state.getValue(FACING) == face;
|
136 | 140 | }
|
137 |
| - |
| 141 | + |
138 | 142 | @Override
|
139 | 143 | public boolean shouldFaceAlwaysRender(BlockState state, Direction face) {
|
140 | 144 | return canFaceBeOccluded(state, face.getOpposite());
|
@@ -222,10 +226,21 @@ public PlacementHelper() {
|
222 | 226 | }
|
223 | 227 |
|
224 | 228 | @Override
|
225 |
| - public Predicate<ItemStack> getItemPredicate() { |
| 229 | + public @NotNull Predicate<ItemStack> getItemPredicate() { |
226 | 230 | return AllBlocks.COPYCAT_STEP::isIn;
|
227 | 231 | }
|
228 | 232 |
|
| 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 | + } |
229 | 244 | }
|
230 | 245 |
|
231 | 246 | }
|
0 commit comments