// Use the LivingEntity sensitive version in favour of this.
@Deprecated
public void eat(Item pItem, ItemStack pStack) {
this.eat(pItem, pStack, null);
}
This method passes null as the LivingEntity paramether. My mod's mixin requires that LivingEntity is not null and it is not fixable from my side (actually is with null check, but then I'll lose core mechanic of my mod). So you should use player.eat() method instead:
public ItemStack eat(Level pLevel, ItemStack pFood) {
this.getFoodData().eat(pFood.getItem(), pFood, this);
this.awardStat(Stats.ITEM_USED.get(pFood.getItem()));
pLevel.playSound((Player)null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_BURP, SoundSource.PLAYERS, 0.5F, pLevel.random.nextFloat() * 0.1F + 0.9F);
if (this instanceof ServerPlayer) {
CriteriaTriggers.CONSUME_ITEM.trigger((ServerPlayer)this, pFood);
}
return super.eat(pLevel, pFood);
}
This method passes null as the LivingEntity paramether. My mod's mixin requires that LivingEntity is not null and it is not fixable from my side (actually is with null check, but then I'll lose core mechanic of my mod). So you should use player.eat() method instead: