From 01d11db8c6662d14ec929383155d3927f197dc53 Mon Sep 17 00:00:00 2001 From: lazertester Date: Sun, 17 Aug 2014 19:56:17 +1000 Subject: [PATCH] Add Hunger Config Values diff --git a/src/main/java/net/minecraft/world/entity/player/EntityHuman.java b/src/main/java/net/minecraft/world/entity/player/EntityHuman.java index e8667f54b..8432d319e 100644 --- a/src/main/java/net/minecraft/world/entity/player/EntityHuman.java +++ b/src/main/java/net/minecraft/world/entity/player/EntityHuman.java @@ -1330,7 +1330,7 @@ public abstract class EntityHuman extends EntityLiving { } } - this.causeFoodExhaustion(0.1F, EntityExhaustionEvent.ExhaustionReason.ATTACK); // CraftBukkit - EntityExhaustionEvent + this.causeFoodExhaustion(level.spigotConfig.combatExhaustion, EntityExhaustionEvent.ExhaustionReason.ATTACK); // CraftBukkit - EntityExhaustionEvent // Spigot - Change to use configurable value } else { this.level.playSound((EntityHuman) null, this.getX(), this.getY(), this.getZ(), SoundEffects.PLAYER_ATTACK_NODAMAGE, this.getSoundSource(), 1.0F, 1.0F); if (flag4) { @@ -1503,9 +1503,9 @@ public abstract class EntityHuman extends EntityLiving { super.jumpFromGround(); this.awardStat(StatisticList.JUMP); if (this.isSprinting()) { - this.causeFoodExhaustion(0.2F, EntityExhaustionEvent.ExhaustionReason.JUMP_SPRINT); // CraftBukkit - EntityExhaustionEvent + this.causeFoodExhaustion(level.spigotConfig.jumpSprintExhaustion, EntityExhaustionEvent.ExhaustionReason.JUMP_SPRINT); // CraftBukkit - EntityExhaustionEvent // Spigot - Change to use configurable value } else { - this.causeFoodExhaustion(0.05F, EntityExhaustionEvent.ExhaustionReason.JUMP); // CraftBukkit - EntityExhaustionEvent + this.causeFoodExhaustion(level.spigotConfig.jumpWalkExhaustion, EntityExhaustionEvent.ExhaustionReason.JUMP); // CraftBukkit - EntityExhaustionEvent // Spigot - Change to use configurable value } } @@ -1578,19 +1578,19 @@ public abstract class EntityHuman extends EntityLiving { i = Math.round((float) Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F); if (i > 0) { this.awardStat(StatisticList.SWIM_ONE_CM, i); - this.causeFoodExhaustion(0.01F * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.SWIM); // CraftBukkit - EntityExhaustionEvent + this.causeFoodExhaustion(level.spigotConfig.swimMultiplier * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.SWIM); // CraftBukkit - EntityExhaustionEvent // Spigot } } else if (this.isEyeInFluid(TagsFluid.WATER)) { i = Math.round((float) Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F); if (i > 0) { this.awardStat(StatisticList.WALK_UNDER_WATER_ONE_CM, i); - this.causeFoodExhaustion(0.01F * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.WALK_UNDERWATER); // CraftBukkit - EntityExhaustionEvent + this.causeFoodExhaustion(level.spigotConfig.swimMultiplier * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.WALK_UNDERWATER); // CraftBukkit - EntityExhaustionEvent // Spigot } } else if (this.isInWater()) { i = Math.round((float) Math.sqrt(d0 * d0 + d2 * d2) * 100.0F); if (i > 0) { this.awardStat(StatisticList.WALK_ON_WATER_ONE_CM, i); - this.causeFoodExhaustion(0.01F * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.WALK_ON_WATER); // CraftBukkit - EntityExhaustionEvent + this.causeFoodExhaustion(level.spigotConfig.swimMultiplier * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.WALK_ON_WATER); // CraftBukkit - EntityExhaustionEvent // Spigot } } else if (this.onClimbable()) { if (d1 > 0.0D) { @@ -1601,13 +1601,13 @@ public abstract class EntityHuman extends EntityLiving { if (i > 0) { if (this.isSprinting()) { this.awardStat(StatisticList.SPRINT_ONE_CM, i); - this.causeFoodExhaustion(0.1F * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.SPRINT); // CraftBukkit - EntityExhaustionEvent + this.causeFoodExhaustion(level.spigotConfig.sprintMultiplier * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.SPRINT); // CraftBukkit - EntityExhaustionEvent // Spigot } else if (this.isCrouching()) { this.awardStat(StatisticList.CROUCH_ONE_CM, i); - this.causeFoodExhaustion(0.0F * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.CROUCH); // CraftBukkit - EntityExhaustionEvent + this.causeFoodExhaustion(level.spigotConfig.otherMultiplier * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.CROUCH); // CraftBukkit - EntityExhaustionEvent // Spigot } else { this.awardStat(StatisticList.WALK_ONE_CM, i); - this.causeFoodExhaustion(0.0F * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.WALK); // CraftBukkit - EntityExhaustionEvent + this.causeFoodExhaustion(level.spigotConfig.otherMultiplier * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.WALK); // CraftBukkit - EntityExhaustionEvent // Spigot } } } else if (this.isFallFlying()) { diff --git a/src/main/java/net/minecraft/world/food/FoodMetaData.java b/src/main/java/net/minecraft/world/food/FoodMetaData.java index 94531cafc..0dc5a9998 100644 --- a/src/main/java/net/minecraft/world/food/FoodMetaData.java +++ b/src/main/java/net/minecraft/world/food/FoodMetaData.java @@ -97,7 +97,7 @@ public class FoodMetaData { if (this.tickTimer >= this.unsaturatedRegenRate) { // CraftBukkit - add regen rate manipulation entityhuman.heal(1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.SATIATED); // CraftBukkit - added RegainReason // this.a(6.0F); CraftBukkit - EntityExhaustionEvent - entityhuman.causeFoodExhaustion(6.0f, org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.REGEN); // CraftBukkit - EntityExhaustionEvent + entityhuman.causeFoodExhaustion(entityhuman.level.spigotConfig.regenExhaustion, org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.REGEN); // CraftBukkit - EntityExhaustionEvent // Spigot - Change to use configurable value this.tickTimer = 0; } } else if (this.foodLevel <= 0) { diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java index 4a03e5b25..984045831 100644 --- a/src/main/java/org/spigotmc/SpigotWorldConfig.java +++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java @@ -322,4 +322,30 @@ public class SpigotWorldConfig log( "Custom Map Seeds: Village: " + villageSeed + " Desert: " + desertSeed + " Igloo: " + iglooSeed + " Jungle: " + jungleSeed + " Swamp: " + swampSeed + " Monument: " + monumentSeed + " Ocean: " + oceanSeed + " Shipwreck: " + shipwreckSeed + " End City: " + endCitySeed + " Slime: " + slimeSeed + " Bastion: " + bastionSeed + " Fortress: " + fortressSeed + " Mansion: " + mansionSeed + " Fossil: " + fossilSeed + " Portal: " + portalSeed ); } + + public float jumpWalkExhaustion; + public float jumpSprintExhaustion; + public float combatExhaustion; + public float regenExhaustion; + public float swimMultiplier; + public float sprintMultiplier; + public float otherMultiplier; + private void initHunger() + { + if ( SpigotConfig.version < 10 ) + { + set( "hunger.walk-exhaustion", null ); + set( "hunger.sprint-exhaustion", null ); + set( "hunger.combat-exhaustion", 0.1 ); + set( "hunger.regen-exhaustion", 6.0 ); + } + + jumpWalkExhaustion = (float) getDouble( "hunger.jump-walk-exhaustion", 0.05 ); + jumpSprintExhaustion = (float) getDouble( "hunger.jump-sprint-exhaustion", 0.2 ); + combatExhaustion = (float) getDouble( "hunger.combat-exhaustion", 0.1 ); + regenExhaustion = (float) getDouble( "hunger.regen-exhaustion", 6.0 ); + swimMultiplier = (float) getDouble( "hunger.swim-multiplier", 0.01 ); + sprintMultiplier = (float) getDouble( "hunger.sprint-multiplier", 0.1 ); + otherMultiplier = (float) getDouble( "hunger.other-multiplier", 0.0 ); + } } -- 2.25.1