Paper/patches/server-unmapped/0014-Allow-nerfed-mobs-to-jump-and-take-water-damage.patch
2021-06-11 14:02:28 +02:00

99 lines
5.1 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Zach Brown <zach.brown@destroystokyo.com>
Date: Tue, 1 Mar 2016 13:24:16 -0600
Subject: [PATCH] Allow nerfed mobs to jump and take water damage
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index 78948c42b13194005bdbbbc69c2b7ae0732a78c5..b41e7922dd96c3358eb849ab39982a75736e3476 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -97,4 +97,9 @@ public class PaperWorldConfig {
fishingMaxTicks = getInt("fishing-time-range.MaximumTicks", 600);
log("Fishing time ranges are between " + fishingMinTicks +" and " + fishingMaxTicks + " ticks");
}
+
+ public boolean nerfedMobsShouldJump;
+ private void nerfedMobsShouldJump() {
+ nerfedMobsShouldJump = getBoolean("spawner-nerfed-mobs-should-jump", false);
+ }
}
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 306f6c0db2333cce5dfc4bf1c09bfef05119a28b..f823763a2f7f40d0be8d058a1bd61386bcd951e6 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -1105,6 +1105,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, ne
return this.isInWater() || this.isInRain();
}
+ public final boolean isInWaterOrRainOrBubble() { return aG(); } // Paper - OBFHELPER
public boolean aG() {
return this.isInWater() || this.isInRain() || this.k();
}
diff --git a/src/main/java/net/minecraft/world/entity/EntityInsentient.java b/src/main/java/net/minecraft/world/entity/EntityInsentient.java
index dbfcdc3cc7c1dccf785f5e13634e84c5af088985..28aa0a9361e8a32763d7fe1af060f0016e8c1e50 100644
--- a/src/main/java/net/minecraft/world/entity/EntityInsentient.java
+++ b/src/main/java/net/minecraft/world/entity/EntityInsentient.java
@@ -98,6 +98,7 @@ public abstract class EntityInsentient extends EntityLiving {
private final EntityAIBodyControl c;
protected NavigationAbstract navigation;
public PathfinderGoalSelector goalSelector;
+ @Nullable public PathfinderGoalFloat goalFloat; // Paper
public PathfinderGoalSelector targetSelector;
private EntityLiving goalTarget;
private final EntitySenses bo;
@@ -784,7 +785,17 @@ public abstract class EntityInsentient extends EntityLiving {
@Override
protected final void doTick() {
++this.ticksFarFromPlayer;
- if (!this.aware) return; // CraftBukkit
+ if (!this.aware) { // Paper start - Allow nerfed mobs to jump, float and take water damage
+ if (goalFloat != null) {
+ if (goalFloat.validConditions()) goalFloat.update();
+ this.getControllerJump().jumpIfSet();
+ }
+ if ((this instanceof EntityBlaze || this instanceof EntityEnderman) && isInWaterOrRainOrBubble()) {
+ damageEntity(DamageSource.DROWN, 1.0F);
+ }
+ return;
+ }
+ // Paper end
this.world.getMethodProfiler().enter("sensing");
this.bo.a();
this.world.getMethodProfiler().exit();
diff --git a/src/main/java/net/minecraft/world/entity/ai/control/ControllerJump.java b/src/main/java/net/minecraft/world/entity/ai/control/ControllerJump.java
index 9767ac416fcd60a8a57b648dcb3f1e427bacd54d..1a9b3e0e0c090683e332dfa53708f8a62c8f14e0 100644
--- a/src/main/java/net/minecraft/world/entity/ai/control/ControllerJump.java
+++ b/src/main/java/net/minecraft/world/entity/ai/control/ControllerJump.java
@@ -15,6 +15,7 @@ public class ControllerJump {
this.a = true;
}
+ public final void jumpIfSet() { this.b(); } // Paper - OBFHELPER
public void b() {
this.b.setJumping(this.a);
this.a = false;
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/PathfinderGoalFloat.java b/src/main/java/net/minecraft/world/entity/ai/goal/PathfinderGoalFloat.java
index 8dfa1a6ade7f51e5d68b290f5376d999bb4c60ab..a6c8763139ed18fe73b2d6f6ec511e59666dc843 100644
--- a/src/main/java/net/minecraft/world/entity/ai/goal/PathfinderGoalFloat.java
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/PathfinderGoalFloat.java
@@ -11,15 +11,18 @@ public class PathfinderGoalFloat extends PathfinderGoal {
public PathfinderGoalFloat(EntityInsentient entityinsentient) {
this.a = entityinsentient;
+ if (entityinsentient.getWorld().paperConfig.nerfedMobsShouldJump) entityinsentient.goalFloat = this; // Paper
this.a(EnumSet.of(PathfinderGoal.Type.JUMP));
entityinsentient.getNavigation().d(true);
}
+ public final boolean validConditions() { return this.a(); } // Paper - OBFHELPER
@Override
public boolean a() {
return this.a.isInWater() && this.a.b((Tag) TagsFluid.WATER) > this.a.cx() || this.a.aQ();
}
+ public void update() { this.e(); } // Paper - OBFHELPER
@Override
public void e() {
if (this.a.getRandom().nextFloat() < 0.8F) {