diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/AbstractContraptionEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/AbstractContraptionEntity.java index 822bf7542..e2dcffc56 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/AbstractContraptionEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/AbstractContraptionEntity.java @@ -224,12 +224,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit return; } - for (Iterator> iterator = collidingEntities.entrySet() - .iterator(); iterator.hasNext();) - if (iterator.next() - .getValue() - .incrementAndGet() > 3) - iterator.remove(); + collidingEntities.entrySet().removeIf(e -> e.getValue().incrementAndGet() > 3); xo = getX(); yo = getY(); @@ -642,7 +637,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit public boolean hasExactlyOnePlayerPassenger() { return false; } - + @OnlyIn(Dist.CLIENT) public abstract void doLocalTransforms(float partialTicks, PoseStack[] matrixStacks); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/OrientedContraptionEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/OrientedContraptionEntity.java index 4c9712276..6373f76e1 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/OrientedContraptionEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/OrientedContraptionEntity.java @@ -74,17 +74,12 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { public float prevPitch; public float pitch; - public float targetPitch; - - // When placed using a contraption item - private float initialYawOffset; public OrientedContraptionEntity(EntityType type, Level world) { super(type, world); motionBeforeStall = Vec3.ZERO; attachedExtraInventories = false; isSerializingFurnaceCart = false; - initialYawOffset = -1; } public static OrientedContraptionEntity create(Level world, Contraption contraption, Direction initialOrientation) { @@ -112,11 +107,6 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { return entityData.get(INITIAL_ORIENTATION); } - public void deferOrientation(Direction newInitialAngle) { - entityData.set(INITIAL_ORIENTATION, Direction.UP); - yaw = initialYawOffset = newInitialAngle.toYRot(); - } - @Override public float getYawOffset() { return getInitialYaw(); @@ -398,7 +388,8 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { prevYaw = yaw; float maxApproachSpeed = (float) (motion.length() * 12f / (Math.max(1, getBoundingBox().getXsize() / 6f))); - float approach = AngleHelper.getShortestAngleDiff(yaw, targetYaw); + float yawHint = AngleHelper.getShortestAngleDiff(yaw, yawFromVector(locationDiff)); + float approach = AngleHelper.getShortestAngleDiff(yaw, targetYaw, yawHint); approach = Mth.clamp(approach, -maxApproachSpeed, maxApproachSpeed); yaw += approach; if (Math.abs(AngleHelper.getShortestAngleDiff(yaw, targetYaw)) < 1f) diff --git a/src/main/java/com/simibubi/create/foundation/utility/AngleHelper.java b/src/main/java/com/simibubi/create/foundation/utility/AngleHelper.java index 9a3e2a393..4c3715fb6 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/AngleHelper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/AngleHelper.java @@ -2,6 +2,7 @@ package com.simibubi.create.foundation.utility; import net.minecraft.core.Direction; import net.minecraft.core.Direction.Axis; +import net.minecraft.util.Mth; public class AngleHelper { @@ -40,4 +41,12 @@ public class AngleHelper { return (float) (((((target - current) % 360) + 540) % 360) - 180); } + public static float getShortestAngleDiff(double current, double target, float hint) { + float diff = getShortestAngleDiff(current, target); + if (Mth.equal(Math.abs(diff), 180) && Math.signum(diff) != Math.signum(hint)) { + return diff + 360*Math.signum(hint); + } + return diff; + } + }