mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Code cleanup
This commit is contained in:
parent
c9b27c3987
commit
c8e0cdde68
2 changed files with 12 additions and 19 deletions
|
|
@ -26,6 +26,7 @@
|
||||||
package org.geysermc.geyser.entity.type;
|
package org.geysermc.geyser.entity.type;
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.cloudburstmc.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
|
@ -38,18 +39,12 @@ import java.util.UUID;
|
||||||
|
|
||||||
public class DisplayBaseEntity extends Entity {
|
public class DisplayBaseEntity extends Entity {
|
||||||
|
|
||||||
private Vector3f baseTranslation;
|
private @Nullable 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) {
|
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);
|
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void initializeMetadata() {
|
|
||||||
super.initializeMetadata();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setDisplayNameVisible(BooleanEntityMetadata entityMetadata) {
|
public void setDisplayNameVisible(BooleanEntityMetadata entityMetadata) {
|
||||||
// Don't allow the display name to be hidden - messes with our armor stand.
|
// Don't allow the display name to be hidden - messes with our armor stand.
|
||||||
|
|
@ -64,24 +59,19 @@ public class DisplayBaseEntity extends Entity {
|
||||||
|
|
||||||
public void setTranslation(EntityMetadata<Vector3f, ?> translationMeta){
|
public void setTranslation(EntityMetadata<Vector3f, ?> translationMeta){
|
||||||
this.baseTranslation = translationMeta.getValue();
|
this.baseTranslation = translationMeta.getValue();
|
||||||
if (this.baseTranslation == null){
|
if (this.baseTranslation == null) {
|
||||||
this.noBaseTranslation = true;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.vehicle == null){
|
if (this.vehicle == null) {
|
||||||
this.setRiderSeatPosition(this.baseTranslation);
|
this.setRiderSeatPosition(this.baseTranslation);
|
||||||
this.moveRelative(0, this.baseTranslation.getY(), 0, yaw, pitch, headYaw, false);
|
this.moveRelative(0, this.baseTranslation.getY(), 0, yaw, pitch, headYaw, false);
|
||||||
} else {
|
} else {
|
||||||
EntityUtils.updateMountOffset(this, this.vehicle, true, true, false);
|
EntityUtils.updateMountOffset(this, this.vehicle, true, true, false);
|
||||||
|
this.updateBedrockMetadata();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector3f getTranslation() {
|
public Vector3f getTranslation() {
|
||||||
return baseTranslation;
|
return baseTranslation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasTranslation(){
|
|
||||||
return !this.noBaseTranslation;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -202,11 +202,14 @@ public final class EntityUtils {
|
||||||
case TRADER_LLAMA, LLAMA -> zOffset = -0.3f;
|
case TRADER_LLAMA, LLAMA -> zOffset = -0.3f;
|
||||||
case TEXT_DISPLAY -> {
|
case TEXT_DISPLAY -> {
|
||||||
if (passenger instanceof TextDisplayEntity textDisplay) {
|
if (passenger instanceof TextDisplayEntity textDisplay) {
|
||||||
if (!textDisplay.hasTranslation()) return;
|
Vector3f displayTranslation = textDisplay.getTranslation();
|
||||||
|
if (displayTranslation == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
xOffset = textDisplay.getTranslation().getX();
|
xOffset = displayTranslation.getX();
|
||||||
yOffset = textDisplay.getTranslation().getY() + 0.2f;
|
yOffset = displayTranslation.getY() + 0.2f;
|
||||||
zOffset = textDisplay.getTranslation().getZ();
|
zOffset = displayTranslation.getZ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue