ZHorse

ZHorse

10.4k Downloads

Horse clones from /zh here are incomplete

RedPanda4552 opened this issue ยท 5 comments

commented

Horses teleported with /zh here are only partially reconstructed versions of the original. The owner field is stripped away. Carried saddles also don't carry over, and I don't see a setter for the armor either.

Adding something to the effect of horse.setOwner(Bukkit.getPlayer(statRecord.getOwnerUUID())); in your HorseManager.assignStats() method should do the trick for the owner, if I am reading everything right.

commented

I might have skipped the owner indeed.
However, saddles or any other inventory item should be copied thanks to this method : https://github.com/Xibalba/ZHorse/blob/master/src/com/gmail/xibalbazedd/zhorse/managers/HorseManager.java#L262
Are there any errors in the console when executing /zh here ?

commented

I do not have console access; I am actually another plugin dev who the server owners contacted about this.

It looks like the inventory clone isn't doing the trick. Normal horses have a HorseInventory object that has specific definitions for the saddle and armor slot, and these don't exist in the Inventory object inherited from LivingEntity. I know there is also a LlamaInventory that does the same thing. But all the other horse types, I haven't found a good way to access saddles. Type casting the inventory won't do either.

I haven't been super pleased with the 1.11.x APIs from Spigot for these reasons...

commented

Well, a console output would help because it works fine on many other servers :p
I just updated my test server to the very last Spigot release and it still works, so I can't really help without other details.

About the inventory, I don't know the internal behaviour of Inventory::setContent but it might be overrided by all sub-classes of Inventory, or taking the size and slots into account, thus allowing to transfer saddles, armors, chests, etc. as expected.

commented

I just modified one of my plugins to imitate this inventory copy with the generic getInventory() and it does seem to work. So now I can't even reproduce my own problem on my test server. At this point I'm willing to chalk that up to a server side problem of theirs.

Now, other problem I just had on their server was duplication. /zh here made a clone and didn't remove the old. I can't help with reproduction on this one, as Vault is throwing permission errors on my test server (I don't have permissions plugins, I just have OP for everything). But thought I'd let you know this popped up as well.

commented

Yes, duplications used to occur from time to time prior to 1.6.4 because Entity::remove sometimes fails when the entity's chunk is unloaded.
Now this is taken into account and duplications are less frequent. I will add another layer of protection against duplicates for 1.6.6.