spigot/CraftBukkit-Patches/0118-Add-Hunger-Config-Values.patch

115 lines
5.8 KiB
Diff

From 95b24a3ed0972ffa722b83f81bb4f34c37c40b7e Mon Sep 17 00:00:00 2001
From: lazertester <austin.techhead@gmail.com>
Date: Sun, 17 Aug 2014 19:56:17 +1000
Subject: [PATCH] Add Hunger Config Values
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
index e516d37bb..c374efd79 100644
--- a/src/main/java/net/minecraft/server/EntityHuman.java
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
@@ -1126,7 +1126,7 @@ public abstract class EntityHuman extends EntityLiving {
}
}
- this.applyExhaustion(0.1F);
+ this.applyExhaustion(world.spigotConfig.combatExhaustion); // Spigot - Change to use configurable value
} else {
this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.fx, this.bK(), 1.0F, 1.0F);
if (flag4) {
@@ -1396,9 +1396,9 @@ public abstract class EntityHuman extends EntityLiving {
super.cu();
this.b(StatisticList.w);
if (this.isSprinting()) {
- this.applyExhaustion(0.2F);
+ this.applyExhaustion(world.spigotConfig.jumpSprintExhaustion); // Spigot - Change to use configurable value
} else {
- this.applyExhaustion(0.05F);
+ this.applyExhaustion(world.spigotConfig.jumpWalkExhaustion); // Spigot - Change to use configurable value
}
}
@@ -1441,13 +1441,13 @@ public abstract class EntityHuman extends EntityLiving {
i = Math.round(MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F);
if (i > 0) {
this.a(StatisticList.q, i);
- this.applyExhaustion(0.01F * (float) i * 0.01F);
+ this.applyExhaustion(world.spigotConfig.swimMultiplier * (float) i * 0.01F); // Spigot
}
} else if (this.isInWater()) {
i = Math.round(MathHelper.sqrt(d0 * d0 + d2 * d2) * 100.0F);
if (i > 0) {
this.a(StatisticList.m, i);
- this.applyExhaustion(0.01F * (float) i * 0.01F);
+ this.applyExhaustion(world.spigotConfig.swimMultiplier * (float) i * 0.01F); // Spigot
}
} else if (this.m_()) {
if (d1 > 0.0D) {
@@ -1458,13 +1458,13 @@ public abstract class EntityHuman extends EntityLiving {
if (i > 0) {
if (this.isSprinting()) {
this.a(StatisticList.l, i);
- this.applyExhaustion(0.1F * (float) i * 0.01F);
+ this.applyExhaustion(world.spigotConfig.sprintMultiplier * (float) i * 0.01F); // Spigot
} else if (this.isSneaking()) {
this.a(StatisticList.k, i);
- this.applyExhaustion(0.0F * (float) i * 0.01F);
+ this.applyExhaustion(world.spigotConfig.otherMultiplier * (float) i * 0.01F); // Spigot
} else {
this.a(StatisticList.j, i);
- this.applyExhaustion(0.0F * (float) i * 0.01F);
+ this.applyExhaustion(world.spigotConfig.otherMultiplier * (float) i * 0.01F); // Spigot
}
}
} else if (this.cP()) {
diff --git a/src/main/java/net/minecraft/server/FoodMetaData.java b/src/main/java/net/minecraft/server/FoodMetaData.java
index 33a2df5d3..d42db9b45 100644
--- a/src/main/java/net/minecraft/server/FoodMetaData.java
+++ b/src/main/java/net/minecraft/server/FoodMetaData.java
@@ -73,7 +73,7 @@ public class FoodMetaData {
++this.foodTickTimer;
if (this.foodTickTimer >= 80) {
entityhuman.heal(1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.SATIATED); // CraftBukkit - added RegainReason
- this.a(6.0F);
+ this.a(entityhuman.world.spigotConfig.regenExhaustion); // Spigot - Change to use configurable value
this.foodTickTimer = 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 5b1dc38ff..715ceefc1 100644
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
@@ -254,4 +254,30 @@ public class SpigotWorldConfig
slimeSeed = getInt( "seed-slime", 987234911 );
log( "Custom Map Seeds: Village: " + villageSeed + " Feature: " + largeFeatureSeed + " Monument: " + monumentSeed + " Slime: " + slimeSeed );
}
+
+ 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.14.1