Saws check actual verticality in contraptions

This commit is contained in:
Colman Davenport 2020-09-12 18:44:53 -04:00
parent 5342beacaf
commit b89710237d
2 changed files with 15 additions and 2 deletions

View file

@ -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;
}

View file

@ -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<SawTileEntity> {
@ -139,7 +140,13 @@ public class SawRenderer extends SafeTileEntityRenderer<SawTileEntity> {
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)