Custom name for ServerNamedEntitySpawn not working
riflowth opened this issue · 4 comments
Make sure you're doing the following
- You're using the latest build for your server version
- This isn't an issue caused by another plugin
- You've checked for duplicate issues --> #674 But it doesn't work for me
- You didn't use
/reload
Describe the question
I have changed the NPC name but nothing happened.
I use PaperMC 1.15.5 and lastest version of ProtocolLib
Code
int entityId = ThreadLocalRandom.current().nextInt() + 10000;
ServerNamedEntitySpawn spawnPacket = new ServerNamedEntitySpawn();
spawnPacket.setEntityID(entityId);
spawnPacket.setPlayerUUID(gameProfile.getUUID());
spawnPacket.setLocation(location);
spawnPacket.sendPacket(player);
ServerEntityMetadata metadataPacket = new ServerEntityMetadata();
metadataPacket.setEntityId(entityId);
Optional<?> optional = Optional.of(WrappedChatComponent.fromChatMessage(displayName)[0].getHandle());
WrappedDataWatcher dataWatcher = new WrappedDataWatcher(metadataPacket.getMetadata());
dataWatcher.setObject(new WrappedDataWatcherObject(0, Registry.get(Byte.class)), (byte) 0x00);
dataWatcher.setObject(new WrappedDataWatcherObject(2, Registry.getChatComponentSerializer(true)), optional);
dataWatcher.setObject(new WrappedDataWatcherObject(3, Registry.get(Boolean.class)), true);
metadataPacket.setEntityMetadata(dataWatcher.getWatchableObjects());
metadataPacket.sendPacket(player);
Same setup, can confirm I'm not the only one. I've been searching for 4+ hours how fix my code, turns out it might be a ProtocolLib error
@alexxbout No 😢