From f9c966d6a89f9b7a93d93399ede94d04e93af674 Mon Sep 17 00:00:00 2001 From: techno-sam <77073745+techno-sam@users.noreply.github.com> Date: Wed, 12 Jun 2024 15:49:08 -0700 Subject: [PATCH] I'm totally stable fixes Creators-of-Create/Create#3640 and Creators-of-Create/Create#6590 --- .../contraptions/AbstractContraptionEntity.java | 10 +++++++--- .../contraptions/OrientedContraptionEntity.java | 7 ++++--- .../create/foundation/utility/AngleHelper.java | 3 +++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/AbstractContraptionEntity.java b/src/main/java/com/simibubi/create/content/contraptions/AbstractContraptionEntity.java index a23fb5e6e..795513952 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/AbstractContraptionEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/AbstractContraptionEntity.java @@ -212,14 +212,18 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit Vec3 transformedVector = getPassengerPosition(passenger, 1); if (transformedVector == null) return; + + float offset = -1 / 8f; + if (passenger instanceof AbstractContraptionEntity) + offset = 0.0f; callback.accept(passenger, transformedVector.x, - transformedVector.y + SeatEntity.getCustomEntitySeatOffset(passenger) - 1 / 8f, transformedVector.z); + transformedVector.y + SeatEntity.getCustomEntitySeatOffset(passenger) + offset, transformedVector.z); } public Vec3 getPassengerPosition(Entity passenger, float partialTicks) { if (contraption == null) return null; - + UUID id = passenger.getUUID(); if (passenger instanceof OrientedContraptionEntity) { BlockPos localPos = contraption.getBearingPosOf(id); @@ -234,7 +238,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit BlockPos seat = contraption.getSeatOf(id); if (seat == null) return null; - + Vec3 transformedVector = toGlobalVector(Vec3.atLowerCornerOf(seat) .add(.5, passenger.getMyRidingOffset() + ySize - .15f, .5), partialTicks) .add(VecHelper.getCenterOf(BlockPos.ZERO)) diff --git a/src/main/java/com/simibubi/create/content/contraptions/OrientedContraptionEntity.java b/src/main/java/com/simibubi/create/content/contraptions/OrientedContraptionEntity.java index 13dc64607..4882e858e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/OrientedContraptionEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/OrientedContraptionEntity.java @@ -1,6 +1,7 @@ package com.simibubi.create.content.contraptions; import static com.simibubi.create.foundation.utility.AngleHelper.angleLerp; +import static com.simibubi.create.foundation.utility.AngleHelper.wrapAngle180; import java.util.Optional; import java.util.UUID; @@ -353,7 +354,7 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { return false; OrientedContraptionEntity parent = (OrientedContraptionEntity) riding; prevYaw = yaw; - yaw = -parent.getViewYRot(1); + yaw = wrapAngle180(getInitialYaw() - parent.getInitialYaw()) - parent.getViewYRot(1); return false; } @@ -496,7 +497,7 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { Vec3 anchorVec = super.getAnchorVec(); return anchorVec.subtract(.5, 0, .5); } - + @Override public Vec3 getPrevAnchorVec() { Vec3 prevAnchorVec = super.getPrevAnchorVec(); @@ -571,7 +572,7 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { Vec3 passengerPosition = parent.getPassengerPosition(this, partialTicks); if (passengerPosition == null) return Vec3.ZERO; - + double x = passengerPosition.x - Mth.lerp(partialTicks, this.xOld, this.getX()); double y = passengerPosition.y - Mth.lerp(partialTicks, this.yOld, this.getY()); double z = passengerPosition.z - Mth.lerp(partialTicks, this.zOld, this.getZ()); 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 4c3715fb6..94a639161 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/AngleHelper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/AngleHelper.java @@ -49,4 +49,7 @@ public class AngleHelper { return diff; } + public static float wrapAngle180(float angle) { + return (angle + 180) % 360 - 180; + } }