Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-26 16:12:46 +01:00
Fix for plugins that use display entities as nametag (#5157)
* Fix for display entity nametags * Added check * Moved lines count to TextDisplayEntity class Removed useless offset * Reset lines when text is null * Conversation changes * Changed y offset formula Removed space * Played around with the yOffset a bit --------- Co-authored-by: Tim203 <mctim203@gmail.com>
Dieser Commit ist enthalten in:
Ursprung
c8dadd8342
Commit
54bdb639cb
@ -25,18 +25,25 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.entity.type;
|
package org.geysermc.geyser.entity.type;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||||
import org.cloudburstmc.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.geyser.translator.text.MessageTranslator;
|
import org.geysermc.geyser.translator.text.MessageTranslator;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.EntityMetadata;
|
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.EntityMetadata;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
// Note: 1.19.4 requires that the billboard is set to something in order to show, on Java Edition
|
// Note: 1.19.4 requires that the billboard is set to something in order to show, on Java Edition
|
||||||
|
@Getter
|
||||||
public class TextDisplayEntity extends DisplayBaseEntity {
|
public class TextDisplayEntity extends DisplayBaseEntity {
|
||||||
|
|
||||||
|
private int lineCount;
|
||||||
|
|
||||||
public TextDisplayEntity(GeyserSession session, int entityId, long geyserId, UUID uuid, EntityDefinition<?> definition, Vector3f position, Vector3f motion, float yaw, float pitch, float headYaw) {
|
public TextDisplayEntity(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.add(0, definition.offset(), 0), motion, yaw, pitch, headYaw);
|
super(session, entityId, geyserId, uuid, definition, position.add(0, definition.offset(), 0), motion, yaw, pitch, headYaw);
|
||||||
}
|
}
|
||||||
@ -61,5 +68,14 @@ public class TextDisplayEntity extends DisplayBaseEntity {
|
|||||||
|
|
||||||
public void setText(EntityMetadata<Component, ?> entityMetadata) {
|
public void setText(EntityMetadata<Component, ?> entityMetadata) {
|
||||||
this.dirtyMetadata.put(EntityDataTypes.NAME, MessageTranslator.convertMessage(entityMetadata.getValue()));
|
this.dirtyMetadata.put(EntityDataTypes.NAME, MessageTranslator.convertMessage(entityMetadata.getValue()));
|
||||||
|
calculateLineCount(entityMetadata.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void calculateLineCount(@Nullable Component text) {
|
||||||
|
if (text == null) {
|
||||||
|
lineCount = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
lineCount = PlainTextComponentSerializer.plainText().serialize(text).split("\n").length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -209,6 +209,18 @@ public final class EntityUtils {
|
|||||||
zOffset = displayTranslation.getZ();
|
zOffset = displayTranslation.getZ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case PLAYER -> {
|
||||||
|
if (passenger instanceof TextDisplayEntity textDisplay) {
|
||||||
|
Vector3f displayTranslation = textDisplay.getTranslation();
|
||||||
|
int lines = textDisplay.getLineCount();
|
||||||
|
if (displayTranslation != null && lines != 0) {
|
||||||
|
float multiplier = .1414f;
|
||||||
|
xOffset = displayTranslation.getX();
|
||||||
|
yOffset += displayTranslation.getY() + multiplier * lines;
|
||||||
|
zOffset = displayTranslation.getZ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (mount instanceof ChestBoatEntity) {
|
if (mount instanceof ChestBoatEntity) {
|
||||||
xOffset = 0.15F;
|
xOffset = 0.15F;
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren