net.minecraft.util.FoodStats.addStats()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(10.6k)|赞(0)|评价(0)|浏览(76)

本文整理了Java中net.minecraft.util.FoodStats.addStats()方法的一些代码示例,展示了FoodStats.addStats()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FoodStats.addStats()方法的具体详情如下:
包路径:net.minecraft.util.FoodStats
类名称:FoodStats
方法名:addStats

FoodStats.addStats介绍

暂无

代码示例

代码示例来源:origin: Vazkii/Botania

@Override
public void onUsingTick(ItemStack stack, EntityLivingBase living, int count) {
  super.onUsingTick(stack, living, count);
  if(!(living instanceof EntityPlayer))
    return;
  EntityPlayer player = (EntityPlayer) living;
  if(ManaItemHandler.requestManaExact(stack, player, 500, true)) {
    if(count % 5 == 0)
      player.getFoodStats().addStats(1, 1F);
    if(count == 5)
      if(player.canEat(false))
        player.activeItemStackUseCount = 20;
  }
}

代码示例来源:origin: PenguinSquad/Harvest-Festival

@Override
public ItemStack onItemUseFinish(ItemStack stack, World world, EntityLivingBase entityLiving) {
  if (entityLiving instanceof EntityPlayer) {
    EntityPlayer player = (EntityPlayer) entityLiving;
    if (!player.capabilities.isCreativeMode) --stack.stackSize;
    player.getFoodStats().addStats(this, stack);
    world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_PLAYER_BURP, SoundCategory.PLAYERS, 0.5F, world.rand.nextFloat() * 0.1F + 0.9F);
    return stack;
  }
  return stack;
}

代码示例来源:origin: ForestryMC/Binnie

@Override
  protected IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing, World world, BlockPos position) {
    for (EntityPlayer player : this.getEntities(EntityPlayer.class, genome, housing)) {
      player.getFoodStats().addStats(2, 0.2f);
    }
    return storedData;
  }
},

代码示例来源:origin: PenguinSquad/Harvest-Festival

@Override
public ItemStack onItemUseFinish(ItemStack stack, World world, EntityLivingBase entityLiving) {
  if (stack.hasTagCompound() && entityLiving instanceof EntityPlayer) {
    EntityPlayer player = (EntityPlayer) entityLiving;
    if (!player.capabilities.isCreativeMode) --stack.stackSize;
    player.getFoodStats().addStats(this, stack);
    world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_PLAYER_BURP, SoundCategory.PLAYERS, 0.5F, world.rand.nextFloat() * 0.1F + 0.9F);
    return stack;
  }
  return stack;
}

代码示例来源:origin: NanamiArihara/FoodCraft-Reloaded

@Nonnull
@Override
public ItemStack onItemUseFinish(ItemStack stack, @Nullable World worldIn, EntityLivingBase entityLiving) {
  if (entityLiving instanceof EntityPlayer && worldIn != null) {
    EntityPlayer entityPlayer = (EntityPlayer)entityLiving;
    entityPlayer.getFoodStats().addStats(this, stack);
    worldIn.playSound(entityPlayer, entityPlayer.posX, entityPlayer.posY, entityPlayer.posZ, SoundEvents.ENTITY_PLAYER_BURP, SoundCategory.PLAYERS, 0.5F, worldIn.rand.nextFloat() * 0.1F + 0.9F);
    this.onFoodEaten(stack, worldIn, entityPlayer);
    Optional.ofNullable(StatList.getObjectUseStats(this)).ifPresent(entityPlayer::addStat);
    entityPlayer.addItemStackToInventory(new ItemStack(FCRItems.GLASS_BOTTLE));
  }
  return stack.splitStack(1);
}

代码示例来源:origin: CyclopsMC/EvilCraft

@Override
public ItemStack onItemUseFinish(ItemStack itemStack, World world, EntityLivingBase entity) {
  FluidUtil.getFluidHandler(itemStack).drain(RejuvenatedFleshConfig.biteUsage, true);
  if(entity instanceof EntityPlayer) {
    ((EntityPlayer) entity).getFoodStats().addStats(3, 0.5F);
  }
  world.playSound(null, entity.posX, entity.posY, entity.posZ, SoundEvents.ENTITY_PLAYER_BURP, SoundCategory.PLAYERS, 0.5F, world.rand.nextFloat() * 0.1F + 0.9F);
  return itemStack;
}

代码示例来源:origin: ForestryMC/Binnie

@Override
public ItemStack onItemUseFinish(ItemStack stack, World world, EntityLivingBase entityLiving) {
  if (entityLiving instanceof EntityPlayer) {
    EntityPlayer player = (EntityPlayer) entityLiving;
    player.getFoodStats().addStats(this, stack);
    world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_PLAYER_BURP, SoundCategory.PLAYERS, 0.5F, world.rand.nextFloat() * 0.1F + 0.9F);
    onFoodEaten(stack, world, player);
    return this.container.getEmpty();
  }
  return stack;
}

代码示例来源:origin: TeamWizardry/Wizardry

@Nonnull
@Override
public ItemStack onItemUseFinish(@Nonnull ItemStack stack, World worldIn, EntityLivingBase entityLiving) {
  stack.setCount(stack.getCount() - 1);
  if (entityLiving instanceof EntityPlayer) {
    EntityPlayer entityplayer = (EntityPlayer) entityLiving;
    entityplayer.getFoodStats().addStats(4, 7f);
    worldIn.playSound(null, entityplayer.posX, entityplayer.posY, entityplayer.posZ, SoundEvents.ENTITY_PLAYER_BURP, SoundCategory.PLAYERS, 0.5F, worldIn.rand.nextFloat() * 0.1F + 0.9F);
    entityLiving.addPotionEffect(new PotionEffect(MobEffects.LEVITATION, 200, 1, true, false));
  }
  return stack;
}

代码示例来源:origin: SleepyTrousers/EnderIO

@Override
public void onEntityCollidedWithBlock(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState state, @Nonnull Entity entity) {
 if (!world.isRemote && entity instanceof EntityPlayerMP) {
  long time = entity.world.getTotalWorldTime();
  EntityPlayerMP player = (EntityPlayerMP) entity;
  if (time % FluidConfig.nutrientFoodBoostDelay.get() == 0 && player.getEntityData().getLong("eioLastFoodBoost") != time) {
   player.getFoodStats().addStats(1, 0.1f);
   player.getEntityData().setLong("eioLastFoodBoost", time);
  }
 }
 super.onEntityCollidedWithBlock(world, pos, state, entity);
}

代码示例来源:origin: vadis365/TheErebus

private boolean eatTreatSlice(World world, BlockPos pos, IBlockState state, EntityPlayer player) {
  if (player.canEat(false)) {
    player.getFoodStats().addStats(2, 0.1F);
    player.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 5 * 20, 1));
    int i = ((Integer) state.getValue(BITES)).intValue();
    if (i < 6)
      world.setBlockState(pos, state.withProperty(BITES, Integer.valueOf(i + 1)), 3);
    else
      world.setBlockToAir(pos);
  }
  return true;
}

代码示例来源:origin: MrCrayfish/MrCrayfishFurnitureMod

@Override
public ItemStack onItemUseFinish(ItemStack cup, World world, EntityLivingBase entity)
{
  if(entity instanceof EntityPlayer)
  {
    EntityPlayer player = (EntityPlayer) entity;
    if(hasLiquid)
    {
      int heal = cup.getTagCompound().getInteger("HealAmount");
      player.getFoodStats().addStats(heal, 0.5F);
      return new ItemStack(FurnitureItems.CUP);
    }
  }
  return cup;
}

代码示例来源:origin: GregTechCE/GregTech

@Override
public ItemStack onItemUseFinish(ItemStack stack, EntityPlayer player) {
  stack.shrink(1);
  player.getFoodStats().addStats(foodStats.getFoodLevel(stack, player), foodStats.getSaturation(stack, player));
  foodStats.onEaten(stack, player);
  return stack;
}

代码示例来源:origin: vadis365/TheErebus

@Override
public void onArmorTick(World world, EntityPlayer player, ItemStack stack) {
  if (player.getFoodStats().needFood() && stack.getItemDamage() != 40) {
    player.getFoodStats().addStats(1, 0.2F);
    stack.damageItem(1, player);
  }
}

代码示例来源:origin: FTBTeam/FTB-Utilities

@Override
  public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
  {
    EntityPlayerMP player = CommandUtils.getSelfOrOther(sender, args, 0, FTBUtilitiesPermissions.HEAL_OTHER).getCommandPlayer(sender);
    player.setHealth(player.getMaxHealth());
    player.getFoodStats().addStats(40, 40F);
    player.extinguish();
  }
}

代码示例来源:origin: ForestryMC/ForestryMC

/**
 * DRINKS
 */
@Override
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving) {
  DrinkProperties drinkProperties = getDrinkProperties(stack);
  if (drinkProperties != null) {
    if (entityLiving instanceof EntityPlayer && !((EntityPlayer) entityLiving).capabilities.isCreativeMode) {
      EntityPlayer player = (EntityPlayer) entityLiving;
      if (!player.capabilities.isCreativeMode) {
        stack.shrink(1);
      }
      if (!worldIn.isRemote) {
        FoodStats foodStats = player.getFoodStats();
        foodStats.addStats(drinkProperties.getHealAmount(), drinkProperties.getSaturationModifier());
        worldIn.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_PLAYER_BURP, SoundCategory.PLAYERS, 0.5F, worldIn.rand.nextFloat() * 0.1F + 0.9F);
      }
      player.addStat(StatList.getObjectUseStats(this));
    }
  }
  return stack;
}

