本文整理了Java中net.minecraft.util.FoodStats.getFoodLevel()
方法的一些代码示例,展示了FoodStats.getFoodLevel()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FoodStats.getFoodLevel()
方法的具体详情如下:
包路径:net.minecraft.util.FoodStats
类名称:FoodStats
方法名:getFoodLevel
暂无
代码示例来源:origin: Vazkii/Botania
@Override
public void onArmorTick(World world, EntityPlayer player, ItemStack stack) {
super.onArmorTick(world, player, stack);
if(hasArmorSet(player)) {
int food = player.getFoodStats().getFoodLevel();
if(food > 0 && food < 18 && player.shouldHeal() && player.ticksExisted % 80 == 0)
player.heal(1F);
ManaItemHandler.dispatchManaExact(stack, player, 1, true);
}
}
代码示例来源:origin: WayofTime/BloodMagic
@Override
public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) {
if (!lastFoodEatenMap.containsKey(player)) {
lastFoodEatenMap.put(player, 20);
return false;
}
int currentFood = player.getFoodStats().getFoodLevel();
int prevFood = lastFoodEatenMap.get(player);
lastFoodEatenMap.put(player, currentFood);
if (currentFood > prevFood) {
foodEaten += (currentFood - prevFood);
markDirty();
return true;
}
return false;
}
代码示例来源:origin: SquidDev-CC/plethora
@Nonnull
@Override
public Map<Object, Object> getMeta(@Nonnull EntityPlayer object) {
Map<Object, Object> result = new HashMap<Object, Object>();
FoodStats stats = object.getFoodStats();
Map<String, Object> foodMap = Maps.newHashMap();
result.put("food", foodMap);
foodMap.put("hunger", stats.getFoodLevel());
foodMap.put("saturation", stats.getSaturationLevel());
foodMap.put("hungry", stats.needFood());
PlayerCapabilities capabilities = object.capabilities;
result.put("isFlying", capabilities.isFlying);
result.put("allowFlying", capabilities.allowFlying);
result.put("walkSpeed", capabilities.getWalkSpeed());
result.put("flySpeed", capabilities.getFlySpeed());
return result;
}
代码示例来源:origin: TeamLapen/Vampirism
@Override
public float getBloodLevelRelative() {
if (getLevel() == 0) {
return player.getFoodStats().getFoodLevel() / 20f; //Foodstats not synced to other clients so this is incorrect on client side
}
return bloodStats.getBloodLevel() / (float) bloodStats.getMaxBlood();
}
代码示例来源:origin: TeamWizardry/Wizardry
public boolean matches(Entity entity) {
if (x != null && entity.posX != x) return false;
if (y != null && entity.posY != y) return false;
if (z != null && entity.posZ != z) return false;
if (yaw != null && entity.rotationYaw != yaw) return false;
if (pitch != null && entity.rotationPitch != pitch) return false;
if (entity instanceof EntityLivingBase) {
EntityLivingBase living = (EntityLivingBase) entity;
if (health != null && living.getHealth() != health) return false;
if (entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) living;
if (food != null && player.getFoodStats().getFoodLevel() != food) return false;
return saturation == null || !(player.getFoodStats().getSaturationLevel() != saturation);
}
}
return true;
}
代码示例来源:origin: Zyin055/zyinhud
int bestFoodMatchIndex = -1;
float bestFoodMatchSaturation = 0;
int foodLevel = mc.thePlayer.getFoodStats().getFoodLevel(); //max 20
代码示例来源:origin: TeamWizardry/Wizardry
public EntityMoment(Entity entity) {
this(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch,
entity instanceof EntityLivingBase ? ((EntityLivingBase) entity).getHealth() : 0f,
entity instanceof EntityPlayer ? ((EntityPlayer) entity).getFoodStats().getFoodLevel() : 0,
entity instanceof EntityPlayer ? ((EntityPlayer) entity).getFoodStats().getSaturationLevel() : 0,
entity instanceof EntityPlayer ? ((Float) exhaustionGetter.invoke(((EntityPlayer) entity).getFoodStats())) : 0f);
}
代码示例来源:origin: ldtteam/minecolonies
range, cit -> !(cit.getCitizenJobHandler().getColonyJob() instanceof JobCook) && cit.getCitizenData() != null && cit.getCitizenData().getSaturation() <= CitizenConstants.AVERAGE_SATURATION);
final List<EntityPlayer> playerList = world.getEntitiesWithinAABB(EntityPlayer.class,
range, player -> player != null && player.getFoodStats().getFoodLevel() < LEVEL_TO_FEED_PLAYER);
代码示例来源:origin: WesCook/Nutrition
private void nutritionDecay(EntityPlayer player) {
// To prevent client/server conflicts, we use a unique ID that stores both the player and their side
Pair<EntityPlayer, Boolean> playerSidedID = new ImmutablePair<>(player, player.getEntityWorld().isRemote);
// Get player food levels
int foodLevelNew = player.getFoodStats().getFoodLevel(); // Current food level
Integer foodLevelOld = playerFoodLevels.get(playerSidedID); // Food level last tick
// If food level has reduced, also lower nutrition
if (foodLevelOld != null && foodLevelNew < foodLevelOld) {
int difference = foodLevelOld - foodLevelNew; // Difference in food level
// Server
Map<Nutrient, Float> playerNutrition;
if (!player.getEntityWorld().isRemote) {
playerNutrition = player.getCapability(NUTRITION_CAPABILITY, null).get();
playerNutrition = calculateDecay(playerNutrition, difference);
player.getCapability(NUTRITION_CAPABILITY, null).set(playerNutrition);
}
// Client
else {
playerNutrition = ClientProxy.localNutrition.get();
playerNutrition = calculateDecay(playerNutrition, difference);
ClientProxy.localNutrition.set(playerNutrition);
// If Nutrition GUI is open, update GUI
GuiScreen currentScreen = Minecraft.getMinecraft().currentScreen;
if (currentScreen != null && currentScreen.equals(ModGuiHandler.nutritionGui))
ModGuiHandler.nutritionGui.redrawLabels();
}
}
// Update for the next pass
playerFoodLevels.put(playerSidedID, foodLevelNew);
}
代码示例来源:origin: PenguinSquad/Harvest-Festival
@SubscribeEvent
public void onEaten(LivingEntityUseItemEvent.Finish event) {
if (event.getEntityLiving() instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.getEntityLiving();
int level = player.getFoodStats().getFoodLevel();
if (level > 2 && player.isPotionActive(EXHAUSTION)) player.removePotionEffect(EXHAUSTION);
if (level > 6 && player.isPotionActive(FATIGUE)) player.removePotionEffect(FATIGUE);
}
}
代码示例来源:origin: TeamWizardry/Wizardry
public static EntityMoment fromPreviousMoment(Entity entity, EntityMoment previous) {
if (previous == null)
return new EntityMoment(entity);
Double x, y, z;
Float yaw, pitch;
Float health = null;
Integer food = null;
Float saturation = null, exhaustion = null;
x = (previous.x == null || entity.posX != previous.x) ? entity.posX : null;
y = (previous.y == null || entity.posY != previous.y) ? entity.posY : null;
z = (previous.z == null || entity.posZ != previous.z) ? entity.posZ : null;
yaw = (previous.yaw == null || entity.rotationYaw != previous.yaw) ? entity.rotationYaw : null;
pitch = (previous.pitch == null || entity.rotationPitch != previous.pitch) ? entity.rotationPitch : null;
if (entity instanceof EntityLivingBase) {
EntityLivingBase living = (EntityLivingBase) entity;
health = (previous.health == null || living.getHealth() != previous.health) ? living.getHealth() : null;
if (entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) living;
food = (previous.food == null || player.getFoodStats().getFoodLevel() != previous.food) ? player.getFoodStats().getFoodLevel() : null;
saturation = (previous.saturation == null || player.getFoodStats().getSaturationLevel() != previous.saturation) ? player.getFoodStats().getSaturationLevel() : null;
exhaustion = (previous.exhaustion == null || exhaustionGetter.invoke(player.getFoodStats()) != previous.saturation) ? (Float) exhaustionGetter.invoke(player.getFoodStats()) : null;
}
}
return new EntityMoment(x, y, z, yaw, pitch, health, food, saturation, exhaustion);
}
代码示例来源: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: TeamLapen/Vampirism
@Override
public int onBite(IVampire biter) {
float perc = biter instanceof IVampirePlayer ? 0.2F : 0.08F;
if (getLevel() == 0) {
int amt = player.getFoodStats().getFoodLevel();
int sucked = (int) Math.ceil((amt * perc));
player.getFoodStats().setFoodLevel(amt - sucked);
player.addExhaustion(1000F);
if (!player.isPotionActive(ModPotions.sanguinare) && Helper.canTurnPlayer(biter, player) && Helper.canBecomeVampire(player)) {
PotionSanguinare.addRandom(player, true);
}
return sucked;
}
int amt = this.getBloodStats().getBloodLevel();
int sucked = (int) Math.ceil((amt * perc));
bloodStats.removeBlood(sucked, true);
sync(this.bloodStats.writeUpdate(new NBTTagCompound()), true);
return sucked;
}
代码示例来源:origin: SonarSonic/Calculator
public static ItemStack chargeHunger(ItemStack stack, World world, EntityPlayer player, String tag) {
if (!stack.hasTagCompound()) {
stack.setTagCompound(new NBTTagCompound());
}
NBTTagCompound nbtData = stack.getTagCompound();
if (nbtData == null) {
stack.getTagCompound().setInteger(tag, 0);
}
int points = stack.getTagCompound().getInteger(tag);
if (player.isSneaking()) {
int hunger = player.getFoodStats().getFoodLevel();
int usedpoints = 20 - hunger;
if (!(hunger >= 20)) {
if (points - usedpoints > 1) {
points -= usedpoints;
nbtData.setInteger(tag, points);
player.getFoodStats().addStats(20, 2.0F);
} else if (points - usedpoints < 1) {
nbtData.setInteger(tag, 0);
player.getFoodStats().addStats(points, 2.0F);
}
}
} else if (!world.isRemote) {
FontHelper.sendMessage(FontHelper.translate("points.hunger") + ": " + stack.getTagCompound().getInteger(tag), world, player);
}
return stack;
}
代码示例来源:origin: SonarSonic/Calculator
stack.getTagCompound().setInteger("ticks", 0);
int points = stack.getTagCompound().getInteger("hunger");
int hunger = player.getFoodStats().getFoodLevel();
int maxpoints = 20 - hunger;
int usedpoints = Math.min(maxpoints, 2);
代码示例来源:origin: WayofTime/BloodMagic
player.connection.sendPacket(new SPacketUpdateHealth(player.getHealth(), player.getFoodStats().getFoodLevel(), player.getFoodStats().getSaturationLevel()));
代码示例来源:origin: PenguinSquad/Harvest-Festival
@SuppressWarnings("ConstantConditions")
public static void consumeHunger(EntityPlayer player, float amount) {
if (player == null) return; //No null players allowed
int level = player.getFoodStats().getFoodLevel();
if (amount > 0F) player.getFoodStats().addExhaustion(HFTools.EXHAUSTION_AMOUNT * amount); //Add Exhaustion
if (level > 2 && level <= 6) {
代码示例来源:origin: PenguinSquad/Harvest-Festival
player.setPositionAndUpdate(spawn.getX(), spawn.getY(), spawn.getZ());
player.world.updateEntityWithOptionalForce(player, false);
player.connection.sendPacket(new SPacketUpdateHealth(player.getHealth(), player.getFoodStats().getFoodLevel(), player.getFoodStats().getSaturationLevel()));
代码示例来源:origin: cabaletta/baritone
this.hasThrowaway = Baritone.settings().allowPlace.get() && MovementHelper.throwaway(baritone.getPlayerContext(), false);
this.hasWaterBucket = Baritone.settings().allowWaterBucketFall.get() && InventoryPlayer.isHotbar(player.inventory.getSlotFor(STACK_BUCKET_WATER)) && !world.provider.isNether();
this.canSprint = Baritone.settings().allowSprint.get() && player.getFoodStats().getFoodLevel() > 6;
this.placeBlockCost = Baritone.settings().blockPlacementPenalty.get();
this.allowBreak = Baritone.settings().allowBreak.get();
代码示例来源:origin: WayofTime/BloodMagic
player.connection.sendPacket(new SPacketUpdateHealth(player.getHealth(), player.getFoodStats().getFoodLevel(), player.getFoodStats().getSaturationLevel()));
内容来源于网络,如有侵权,请联系作者删除!