mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-16 09:53:43 +01:00
Saws check actual verticality in contraptions
This commit is contained in:
parent
5342beacaf
commit
b89710237d
2 changed files with 15 additions and 2 deletions
|
@ -16,6 +16,7 @@ import net.minecraft.entity.item.ItemEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tags.BlockTags;
|
import net.minecraft.tags.BlockTags;
|
||||||
import net.minecraft.util.DamageSource;
|
import net.minecraft.util.DamageSource;
|
||||||
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
@ -39,7 +40,12 @@ public class SawMovementBehaviour extends BlockBreakingMovementBehaviour {
|
||||||
@Override
|
@Override
|
||||||
public void visitNewPosition(MovementContext context, BlockPos pos) {
|
public void visitNewPosition(MovementContext context, BlockPos pos) {
|
||||||
super.visitNewPosition(context, 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.data.remove("BreakingPos");
|
||||||
context.stall = false;
|
context.stall = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.Rotation;
|
import net.minecraft.util.Rotation;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
|
||||||
public class SawRenderer extends SafeTileEntityRenderer<SawTileEntity> {
|
public class SawRenderer extends SafeTileEntityRenderer<SawTileEntity> {
|
||||||
|
|
||||||
|
@ -139,7 +140,13 @@ public class SawRenderer extends SafeTileEntityRenderer<SawTileEntity> {
|
||||||
SuperByteBuffer superBuffer;
|
SuperByteBuffer superBuffer;
|
||||||
Direction facing = state.get(SawBlock.FACING);
|
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 backwards = VecHelper.isVecPointingTowards(context.relativeMotion, facing.getOpposite());
|
||||||
boolean moving = context.getAnimationSpeed() != 0;
|
boolean moving = context.getAnimationSpeed() != 0;
|
||||||
boolean shouldAnimate = (context.contraption.stalled && horizontal)
|
boolean shouldAnimate = (context.contraption.stalled && horizontal)
|
||||||
|
|
Loading…
Reference in a new issue