Skip to content

[Forge 1.20.1] consumeBite() method in PieBlock.class uses deprecated method FoodData.eat() #1344

Description

@TheRealVoin
// 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);
   }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions