mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Code cleaning and optimization
This commit is contained in:
parent
92f40aedf9
commit
5fcfd5a9f0
3 changed files with 28 additions and 12 deletions
|
|
@ -316,7 +316,6 @@ public final class EntityDefinitions {
|
|||
.addTranslator(null) // Height
|
||||
.addTranslator(null) // Glow color override
|
||||
.build();
|
||||
|
||||
TEXT_DISPLAY = EntityDefinition.inherited(TextDisplayEntity::new, displayBase)
|
||||
.type(EntityType.TEXT_DISPLAY)
|
||||
.identifier("minecraft:armor_stand")
|
||||
|
|
|
|||
|
|
@ -38,8 +38,8 @@ import java.util.UUID;
|
|||
|
||||
public class DisplayBaseEntity extends Entity {
|
||||
|
||||
public Vector3f baseTranslation;
|
||||
|
||||
private Vector3f baseTranslation;
|
||||
private boolean noBaseTranslation;
|
||||
|
||||
public DisplayBaseEntity(GeyserSession session, int entityId, long geyserId, UUID uuid, EntityDefinition<?> definition, Vector3f position, Vector3f motion, float yaw, float pitch, float headYaw) {
|
||||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||
|
|
@ -64,12 +64,24 @@ public class DisplayBaseEntity extends Entity {
|
|||
|
||||
public void setTranslation(EntityMetadata<Vector3f, ?> translationMeta){
|
||||
this.baseTranslation = translationMeta.getValue();
|
||||
if (this.baseTranslation == null){
|
||||
this.noBaseTranslation = true;
|
||||
return;
|
||||
}
|
||||
if (this.vehicle == null){
|
||||
this.setRiderSeatPosition(this.baseTranslation);
|
||||
this.moveRelative(0, this.baseTranslation.getY(), 0, yaw, pitch, headYaw, false);
|
||||
} else {
|
||||
EntityUtils.updateMountOffset(this, this.vehicle, true, true, false);
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3f getTranslation() {
|
||||
return baseTranslation;
|
||||
}
|
||||
|
||||
public boolean hasTranslation(){
|
||||
return !this.noBaseTranslation;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ public final class EntityUtils {
|
|||
*/
|
||||
public static void updateMountOffset(Entity passenger, Entity mount, boolean rider, boolean riding, boolean moreThanOneEntity) {
|
||||
if (passenger instanceof TextDisplayEntity textDisplay
|
||||
&& textDisplay.baseTranslation == null) return;
|
||||
&& !textDisplay.hasTranslation()) return;
|
||||
|
||||
passenger.setFlag(EntityFlag.RIDING, riding);
|
||||
if (riding) {
|
||||
|
|
@ -197,6 +197,15 @@ public final class EntityUtils {
|
|||
case CHEST_BOAT -> xOffset = 0.15F;
|
||||
case CHICKEN -> zOffset = -0.1f;
|
||||
case TRADER_LLAMA, LLAMA -> zOffset = -0.3f;
|
||||
case TEXT_DISPLAY -> {
|
||||
TextDisplayEntity textDisplay;
|
||||
if (passenger instanceof TextDisplayEntity) {
|
||||
textDisplay = (TextDisplayEntity) passenger;
|
||||
xOffset = textDisplay.getTranslation().getX();
|
||||
yOffset = textDisplay.getTranslation().getY() + 0.2f;
|
||||
zOffset = textDisplay.getTranslation().getZ();
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Bedrock Differences
|
||||
|
|
@ -222,11 +231,7 @@ public final class EntityUtils {
|
|||
if (mount instanceof ArmorStandEntity armorStand) {
|
||||
yOffset -= armorStand.getYOffset();
|
||||
}
|
||||
Vector3f offset = Vector3f.from(xOffset, yOffset, zOffset);
|
||||
|
||||
passenger.setRiderSeatPosition( passenger instanceof TextDisplayEntity textDisplay ?
|
||||
textDisplay.baseTranslation.add(offset).add(0f, 0.2f, 0f) : offset
|
||||
);
|
||||
passenger.setRiderSeatPosition(Vector3f.from(xOffset, yOffset, zOffset));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue