Skip to content

Commit

Permalink
Fall back to vanilla when custom moving block offsets are used, but w…
Browse files Browse the repository at this point in the history
…ith corrected absolute value

Relates to #577
  • Loading branch information
2No2Name committed Nov 8, 2024
1 parent 86cfc8a commit 0f9bce1
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ public abstract class PistonMovingBlockEntityMixin {
cancellable = true
)
private void skipVoxelShapeUnion(BlockGetter world, BlockPos pos, CallbackInfoReturnable<VoxelShape> cir, VoxelShape voxelShape, Direction direction, BlockState blockState, float offset) {
if (offset != 0f && offset != 0.5f && offset != 1f) {
float absOffset = Math.abs(offset);
if (absOffset != 0f && absOffset != 0.5f && absOffset != 1f) {
//This doesn't happen in vanilla, but we fall back to vanilla code in case mods use custom offsets
return;
}
Expand All @@ -62,7 +63,7 @@ private void skipVoxelShapeUnion(BlockGetter world, BlockPos pos, CallbackInfoRe
VoxelShape blockShape = blockState.getCollisionShape(world, pos);

//we cache the simplified shapes, as the simplify() method costs a lot of CPU time and allocates several objects
VoxelShape offsetAndSimplified = getOffsetAndSimplified(blockShape, Math.abs(offset), offset < 0f ? this.direction.getOpposite() : this.direction);
VoxelShape offsetAndSimplified = getOffsetAndSimplified(blockShape, absOffset, offset < 0f ? this.direction.getOpposite() : this.direction);
cir.setReturnValue(offsetAndSimplified);
} else {
//retracting piston heads have to act like their base as well, as the base block is replaced with the moving block
Expand Down

0 comments on commit 0f9bce1

Please sign in to comment.