Implement #5666 on main branch

This commit is contained in:
simibubi 2023-11-01 12:56:14 +01:00
parent 2cf7d171df
commit bc340c7d3e
2 changed files with 7 additions and 0 deletions

View file

@ -217,6 +217,9 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
} }
public Vec3 getPassengerPosition(Entity passenger, float partialTicks) { public Vec3 getPassengerPosition(Entity passenger, float partialTicks) {
if (contraption == null)
return null;
UUID id = passenger.getUUID(); UUID id = passenger.getUUID();
if (passenger instanceof OrientedContraptionEntity) { if (passenger instanceof OrientedContraptionEntity) {
BlockPos localPos = contraption.getBearingPosOf(id); BlockPos localPos = contraption.getBearingPosOf(id);
@ -231,6 +234,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
BlockPos seat = contraption.getSeatOf(id); BlockPos seat = contraption.getSeatOf(id);
if (seat == null) if (seat == null)
return null; return null;
Vec3 transformedVector = toGlobalVector(Vec3.atLowerCornerOf(seat) Vec3 transformedVector = toGlobalVector(Vec3.atLowerCornerOf(seat)
.add(.5, passenger.getMyRidingOffset() + ySize - .15f, .5), partialTicks) .add(.5, passenger.getMyRidingOffset() + ySize - .15f, .5), partialTicks)
.add(VecHelper.getCenterOf(BlockPos.ZERO)) .add(VecHelper.getCenterOf(BlockPos.ZERO))

View file

@ -569,6 +569,9 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity {
private Vec3 getContraptionOffset(float partialTicks, Entity ridingEntity) { private Vec3 getContraptionOffset(float partialTicks, Entity ridingEntity) {
AbstractContraptionEntity parent = (AbstractContraptionEntity) ridingEntity; AbstractContraptionEntity parent = (AbstractContraptionEntity) ridingEntity;
Vec3 passengerPosition = parent.getPassengerPosition(this, partialTicks); Vec3 passengerPosition = parent.getPassengerPosition(this, partialTicks);
if (passengerPosition == null)
return Vec3.ZERO;
double x = passengerPosition.x - Mth.lerp(partialTicks, this.xOld, this.getX()); double x = passengerPosition.x - Mth.lerp(partialTicks, this.xOld, this.getX());
double y = passengerPosition.y - Mth.lerp(partialTicks, this.yOld, this.getY()); double y = passengerPosition.y - Mth.lerp(partialTicks, this.yOld, this.getY());
double z = passengerPosition.z - Mth.lerp(partialTicks, this.zOld, this.getZ()); double z = passengerPosition.z - Mth.lerp(partialTicks, this.zOld, this.getZ());