Fix Copycat step placement helper (#6267)

This commit is contained in:
IThundxr 2024-03-22 09:27:35 -04:00 committed by GitHub
parent 41f957a94d
commit 51db53c74f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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> 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<ItemStack> getItemPredicate() {
public @NotNull Predicate<ItemStack> 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;
}
}
}