2018-10-07 16:57:52 +00:00
|
|
|
From 6110250bffd564f51fada4f6be67f4475c670555 Mon Sep 17 00:00:00 2001
|
2018-08-24 14:40:14 +00:00
|
|
|
From: BillyGalbreath <Blake.Galbreath@GMail.com>
|
|
|
|
Date: Fri, 24 Aug 2018 08:18:42 -0500
|
|
|
|
Subject: [PATCH] Slime Pathfinder Events
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntitySlime.java b/src/main/java/net/minecraft/server/EntitySlime.java
|
2018-10-07 16:57:52 +00:00
|
|
|
index 238f3c792..2737a7d69 100644
|
2018-08-24 14:40:14 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntitySlime.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntitySlime.java
|
2018-10-07 16:57:52 +00:00
|
|
|
@@ -1,6 +1,14 @@
|
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
import javax.annotation.Nullable;
|
|
|
|
+// Paper start
|
|
|
|
+import com.destroystokyo.paper.event.entity.SlimeChangeDirectionEvent;
|
|
|
|
+import com.destroystokyo.paper.event.entity.SlimeSwimEvent;
|
|
|
|
+import com.destroystokyo.paper.event.entity.SlimeTargetLivingEntityEvent;
|
|
|
|
+import com.destroystokyo.paper.event.entity.SlimeWanderEvent;
|
|
|
|
+import org.bukkit.entity.LivingEntity;
|
|
|
|
+import org.bukkit.entity.Slime;
|
|
|
|
+// Paper end
|
|
|
|
// CraftBukkit start
|
|
|
|
import org.bukkit.event.entity.SlimeSplitEvent;
|
|
|
|
// CraftBukkit end
|
|
|
|
@@ -57,6 +65,7 @@ public class EntitySlime extends EntityInsentient implements IMonster {
|
2018-08-24 14:40:14 +00:00
|
|
|
super.b(nbttagcompound);
|
|
|
|
nbttagcompound.setInt("Size", this.getSize() - 1);
|
|
|
|
nbttagcompound.setBoolean("wasOnGround", this.bD);
|
|
|
|
+ nbttagcompound.setBoolean("Paper.canWander", this.canWander); // Paper
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(NBTTagCompound nbttagcompound) {
|
2018-10-07 16:57:52 +00:00
|
|
|
@@ -69,6 +78,11 @@ public class EntitySlime extends EntityInsentient implements IMonster {
|
2018-08-24 14:40:14 +00:00
|
|
|
|
|
|
|
this.setSize(i + 1, false);
|
|
|
|
this.bD = nbttagcompound.getBoolean("wasOnGround");
|
2018-09-29 20:00:55 +00:00
|
|
|
+ // Paper start - check exists before loading or this will be loaded as false
|
|
|
|
+ if (nbttagcompound.hasKey("Paper.canWander")) {
|
|
|
|
+ this.canWander = nbttagcompound.getBoolean("Paper.canWander");
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
2018-08-24 14:40:14 +00:00
|
|
|
}
|
|
|
|
|
2018-08-26 18:11:49 +00:00
|
|
|
public boolean dy() {
|
2018-10-07 16:57:52 +00:00
|
|
|
@@ -308,7 +322,7 @@ public class EntitySlime extends EntityInsentient implements IMonster {
|
2018-08-24 14:40:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean a() {
|
|
|
|
- return true;
|
2018-10-07 16:57:52 +00:00
|
|
|
+ return this.a.canWander && new SlimeWanderEvent((Slime) this.a.getBukkitEntity()).callEvent(); // Paper
|
2018-08-24 14:40:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void e() {
|
2018-10-07 16:57:52 +00:00
|
|
|
@@ -327,7 +341,7 @@ public class EntitySlime extends EntityInsentient implements IMonster {
|
2018-08-24 14:40:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean a() {
|
|
|
|
- return this.a.isInWater() || this.a.ax();
|
2018-10-07 16:57:52 +00:00
|
|
|
+ return (this.a.isInWater() || this.a.ax()) && this.a.canWander && new SlimeSwimEvent((Slime) this.a.getBukkitEntity()).callEvent(); // Paper
|
2018-08-24 14:40:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void e() {
|
2018-10-07 16:57:52 +00:00
|
|
|
@@ -351,13 +365,17 @@ public class EntitySlime extends EntityInsentient implements IMonster {
|
2018-08-24 14:40:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean a() {
|
|
|
|
- return this.a.getGoalTarget() == null && (this.a.onGround || this.a.isInWater() || this.a.ax() || this.a.hasEffect(MobEffects.LEVITATION));
|
|
|
|
+ return this.a.canWander && this.a.getGoalTarget() == null && (this.a.onGround || this.a.isInWater() || this.a.ax() || this.a.hasEffect(MobEffects.LEVITATION)); // Paper
|
|
|
|
}
|
|
|
|
|
|
|
|
public void e() {
|
|
|
|
if (--this.c <= 0) {
|
|
|
|
this.c = 40 + this.a.getRandom().nextInt(60);
|
|
|
|
- this.b = (float) this.a.getRandom().nextInt(360);
|
|
|
|
+ // Paper start
|
2018-10-07 16:57:52 +00:00
|
|
|
+ SlimeChangeDirectionEvent event = new SlimeChangeDirectionEvent((Slime) this.a.getBukkitEntity(), (float) this.a.getRandom().nextInt(360));
|
2018-08-24 14:40:14 +00:00
|
|
|
+ if (!this.a.canWander || !event.callEvent()) return;
|
|
|
|
+ this.b = event.getNewYaw();
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
((EntitySlime.ControllerMoveSlime) this.a.getControllerMove()).a(this.b, false);
|
2018-10-07 16:57:52 +00:00
|
|
|
@@ -377,7 +395,15 @@ public class EntitySlime extends EntityInsentient implements IMonster {
|
2018-08-24 14:40:14 +00:00
|
|
|
public boolean a() {
|
|
|
|
EntityLiving entityliving = this.a.getGoalTarget();
|
|
|
|
|
|
|
|
- return entityliving == null ? false : (!entityliving.isAlive() ? false : !(entityliving instanceof EntityHuman) || !((EntityHuman) entityliving).abilities.isInvulnerable);
|
|
|
|
+ // Paper start
|
2018-10-07 16:57:52 +00:00
|
|
|
+ if (entityliving == null || !entityliving.isAlive()) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ if (entityliving instanceof EntityHuman && ((EntityHuman) entityliving).abilities.isInvulnerable) {
|
|
|
|
+ return false;
|
2018-08-24 14:40:14 +00:00
|
|
|
+ }
|
2018-10-07 16:57:52 +00:00
|
|
|
+ return this.a.canWander && new SlimeTargetLivingEntityEvent((Slime) this.a.getBukkitEntity(), (LivingEntity) entityliving.getBukkitEntity()).callEvent();
|
2018-08-24 14:40:14 +00:00
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
public void c() {
|
2018-10-07 16:57:52 +00:00
|
|
|
@@ -388,13 +414,28 @@ public class EntitySlime extends EntityInsentient implements IMonster {
|
2018-08-24 14:40:14 +00:00
|
|
|
public boolean b() {
|
|
|
|
EntityLiving entityliving = this.a.getGoalTarget();
|
|
|
|
|
|
|
|
- return entityliving == null ? false : (!entityliving.isAlive() ? false : (entityliving instanceof EntityHuman && ((EntityHuman) entityliving).abilities.isInvulnerable ? false : --this.b > 0));
|
|
|
|
+ // Paper start
|
2018-10-07 16:57:52 +00:00
|
|
|
+ if (entityliving == null || !entityliving.isAlive()) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ if (entityliving instanceof EntityHuman && ((EntityHuman) entityliving).abilities.isInvulnerable) {
|
|
|
|
+ return false;
|
2018-08-24 14:40:14 +00:00
|
|
|
+ }
|
2018-10-07 16:57:52 +00:00
|
|
|
+ return --this.b > 0 && this.a.canWander && new SlimeTargetLivingEntityEvent((Slime) this.a.getBukkitEntity(), (LivingEntity) entityliving.getBukkitEntity()).callEvent();
|
2018-08-24 14:40:14 +00:00
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
public void e() {
|
2018-10-07 16:57:52 +00:00
|
|
|
this.a.a((Entity) this.a.getGoalTarget(), 10.0F, 10.0F);
|
|
|
|
((EntitySlime.ControllerMoveSlime) this.a.getControllerMove()).a(this.a.yaw, this.a.dt());
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // Paper start - clear timer and target when goal resets
|
|
|
|
+ public void d() {
|
|
|
|
+ this.b = 0;
|
|
|
|
+ this.a.setGoalTarget(null);
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
static class ControllerMoveSlime extends ControllerMove {
|
|
|
|
@@ -452,4 +493,15 @@ public class EntitySlime extends EntityInsentient implements IMonster {
|
2018-08-24 14:40:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // Paper start
|
|
|
|
+ private boolean canWander = true;
|
|
|
|
+ public boolean canWander() {
|
|
|
|
+ return canWander;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setWander(boolean canWander) {
|
|
|
|
+ this.canWander = canWander;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java
|
2018-10-07 16:57:52 +00:00
|
|
|
index 18e7ef80a..8403c1e01 100644
|
2018-08-24 14:40:14 +00:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java
|
|
|
|
@@ -33,4 +33,14 @@ public class CraftSlime extends CraftMob implements Slime {
|
|
|
|
public EntityType getType() {
|
|
|
|
return EntityType.SLIME;
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // Paper start
|
|
|
|
+ public boolean canWander() {
|
|
|
|
+ return getHandle().canWander();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setWander(boolean canWander) {
|
|
|
|
+ getHandle().setWander(canWander);
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
--
|
2018-09-27 02:35:42 +00:00
|
|
|
2.19.0
|
2018-08-24 14:40:14 +00:00
|
|
|
|