mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Clean up and fix more armor stand inconsistencies (#1988)
This commit is contained in:
parent
ae3f50a79c
commit
e09f33c614
1 changed files with 27 additions and 22 deletions
|
@ -123,43 +123,38 @@ public class ArmorStandEntity extends LivingEntity {
|
||||||
isInvisible = (xd & 0x20) == 0x20;
|
isInvisible = (xd & 0x20) == 0x20;
|
||||||
updateSecondEntityStatus(false);
|
updateSecondEntityStatus(false);
|
||||||
}
|
}
|
||||||
} else if (entityMetadata.getId() == 2 || entityMetadata.getId() == 3) {
|
} else if (entityMetadata.getId() == 2) {
|
||||||
updateSecondEntityStatus(false);
|
updateSecondEntityStatus(false);
|
||||||
} else if (entityMetadata.getId() == 14 && entityMetadata.getType() == MetadataType.BYTE) {
|
} else if (entityMetadata.getId() == 14 && entityMetadata.getType() == MetadataType.BYTE) {
|
||||||
byte xd = (byte) entityMetadata.getValue();
|
byte xd = (byte) entityMetadata.getValue();
|
||||||
|
|
||||||
// isSmall
|
// isSmall
|
||||||
boolean newIsSmall = (xd & 0x01) == 0x01;
|
boolean newIsSmall = (xd & 0x01) == 0x01;
|
||||||
if ((newIsSmall != isSmall) && positionRequiresOffset) {
|
if (newIsSmall != isSmall) {
|
||||||
|
if (positionRequiresOffset) {
|
||||||
// Fix new inconsistency with offset
|
// Fix new inconsistency with offset
|
||||||
this.position = fixOffsetForSize(position, newIsSmall);
|
this.position = fixOffsetForSize(position, newIsSmall);
|
||||||
positionUpdateRequired = true;
|
positionUpdateRequired = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
isSmall = newIsSmall;
|
isSmall = newIsSmall;
|
||||||
if (isSmall) {
|
if (!isMarker) {
|
||||||
|
toggleSmallStatus();
|
||||||
float scale = metadata.getFloat(EntityData.SCALE);
|
|
||||||
if (scale != 0.55f && scale != 0.0f) {
|
|
||||||
metadata.put(EntityData.SCALE, 0.55f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (metadata.getFloat(EntityData.BOUNDING_BOX_WIDTH) == 0.5f) {
|
|
||||||
metadata.put(EntityData.BOUNDING_BOX_WIDTH, 0.25f);
|
|
||||||
metadata.put(EntityData.BOUNDING_BOX_HEIGHT, 0.9875f);
|
|
||||||
}
|
|
||||||
} else if (metadata.getFloat(EntityData.BOUNDING_BOX_WIDTH) == 0.25f) {
|
|
||||||
metadata.put(EntityData.BOUNDING_BOX_WIDTH, entityType.getWidth());
|
|
||||||
metadata.put(EntityData.BOUNDING_BOX_HEIGHT, entityType.getHeight());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// setMarker
|
// setMarker
|
||||||
boolean oldIsMarker = isMarker;
|
boolean oldIsMarker = isMarker;
|
||||||
isMarker = (xd & 0x10) == 0x10;
|
isMarker = (xd & 0x10) == 0x10;
|
||||||
|
if (oldIsMarker != isMarker) {
|
||||||
if (isMarker) {
|
if (isMarker) {
|
||||||
metadata.put(EntityData.BOUNDING_BOX_WIDTH, 0.0f);
|
metadata.put(EntityData.BOUNDING_BOX_WIDTH, 0.0f);
|
||||||
metadata.put(EntityData.BOUNDING_BOX_HEIGHT, 0.0f);
|
metadata.put(EntityData.BOUNDING_BOX_HEIGHT, 0.0f);
|
||||||
|
metadata.put(EntityData.SCALE, 0f);
|
||||||
|
} else {
|
||||||
|
toggleSmallStatus();
|
||||||
}
|
}
|
||||||
if (oldIsMarker != isMarker) {
|
|
||||||
updateSecondEntityStatus(false);
|
updateSecondEntityStatus(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -226,6 +221,7 @@ public class ArmorStandEntity extends LivingEntity {
|
||||||
if (!primaryEntity) return;
|
if (!primaryEntity) return;
|
||||||
if (!isInvisible || isMarker) {
|
if (!isInvisible || isMarker) {
|
||||||
// It is either impossible to show armor, or the armor stand isn't invisible. We good.
|
// It is either impossible to show armor, or the armor stand isn't invisible. We good.
|
||||||
|
metadata.getFlags().setFlag(EntityFlag.INVISIBLE, false);
|
||||||
updateOffsetRequirement(false);
|
updateOffsetRequirement(false);
|
||||||
if (positionUpdateRequired) {
|
if (positionUpdateRequired) {
|
||||||
positionUpdateRequired = false;
|
positionUpdateRequired = false;
|
||||||
|
@ -306,6 +302,15 @@ public class ArmorStandEntity extends LivingEntity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If this armor stand is not a marker, set its bounding box size and scale.
|
||||||
|
*/
|
||||||
|
private void toggleSmallStatus() {
|
||||||
|
metadata.put(EntityData.BOUNDING_BOX_WIDTH, isSmall ? 0.25f : entityType.getWidth());
|
||||||
|
metadata.put(EntityData.BOUNDING_BOX_HEIGHT, isSmall ? 0.9875f : entityType.getHeight());
|
||||||
|
metadata.put(EntityData.SCALE, isSmall ? 0.55f : 1f);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the selected position with the position offset applied.
|
* @return the selected position with the position offset applied.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue