Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client crash. #61

Closed
Eternalrealms opened this issue Oct 2, 2015 · 4 comments
Closed

Client crash. #61

Eternalrealms opened this issue Oct 2, 2015 · 4 comments

Comments

@Eternalrealms
Copy link

Take a pair of depth strider boots, when you're on 1.7 it doesn't SAY they have depth strider but when you put them in an anvil it crashes their client.

It says this on their client. https://gyazo.com/2b92fdc8d9ee177e0d992ebc152130d8

Pastebin of error: http://pastebin.com/WSQ6mDfm

@MrPowerGamerBR
Copy link
Member

Can confirm, also crashes 1.5.2.

Here is a log from the 1.5.2 client: http://pastebin.com/eyj4NYCB

Here is a log from the 1.7.2 client: http://pastebin.com/35bt1unC

I think the only way to fix this is by not sending the new enchants to older clients.

This crashes any client if the enchant is not available for that specific version

Example: A fishing rod with lure crashes a 1.5.2 client while trying to use in an anvil.

@MrPowerGamerBR
Copy link
Member

A very simple fix would be changing the PacketDataSerializer class to verify the player version and removing the affected enchant and then sending the item without the enchant.

Like this:

org.bukkit.inventory.ItemStack is = CraftItemStack.asBukkitCopy(itemstack);

/*
* TODO: Need to verify the player's version before stripping the enchant.
*/
if (is.containsEnchantment(Enchantment.DEPTH_STRIDER)) {
    is.removeEnchantment(Enchantment.DEPTH_STRIDER);
}
itemstack = CraftItemStack.asNMSCopy(is);

This works, however it will remove the enchant to every client, not only to 1.5/1.6/1.7 clients, and no player argument is passed to the "a" function (however, you can get the version using getVersion()), so it will be a very easy fix.

Also a little bonus, you can edit the item lore (by editing the ItemMeta) to "add" the Depth Strider enchant, so people without 1.8 could at least see the enchant on the item.

EDIT: With some protocol magic, it would be easy to add the "glowing" effect to the item.

TL;DR: Remove the enchant before sending the packet, this will make the item not glow and it will appear as non-enchanted to 1.5/1.6/1.7 clients, then, edit the item to add the "Depth Strider I" enchant on the lore, this will allow 1.5/1.6/1.7 clients to know that the item is enchanted, then, with some protocol magic, add the glowing effect.

This will be better than the current implementation (the item glows on 1.5/1.6/1.7 build, however, you can't know what is the enchant and, if you try to use in an Anvil, the client crashes)

@Shevchik
Copy link
Member

Should be fixed now

@MrPowerGamerBR
Copy link
Member

@Shevchik I didn't test, but after doing a quick look on the modified code, it doesn't verify for the fishing enchantments that didn't exist on 1.5.2 and 1.6.4, those enchants (Enchantment.LURE and Enchantment.LUCK) also make the client crash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants