Fixed crash when an entity other than the player tries to eat

This commit is contained in:
Sollace 2022-10-03 23:44:48 +02:00
parent afda7a6ef8
commit 64be265c04

View file

@ -24,7 +24,9 @@ public record Toxic (
}
public ItemStack finishUsing(ItemStack stack, World world, LivingEntity entity) {
ailment.get(entity).ifPresent(ailment -> ailment.effect().afflict((PlayerEntity)entity, stack));
if (entity instanceof PlayerEntity player) {
ailment.get(entity).ifPresent(ailment -> ailment.effect().afflict(player, stack));
}
return stack;
}