代码示例来源:origin: ForestryMC/Binnie

@Override
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving) {
  final IFluidHandler handler = stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null);
  if (handler != null && entityLiving instanceof EntityPlayer) {
    EntityPlayer entityplayer = (EntityPlayer) entityLiving;
    entityplayer.getFoodStats().addStats(this, stack);
    worldIn.playSound(null, entityplayer.posX, entityplayer.posY, entityplayer.posZ, SoundEvents.ENTITY_GENERIC_DRINK, SoundCategory.PLAYERS, 0.5F, worldIn.rand.nextFloat() * 0.1F + 0.9F);
    this.onFoodEaten(stack, worldIn, entityplayer);
    entityplayer.addStat(StatList.getObjectUseStats(this));
    handler.drain(Integer.MAX_VALUE, true);
    if (entityplayer instanceof EntityPlayerMP) {
      CriteriaTriggers.CONSUME_ITEM.trigger((EntityPlayerMP) entityplayer, stack);
    }
    return stack;
  } else {
    return super.onItemUseFinish(stack, worldIn, entityLiving);
  }
}

代码示例来源:origin: vadis365/TheErebus

@Override
public ItemStack onItemUseFinish(ItemStack stack, World world, EntityLivingBase entityLiving) {
  if (entityLiving instanceof EntityPlayer) {
    EntityPlayer player = (EntityPlayer) entityLiving;
    EnumFoodType type = EnumFoodType.values()[stack.getItemDamage()];
    player.getFoodStats().addStats(this, stack);
    SoundEvent sound = type == EnumFoodType.CABBAGE ? ModSounds.CABBAGE_FART : SoundEvents.ENTITY_PLAYER_BURP;
    float volume = type == EnumFoodType.CABBAGE ? 1 : 0.5F;
    world.playSound(null, player.getPosition(), sound, SoundCategory.PLAYERS, volume, world.rand.nextFloat() * 0.1F + 0.9F);
    onFoodEaten(stack, world, player);
    player.addStat(StatList.getObjectUseStats(this));
  }
  stack.shrink(1);
  return hasContainerItem(stack) ? getContainerItem(stack) : stack;
}

代码示例来源:origin: MatterOverdrive/MatterOverdrive-Legacy-Edition

@Override
public void onAndroidUpdate(AndroidPlayer android, int level) {
  if (android.getPlayer().getFoodStats().needFood() && isEnabled(android, level)) {
    int foodNeeded = 20 - android.getPlayer().getFoodStats().getFoodLevel();
    int extractedEnergy = android.extractEnergyRaw(foodNeeded * ENERGY_FOOD_MULTIPLY, false);
    android.getPlayer().getFoodStats().addStats(extractedEnergy / ENERGY_FOOD_MULTIPLY, 0);
  }
}

代码示例来源:origin: PrinceOfAmber/Cyclic

@SubscribeEvent
public void onEntityKill(LivingDeathEvent event) {
 if (event.getSource().getTrueSource() instanceof EntityPlayer && event.getEntity() instanceof EntityLivingBase) {
  EntityPlayer attacker = (EntityPlayer) event.getSource().getTrueSource();
  EntityLivingBase target = (EntityLivingBase) event.getEntity();
  int level = getCurrentLevelTool(attacker);
  if (level > 0) {
   // we -1  since potion level 1 is  II
   //so that means enchantment I giving poison I means this
   int restore = (int) Math.max(Math.ceil(target.getMaxHealth() / 5), 4);
   int min = level;//so if restore starts at 4 the rand will be [min,restore]
   restore = attacker.getEntityWorld().rand.nextInt(restore + 1) + min;
   if (restore > 0) {
    //hunger
    attacker.getFoodStats().addStats(restore, 0.5F);
    //hearts
    if (attacker.getHealth() < attacker.getMaxHealth()) {
     attacker.heal(restore);
     UtilParticle.spawnParticle(target.getEntityWorld(), EnumParticleTypes.HEART, attacker.getPosition().up(1));
     UtilParticle.spawnParticle(attacker.getEntityWorld(), EnumParticleTypes.HEART, attacker.getPosition().up(1));
    }
   }
  }
 }
}

代码示例来源:origin: sinkillerj/ProjectE

player.getFoodStats().addStats(2, 10);
removeEmc(stack, 64);

相关文章