Minecraft Comes Alive (MCA)

Minecraft Comes Alive (MCA)

13M Downloads

Crash on item damage when Villager does not have item in inventory

Closed this issue ยท 1 comments

commented

getHeldItem() returns a new ItemStack without that Item being in the villager inventory. When the item then takes damage, damageHeldItem() then looks for the held item, gets for example an iron sword for the Guards but the item slot returns -1, and causes an array out of bounds exception which crashes the client.

The workaround is to check for item slot returning -1, and only damage the item if it doesn't equal -1.

The real fix would be to have the item in the villager inventory, but this could cause issues in the future when the sword breaks. Does the villager get another sword in their inventory or could their possibly be a chest the villager can go get swords from that the player can fill up?

commented

The two methods you mention need a rewrite. They were partially rewritten awhile ago (that's why they're broken), but I haven't gotten around to finishing it.