Search in sources :

Example 1 with FoodStatsAccessor

use of com.almuradev.almura.asm.mixin.accessors.util.FoodStatsAccessor in project Almura by AlmuraDev.

the class FoodLevelChangeApply method apply0.

@Override
public void apply0(final EntityPlayer entity, final ItemApplyContext context) {
    final ItemStack usedStack = context.item();
    if (usedStack.getItem() instanceof ItemFood) {
        final ItemFood food = (ItemFood) usedStack.getItem();
        final int currentFoodLevel = ((FoodStatsAccessor) entity.getFoodStats()).accessor$getFoodLevel();
        ((FoodStatsAccessor) entity.getFoodStats()).accessor$setFoodLevel(Math.min(currentFoodLevel + food.getHealAmount(usedStack), 20));
    }
}
Also used : FoodStatsAccessor(com.almuradev.almura.asm.mixin.accessors.util.FoodStatsAccessor) ItemFood(net.minecraft.item.ItemFood) ItemStack(net.minecraft.item.ItemStack)

Aggregations

FoodStatsAccessor (com.almuradev.almura.asm.mixin.accessors.util.FoodStatsAccessor)1 ItemFood (net.minecraft.item.ItemFood)1 ItemStack (net.minecraft.item.ItemStack)1