new things

This commit is contained in:
zimzaza4
2024-09-08 14:25:32 +08:00
parent e42b6b213e
commit 788b5b1981
4 changed files with 142 additions and 188 deletions

View File

@@ -2,13 +2,18 @@ package re.imc.geysermodelengine.packet;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.WrappedChatComponent;
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
import java.util.Optional;
public class EntityMetadataPacket implements WrapperPacket {
private final int id;
private final String name;
public EntityMetadataPacket(int id) {
public EntityMetadataPacket(int id, String name) {
this.id = id;
this.name = name;
}
@Override
@@ -16,6 +21,7 @@ public class EntityMetadataPacket implements WrapperPacket {
PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);
packet.getIntegers().write(0, id);
WrappedDataWatcher watcher = new WrappedDataWatcher();
watcher.setOptionalChatComponent(0, Optional.of(WrappedChatComponent.fromLegacyText(name)) ,true);
packet.getWatchableCollectionModifier().writeSafely(0, watcher.getWatchableObjects());
return packet;
}