ProtocolLib

3M Downloads

1.13 SpawnEntityLiving

Ste3et opened this issue ยท 10 comments

commented

Hello @dmulloy2 i have a little question for you i write on my FurnitureLib update for Spigot1.13-pre7 an error in the console then i want to spawn an ArmorStand to an client:

https://hastebin.com/uzitixiler.cs

I hope you can do something with the code i want to fix it from my side i have disable all extra functions in the ArmorStand packet, i have test it only with the blank armorstand and receive the error again. did you know how to expend the

... 20 more

message ? ๐Ÿ˜ƒ i can look at the rest of the debug i think it must be a fail from my side if you want to see my code you can look into the packet data https://github.com/Ste3et/FurnitureLib/blob/master/src/de/Ste3et_C0st/FurnitureLib/main/entity/fArmorStand.java

Spigot-Version: CraftBukkit version git-Spigot-3fa6cc4-961295e (MC: 1.13-pre7) (Implementing API version 1.13-pre7-R0.1-SNAPSHOT)
ProtocolLib-Version: http://ci.dmulloy2.net/job/ProtocolLib/405/

best regrads: Ste3et_C0st (Matthias)

commented

Ok i find it out the problem was the watcher of my plugin i code a simple test plugin
https://hastebin.com/ragozoquxu.java
and the error apears again:
ServerError: https://hastebin.com/kofuhokiye.cs
ClientError: https://hastebin.com/wurewatoza.css

at the moment i work realy hard on the datawatchers with the spigot.jar and the nms system but i do not figure it out. i find out the entity ids from http://wiki.vg/Entity_metadata#Mobs and org.bukkit.entity.EntityType are wrong in this files the minecraft:armor_stand EntityID 30 (org.bukkit.entity.EntityType ) -> EntityID 1 (net.minecraft.server.v1_13_R1.EntityTypes)

EntityTypes.REGISTRY.a(EntityTypes.ARMOR_STAND)

best regrads: Ste3et_C0st (Matthias)

commented

Bump

commented

In 1.13, Mojang changed custom entity names from strings to optionals containing chat components. So if you're dealing with 1.13, you need to do something like Optional.of(WrappedChatComponent.fromText(customName).getHandle())

commented

@dmulloy2 it's seems like WrappedDataWatcher.getEntityWatcher(entity).deepClone(); is returning wrong values too. I'm getting default datawatcher from entities, then i create spawn packets. It's crashing client with: java.lang.ClassCastException: fc cannot be cast to java.lang.Boolean

commented

Ok, when you are trying to spawn entity by packet you need to specify EntityType. But EntityType.getTypeId() is returning wrong id of entity (1.13). This is why i get client crashes.

Example of wrong code: https://github.com/dmulloy2/PacketWrapper/blob/master/PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerSpawnEntityLiving.java#L125

To get correct id you should do something like this:

public void setType(EntityType value) {

	int id = EntityTypes.REGISTRY.a(EntityTypes.a(value.getName()));
	handle.getIntegers().write(1, id);

}
commented

The whole point of packet wrapper is to avoid using NMS, so that's not a great solution

commented

Am I doing something wrong? Trying to set custom name without crashing the client.

int index = 2;
String customName = "test";
Optional value = Optional.of(WrappedChatComponent.fromText(customName).getHandle());
WrappedDataWatcher.Serializer serializer = WrappedDataWatcher.Registry.get(Optional.class);
watcher.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(index, serializer), value);

Error:

java.lang.IllegalArgumentException: No serializer found for class java.util.Optional
	at com.comphenix.protocol.wrappers.WrappedDataWatcher$Registry.get(WrappedDataWatcher.java:940) ~[?:?]

ProtocolLib version 4.4.0-SNAPSHOT-b408 (build 408, latest build)

commented

Instead of
WrappedDataWatcher.Serializer serializer = WrappedDataWatcher.Registry.get(Optional.class);
do
Serializer serializer = Registry.getChatComponentSerializer(true);

commented

That worked, thanks.

commented

Hello @dmulloy2 i receive an error in the console it is a single error i call the methode every entity creation:

https://hastebin.com/usadapozop.log

this is the code line i used: https://github.com/Ste3et/FurnitureLib/blob/master/src/de/Ste3et_C0st/FurnitureLib/main/entity/fEntity.java#L216

best regrads Ste3et_C0st (Matthias)