Skip to content

Commit

Permalink
Fixed armorstand passenger yOffset (GeyserMC#2976)
Browse files Browse the repository at this point in the history
  • Loading branch information
Xamyrz committed Jun 18, 2022
1 parent 71c489b commit fef0401
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class ArmorStandEntity extends LivingEntity {
@Getter
private boolean isMarker = false;
private boolean isInvisible = false;
@Getter
private boolean isSmall = false;

/**
Expand All @@ -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.
Expand Down Expand Up @@ -411,6 +413,8 @@ private void updateOffsetRequirement(boolean newValue) {
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);
}
Expand Down
9 changes: 9 additions & 0 deletions core/src/main/java/org/geysermc/geyser/util/EntityUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,15 @@ public static void updateMountOffset(Entity passenger, Entity mount, boolean rid
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);
}
Expand Down

0 comments on commit fef0401

Please sign in to comment.