From 04f4adcf46b9e0327f7bf4249fe99dbe283efc44 Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Sat, 17 Sep 2022 22:36:10 +0200 Subject: [PATCH] Oofset - Correction to a previous fix --- .../AbstractContraptionEntity.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) 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 cc31b9b52..58ccad24e 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 @@ -300,17 +300,27 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit } public Vec3 toGlobalVector(Vec3 localVec, float partialTicks) { + return toGlobalVector(localVec, partialTicks, false); + } + + public Vec3 toGlobalVector(Vec3 localVec, float partialTicks, boolean prevAnchor) { + Vec3 anchor = prevAnchor ? getPrevAnchorVec() : getAnchorVec(); Vec3 rotationOffset = VecHelper.getCenterOf(BlockPos.ZERO); localVec = localVec.subtract(rotationOffset); localVec = applyRotation(localVec, partialTicks); localVec = localVec.add(rotationOffset) - .add(getPrevAnchorVec()); + .add(anchor); return localVec; } + + public Vec3 toLocalVector(Vec3 localVec, float partialTicks) { + return toLocalVector(localVec, partialTicks, false); + } - public Vec3 toLocalVector(Vec3 globalVec, float partialTicks) { + public Vec3 toLocalVector(Vec3 globalVec, float partialTicks, boolean prevAnchor) { + Vec3 anchor = prevAnchor ? getPrevAnchorVec() : getAnchorVec(); Vec3 rotationOffset = VecHelper.getCenterOf(BlockPos.ZERO); - globalVec = globalVec.subtract(getPrevAnchorVec()) + globalVec = globalVec.subtract(anchor) .subtract(rotationOffset); globalVec = reverseRotation(globalVec, partialTicks); globalVec = globalVec.add(rotationOffset); @@ -797,7 +807,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit if (prevPosInvalid) return Vec3.ZERO; - Vec3 contactPoint = toGlobalVector(toLocalVector(globalContactPoint, 0), 1); + Vec3 contactPoint = toGlobalVector(toLocalVector(globalContactPoint, 0, true), 1, true); Vec3 contraptionLocalMovement = contactPoint.subtract(globalContactPoint); Vec3 contraptionAnchorMovement = position().subtract(getPrevPositionVec()); return contraptionLocalMovement.add(contraptionAnchorMovement);