From b89710237db5cd0edc020fd1fe0e273ff34adbf3 Mon Sep 17 00:00:00 2001 From: Colman Davenport Date: Sat, 12 Sep 2020 18:44:53 -0400 Subject: [PATCH] Saws check actual verticality in contraptions --- .../components/actors/SawMovementBehaviour.java | 8 +++++++- .../content/contraptions/components/saw/SawRenderer.java | 9 ++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/SawMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/SawMovementBehaviour.java index fea857ff2..d4a36f042 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/SawMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/SawMovementBehaviour.java @@ -16,6 +16,7 @@ import net.minecraft.entity.item.ItemEntity; import net.minecraft.item.ItemStack; import net.minecraft.tags.BlockTags; import net.minecraft.util.DamageSource; +import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; @@ -39,7 +40,12 @@ public class SawMovementBehaviour extends BlockBreakingMovementBehaviour { @Override public void visitNewPosition(MovementContext context, BlockPos pos) { super.visitNewPosition(context, pos); - if(!SawBlock.isHorizontal(context.state) && context.data.contains("BreakingPos")) { + Vec3d facingVec = new Vec3d(context.state.get(SawBlock.FACING).getDirectionVec()); + facingVec = VecHelper.rotate(facingVec, context.rotation.x, context.rotation.y, context.rotation.z); + facingVec.normalize(); + + Direction closestToFacing = Direction.getFacingFromVector(facingVec.x, facingVec.y, facingVec.z); + if(closestToFacing.getAxis().isVertical() && context.data.contains("BreakingPos")) { context.data.remove("BreakingPos"); context.stall = false; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java index 3d7e5ab7b..078863d50 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java @@ -25,6 +25,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.Direction; import net.minecraft.util.Rotation; import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.Vec3d; public class SawRenderer extends SafeTileEntityRenderer { @@ -139,7 +140,13 @@ public class SawRenderer extends SafeTileEntityRenderer { SuperByteBuffer superBuffer; Direction facing = state.get(SawBlock.FACING); - boolean horizontal = SawBlock.isHorizontal(state); + Vec3d facingVec = new Vec3d(context.state.get(SawBlock.FACING).getDirectionVec()); + facingVec = VecHelper.rotate(facingVec, context.rotation.x, context.rotation.y, context.rotation.z); + facingVec.normalize(); + + Direction closestToFacing = Direction.getFacingFromVector(facingVec.x, facingVec.y, facingVec.z); + + boolean horizontal = closestToFacing.getAxis().isHorizontal(); boolean backwards = VecHelper.isVecPointingTowards(context.relativeMotion, facing.getOpposite()); boolean moving = context.getAnimationSpeed() != 0; boolean shouldAnimate = (context.contraption.stalled && horizontal)