Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-20 06:50:09 +01:00
A start on signs
Dieser Commit ist enthalten in:
Ursprung
d9698edcc2
Commit
8e67b87bc0
@ -236,7 +236,7 @@ public final class EntityDefinitions {
|
|||||||
.type(EntityType.EXPERIENCE_ORB)
|
.type(EntityType.EXPERIENCE_ORB)
|
||||||
.identifier("minecraft:xp_orb")
|
.identifier("minecraft:xp_orb")
|
||||||
.build();
|
.build();
|
||||||
EVOKER_FANGS = EntityDefinition.builder(EvokerFangsEntity::new) // No entity metadata to listen to as of 1.18.1
|
EVOKER_FANGS = EntityDefinition.inherited(EvokerFangsEntity::new, entityBase)
|
||||||
.type(EntityType.EVOKER_FANGS)
|
.type(EntityType.EVOKER_FANGS)
|
||||||
.height(0.8f).width(0.5f)
|
.height(0.8f).width(0.5f)
|
||||||
.identifier("minecraft:evocation_fang")
|
.identifier("minecraft:evocation_fang")
|
||||||
@ -847,6 +847,7 @@ public final class EntityDefinitions {
|
|||||||
.type(EntityType.SNIFFER)
|
.type(EntityType.SNIFFER)
|
||||||
.height(1.75f).width(1.9f)
|
.height(1.75f).width(1.9f)
|
||||||
.addTranslator(MetadataType.SNIFFER_STATE, SnifferEntity::setSnifferState)
|
.addTranslator(MetadataType.SNIFFER_STATE, SnifferEntity::setSnifferState)
|
||||||
|
.addTranslator(null) // Integer, drop seed at tick
|
||||||
.build();
|
.build();
|
||||||
STRIDER = EntityDefinition.inherited(StriderEntity::new, ageableEntityBase)
|
STRIDER = EntityDefinition.inherited(StriderEntity::new, ageableEntityBase)
|
||||||
.type(EntityType.STRIDER)
|
.type(EntityType.STRIDER)
|
||||||
@ -890,7 +891,6 @@ public final class EntityDefinitions {
|
|||||||
.build();
|
.build();
|
||||||
CAMEL = EntityDefinition.inherited(CamelEntity::new, abstractHorseEntityBase)
|
CAMEL = EntityDefinition.inherited(CamelEntity::new, abstractHorseEntityBase)
|
||||||
.type(EntityType.CAMEL)
|
.type(EntityType.CAMEL)
|
||||||
.identifier("minecraft:llama") // todo 1.20
|
|
||||||
.height(2.375f).width(1.7f)
|
.height(2.375f).width(1.7f)
|
||||||
.addTranslator(MetadataType.BOOLEAN, CamelEntity::setDashing)
|
.addTranslator(MetadataType.BOOLEAN, CamelEntity::setDashing)
|
||||||
.addTranslator(null) // Last pose change tick
|
.addTranslator(null) // Last pose change tick
|
||||||
|
@ -29,11 +29,14 @@ import com.github.steveice10.mc.protocol.data.game.entity.metadata.SnifferState;
|
|||||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ObjectEntityMetadata;
|
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ObjectEntityMetadata;
|
||||||
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.entity.EntityDefinitions;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class SnifferEntity extends AnimalEntity {
|
public class SnifferEntity extends AnimalEntity {
|
||||||
|
private static final float DIGGING_HEIGHT = EntityDefinitions.SNIFFER.height() - 0.4f;
|
||||||
|
|
||||||
public SnifferEntity(GeyserSession session, int entityId, long geyserId, UUID uuid, EntityDefinition<?> definition, Vector3f position, Vector3f motion, float yaw, float pitch, float headYaw) {
|
public SnifferEntity(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);
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,6 @@ package org.geysermc.geyser.entity.type.living.animal.horse;
|
|||||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Pose;
|
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Pose;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||||
import org.cloudburstmc.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.item.Items;
|
import org.geysermc.geyser.item.Items;
|
||||||
import org.geysermc.geyser.item.type.Item;
|
import org.geysermc.geyser.item.type.Item;
|
||||||
@ -44,12 +43,6 @@ public class CamelEntity extends AbstractHorseEntity {
|
|||||||
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();
|
|
||||||
this.dirtyMetadata.put(EntityDataTypes.VARIANT, 2); // Closest llama colour to camel
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canEat(Item item) {
|
public boolean canEat(Item item) {
|
||||||
return item == Items.CACTUS;
|
return item == Items.CACTUS;
|
||||||
|
@ -27,8 +27,11 @@ package org.geysermc.geyser.translator.level.block.entity;
|
|||||||
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.level.block.BlockEntityType;
|
import com.github.steveice10.mc.protocol.data.game.level.block.BlockEntityType;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||||
|
import com.github.steveice10.opennbt.tag.builtin.ListTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
||||||
|
import org.cloudburstmc.nbt.NbtMap;
|
||||||
import org.cloudburstmc.nbt.NbtMapBuilder;
|
import org.cloudburstmc.nbt.NbtMapBuilder;
|
||||||
|
import org.geysermc.geyser.text.ChatColor;
|
||||||
import org.geysermc.geyser.translator.text.MessageTranslator;
|
import org.geysermc.geyser.translator.text.MessageTranslator;
|
||||||
import org.geysermc.geyser.util.SignUtils;
|
import org.geysermc.geyser.util.SignUtils;
|
||||||
|
|
||||||
@ -66,10 +69,23 @@ public class SignBlockEntityTranslator extends BlockEntityTranslator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void translateTag(NbtMapBuilder builder, CompoundTag tag, int blockState) {
|
public void translateTag(NbtMapBuilder builder, CompoundTag tag, int blockState) {
|
||||||
|
builder.putCompound("FrontText", translateSide(tag.get("front_text")));
|
||||||
|
builder.putCompound("BackText", translateSide(tag.get("back_text")));
|
||||||
|
var waxed = tag.get("is_waxed");
|
||||||
|
builder.putBoolean("IsWaxed", waxed != null && waxed.getValue() instanceof Number number && number.byteValue() != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private NbtMap translateSide(Tag tag) {
|
||||||
|
if (!(tag instanceof CompoundTag signData)) {
|
||||||
|
return NbtMap.EMPTY;
|
||||||
|
}
|
||||||
|
NbtMapBuilder builder = NbtMap.builder();
|
||||||
|
|
||||||
StringBuilder signText = new StringBuilder();
|
StringBuilder signText = new StringBuilder();
|
||||||
for (int i = 0; i < 4; i++) {
|
Tag messages = signData.get("messages");
|
||||||
int currentLine = i + 1;
|
if (messages instanceof ListTag listTag) {
|
||||||
String signLine = getOrDefault(tag.getValue().get("Text" + currentLine), "");
|
for (int i = 0; i < listTag.size(); i++) {
|
||||||
|
String signLine = (String) listTag.get(i).getValue();
|
||||||
signLine = MessageTranslator.convertMessageLenient(signLine);
|
signLine = MessageTranslator.convertMessageLenient(signLine);
|
||||||
|
|
||||||
// Check the character width on the sign to ensure there is no overflow that is usually hidden
|
// Check the character width on the sign to ensure there is no overflow that is usually hidden
|
||||||
@ -78,7 +94,7 @@ public class SignBlockEntityTranslator extends BlockEntityTranslator {
|
|||||||
StringBuilder finalSignLine = new StringBuilder();
|
StringBuilder finalSignLine = new StringBuilder();
|
||||||
boolean previousCharacterWasFormatting = false; // Color changes do not count for maximum width
|
boolean previousCharacterWasFormatting = false; // Color changes do not count for maximum width
|
||||||
for (char c : signLine.toCharArray()) {
|
for (char c : signLine.toCharArray()) {
|
||||||
if (c == '\u00a7') {
|
if (c == ChatColor.ESCAPE) {
|
||||||
// Don't count this character
|
// Don't count this character
|
||||||
previousCharacterWasFormatting = true;
|
previousCharacterWasFormatting = true;
|
||||||
} else if (previousCharacterWasFormatting) {
|
} else if (previousCharacterWasFormatting) {
|
||||||
@ -100,18 +116,19 @@ public class SignBlockEntityTranslator extends BlockEntityTranslator {
|
|||||||
signText.append(finalSignLine);
|
signText.append(finalSignLine);
|
||||||
signText.append("\n");
|
signText.append("\n");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
builder.putString("Text", signText.toString());
|
builder.putString("Text", signText.toString());
|
||||||
|
|
||||||
// Java Edition 1.14 added the ability to change the text color of the whole sign using dye
|
// Java Edition 1.14 added the ability to change the text color of the whole sign using dye
|
||||||
Tag color = tag.get("Color");
|
Tag color = signData.get("Color");
|
||||||
if (color != null) {
|
if (color != null) {
|
||||||
builder.putInt("SignTextColor", getBedrockSignColor(color.getValue().toString()));
|
builder.putInt("SignTextColor", getBedrockSignColor(color.getValue().toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Glowing text
|
// Glowing text
|
||||||
boolean isGlowing = getOrDefault(tag.getValue().get("GlowingText"), (byte) 0) != (byte) 0;
|
boolean isGlowing = getOrDefault(signData.get("GlowingText"), (byte) 0) != (byte) 0;
|
||||||
builder.putBoolean("IgnoreLighting", isGlowing);
|
builder.putBoolean("IgnoreLighting", isGlowing);
|
||||||
builder.putBoolean("TextIgnoreLegacyBugResolved", isGlowing); // ??? required
|
return builder.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ public class JavaOpenSignEditorTranslator extends PacketTranslator<ClientboundOp
|
|||||||
public void translate(GeyserSession session, ClientboundOpenSignEditorPacket packet) {
|
public void translate(GeyserSession session, ClientboundOpenSignEditorPacket packet) {
|
||||||
OpenSignPacket openSignPacket = new OpenSignPacket();
|
OpenSignPacket openSignPacket = new OpenSignPacket();
|
||||||
openSignPacket.setPosition(packet.getPosition());
|
openSignPacket.setPosition(packet.getPosition());
|
||||||
openSignPacket.setFrontSide(true); // Will be remedied in 1.20
|
openSignPacket.setFrontSide(packet.isFrontText());
|
||||||
session.sendUpstreamPacket(openSignPacket);
|
session.sendUpstreamPacket(openSignPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren