mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-27 07:27:15 +01:00
Merge pull request #6592 from Layers-of-Railways/mc1.18/stabilized_contraption_fixes
Fix Stabilized contraption offset and incorrect rotation
This commit is contained in:
commit
3c9c668b56
3 changed files with 14 additions and 6 deletions
|
@ -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))
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -49,4 +49,7 @@ public class AngleHelper {
|
|||
return diff;
|
||||
}
|
||||
|
||||
public static float wrapAngle180(float angle) {
|
||||
return (angle + 180) % 360 - 180;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue