Fixed crash due to skeletons stealing items/having their bows stolen. Closes #53

This commit is contained in:
Sollace 2022-03-26 21:51:28 +02:00
parent 8aebf82eff
commit 75a63e7a97

View file

@ -62,12 +62,14 @@ public class WantItTakeItGoal extends BreakHeartGoal {
mob.swingHand(Hand.MAIN_HAND); mob.swingHand(Hand.MAIN_HAND);
if (mob.world.random.nextInt(20) == 0) { if (mob.world.random.nextInt(20) == 0) {
for (EquipmentSlot slot : EquipmentSlot.values()) { for (EquipmentSlot slot : EquipmentSlot.values()) {
ItemStack stack = ((LivingEntity)target).getEquippedStack(slot); ItemStack stack = ((LivingEntity)target).getEquippedStack(slot);
if (EnchantmentHelper.getLevel(UEnchantments.WANT_IT_NEED_IT, stack) > 0) { if (EnchantmentHelper.getLevel(UEnchantments.WANT_IT_NEED_IT, stack) > 0) {
AwaitTickQueue.scheduleTask(mob.world, w -> {
target.equipStack(slot, ItemStack.EMPTY); target.equipStack(slot, ItemStack.EMPTY);
AwaitTickQueue.scheduleTask(mob.world, w -> mob.tryEquip(stack)); mob.tryEquip(stack);
});
break;
} }
} }
} }