Fixed armorstand passenger yOffset (#2976)

This commit is contained in:
Xamyr 2022-06-18 03:15:31 +01:00 committed by GitHub
parent 71c489b462
commit fef0401add
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View file

@ -51,6 +51,7 @@ public class ArmorStandEntity extends LivingEntity {
@Getter
private boolean isMarker = false;
private boolean isInvisible = false;
@Getter
private boolean isSmall = false;
/**
@ -74,6 +75,7 @@ public class ArmorStandEntity extends LivingEntity {
* - No armor, no name: false
* - No armor, yes name: true
*/
@Getter
private boolean positionRequiresOffset = false;
/**
* Whether we should update the position of this armor stand after metadata updates.
@ -411,6 +413,8 @@ public class ArmorStandEntity extends LivingEntity {
this.positionRequiresOffset = newValue;
if (positionRequiresOffset) {
this.position = applyOffsetToPosition(position);
// Update the passenger offset as armorstand is moving up by roughly 2 blocks
updatePassengerOffsets();
} else {
this.position = removeOffsetFromPosition(position);
}

View file

@ -187,6 +187,15 @@ public final class EntityUtils {
case MINECART, HOPPER_MINECART, TNT_MINECART, CHEST_MINECART, FURNACE_MINECART, SPAWNER_MINECART,
COMMAND_BLOCK_MINECART, BOAT, CHEST_BOAT -> yOffset -= mount.getDefinition().height() * 0.5f;
}
if (passenger.getDefinition().entityType() == EntityType.FALLING_BLOCK) {
yOffset += 0.5f;
}
if (mount.getDefinition().entityType() == EntityType.ARMOR_STAND) {
ArmorStandEntity armorStand = (ArmorStandEntity) mount;
if (armorStand.isPositionRequiresOffset()) {
yOffset -= EntityDefinitions.ARMOR_STAND.height() * (armorStand.isSmall() ? 0.55d : 1d);
}
}
Vector3f offset = Vector3f.from(xOffset, yOffset, zOffset);
passenger.setRiderSeatPosition(offset);
}