2020-05-06 11:48:49 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2018-08-24 16:40:14 +02: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
|
2020-11-03 03:22:15 +01:00
|
|
|
index 563340d410f76ec1df90403879b835ebd9e6b533..e99fd88118a75f36cb93d02aa7c6029bcffd5f10 100644
|
2018-08-24 16:40:14 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntitySlime.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntitySlime.java
|
2020-08-25 04:22:08 +02:00
|
|
|
@@ -5,6 +5,14 @@ import java.util.Objects;
|
|
|
|
import java.util.Optional;
|
2019-06-25 03:47:58 +02:00
|
|
|
import java.util.Random;
|
2018-10-07 18:57:52 +02:00
|
|
|
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
|
2018-12-08 11:09:55 +01:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
2020-06-25 16:09:55 +02:00
|
|
|
@@ -65,6 +73,7 @@ public class EntitySlime extends EntityInsentient implements IMonster {
|
2020-08-25 04:22:08 +02:00
|
|
|
@Override
|
|
|
|
public void saveData(NBTTagCompound nbttagcompound) {
|
2020-06-25 16:09:55 +02:00
|
|
|
super.saveData(nbttagcompound);
|
2018-08-24 16:40:14 +02:00
|
|
|
+ nbttagcompound.setBoolean("Paper.canWander", this.canWander); // Paper
|
2020-08-25 04:22:08 +02:00
|
|
|
nbttagcompound.setInt("Size", this.getSize() - 1);
|
|
|
|
nbttagcompound.setBoolean("wasOnGround", this.bp);
|
2018-08-24 16:40:14 +02:00
|
|
|
}
|
2020-08-25 04:22:08 +02:00
|
|
|
@@ -79,6 +88,11 @@ public class EntitySlime extends EntityInsentient implements IMonster {
|
2018-08-24 16:40:14 +02:00
|
|
|
|
|
|
|
this.setSize(i + 1, false);
|
2020-06-25 16:09:55 +02:00
|
|
|
super.loadData(nbttagcompound);
|
2018-09-29 22:00:55 +02: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
|
2020-08-25 04:22:08 +02:00
|
|
|
this.bp = nbttagcompound.getBoolean("wasOnGround");
|
2018-08-24 16:40:14 +02:00
|
|
|
}
|
|
|
|
|
2020-06-25 16:09:55 +02:00
|
|
|
@@ -358,7 +372,7 @@ public class EntitySlime extends EntityInsentient implements IMonster {
|
2018-08-24 16:40:14 +02:00
|
|
|
|
2019-05-05 10:33:44 +02:00
|
|
|
@Override
|
2018-08-24 16:40:14 +02:00
|
|
|
public boolean a() {
|
2019-05-05 10:33:44 +02:00
|
|
|
- return !this.a.isPassenger();
|
|
|
|
+ return !this.a.isPassenger() && this.a.canWander && new SlimeWanderEvent((Slime) this.a.getBukkitEntity()).callEvent(); // Paper
|
2018-08-24 16:40:14 +02:00
|
|
|
}
|
|
|
|
|
2019-05-05 10:33:44 +02:00
|
|
|
@Override
|
2020-06-25 16:09:55 +02:00
|
|
|
@@ -379,7 +393,7 @@ public class EntitySlime extends EntityInsentient implements IMonster {
|
2018-08-24 16:40:14 +02:00
|
|
|
|
2019-05-05 10:33:44 +02:00
|
|
|
@Override
|
2018-08-24 16:40:14 +02:00
|
|
|
public boolean a() {
|
2020-11-03 03:22:15 +01:00
|
|
|
- return (this.a.isInWater() || this.a.aQ()) && this.a.getControllerMove() instanceof EntitySlime.ControllerMoveSlime;
|
|
|
|
+ return (this.a.isInWater() || this.a.aQ()) && this.a.getControllerMove() instanceof EntitySlime.ControllerMoveSlime && this.a.canWander && new SlimeSwimEvent((Slime) this.a.getBukkitEntity()).callEvent(); // Paper
|
2018-08-24 16:40:14 +02:00
|
|
|
}
|
|
|
|
|
2019-05-05 10:33:44 +02:00
|
|
|
@Override
|
2020-06-25 16:09:55 +02:00
|
|
|
@@ -405,14 +419,18 @@ public class EntitySlime extends EntityInsentient implements IMonster {
|
2018-08-24 16:40:14 +02:00
|
|
|
|
2019-05-05 10:33:44 +02:00
|
|
|
@Override
|
2018-08-24 16:40:14 +02:00
|
|
|
public boolean a() {
|
2020-11-03 03:22:15 +01:00
|
|
|
- return this.a.getGoalTarget() == null && (this.a.onGround || this.a.isInWater() || this.a.aQ() || this.a.hasEffect(MobEffects.LEVITATION)) && this.a.getControllerMove() instanceof EntitySlime.ControllerMoveSlime;
|
|
|
|
+ return this.a.getGoalTarget() == null && (this.a.onGround || this.a.isInWater() || this.a.aQ() || this.a.hasEffect(MobEffects.LEVITATION)) && this.a.getControllerMove() instanceof EntitySlime.ControllerMoveSlime && this.a.canWander; // Paper - add canWander
|
2018-08-24 16:40:14 +02:00
|
|
|
}
|
|
|
|
|
2019-05-05 10:33:44 +02:00
|
|
|
@Override
|
2018-08-24 16:40:14 +02:00
|
|
|
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 18:57:52 +02:00
|
|
|
+ SlimeChangeDirectionEvent event = new SlimeChangeDirectionEvent((Slime) this.a.getBukkitEntity(), (float) this.a.getRandom().nextInt(360));
|
2018-08-24 16:40:14 +02:00
|
|
|
+ if (!this.a.canWander || !event.callEvent()) return;
|
|
|
|
+ this.b = event.getNewYaw();
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
((EntitySlime.ControllerMoveSlime) this.a.getControllerMove()).a(this.b, false);
|
2020-06-25 16:09:55 +02:00
|
|
|
@@ -433,7 +451,15 @@ public class EntitySlime extends EntityInsentient implements IMonster {
|
2018-08-24 16:40:14 +02:00
|
|
|
public boolean a() {
|
|
|
|
EntityLiving entityliving = this.a.getGoalTarget();
|
|
|
|
|
2019-05-05 10:33:44 +02:00
|
|
|
- return entityliving == null ? false : (!entityliving.isAlive() ? false : (entityliving instanceof EntityHuman && ((EntityHuman) entityliving).abilities.isInvulnerable ? false : this.a.getControllerMove() instanceof EntitySlime.ControllerMoveSlime));
|
2018-08-24 16:40:14 +02:00
|
|
|
+ // Paper start
|
2018-10-07 18:57:52 +02:00
|
|
|
+ if (entityliving == null || !entityliving.isAlive()) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ if (entityliving instanceof EntityHuman && ((EntityHuman) entityliving).abilities.isInvulnerable) {
|
|
|
|
+ return false;
|
2018-08-24 16:40:14 +02:00
|
|
|
+ }
|
2019-05-05 10:33:44 +02:00
|
|
|
+ return this.a.getControllerMove() instanceof EntitySlime.ControllerMoveSlime && this.a.canWander && new SlimeTargetLivingEntityEvent((Slime) this.a.getBukkitEntity(), (LivingEntity) entityliving.getBukkitEntity()).callEvent();
|
2018-08-24 16:40:14 +02:00
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
2019-05-05 10:33:44 +02:00
|
|
|
@Override
|
2020-06-25 16:09:55 +02:00
|
|
|
@@ -446,7 +472,15 @@ public class EntitySlime extends EntityInsentient implements IMonster {
|
2018-08-24 16:40:14 +02: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 18:57:52 +02:00
|
|
|
+ if (entityliving == null || !entityliving.isAlive()) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ if (entityliving instanceof EntityHuman && ((EntityHuman) entityliving).abilities.isInvulnerable) {
|
|
|
|
+ return false;
|
2018-08-24 16:40:14 +02:00
|
|
|
+ }
|
2018-10-07 18:57:52 +02:00
|
|
|
+ return --this.b > 0 && this.a.canWander && new SlimeTargetLivingEntityEvent((Slime) this.a.getBukkitEntity(), (LivingEntity) entityliving.getBukkitEntity()).callEvent();
|
2018-08-24 16:40:14 +02:00
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
2019-05-05 10:33:44 +02:00
|
|
|
@Override
|
2020-06-25 16:09:55 +02:00
|
|
|
@@ -454,6 +488,13 @@ public class EntitySlime extends EntityInsentient implements IMonster {
|
2018-10-07 18:57:52 +02:00
|
|
|
this.a.a((Entity) this.a.getGoalTarget(), 10.0F, 10.0F);
|
2020-08-25 04:22:08 +02:00
|
|
|
((EntitySlime.ControllerMoveSlime) this.a.getControllerMove()).a(this.a.yaw, this.a.eL());
|
2018-10-07 18:57:52 +02:00
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // 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 {
|
2020-06-25 16:09:55 +02:00
|
|
|
@@ -512,4 +553,15 @@ public class EntitySlime extends EntityInsentient implements IMonster {
|
2018-08-24 16:40:14 +02: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
|
2020-05-06 11:48:49 +02:00
|
|
|
index ce6ed6e890795ff2840c800a8fd56fdc618b383a..6e9f1b66dfc12491c945f87c51e81aa02424e885 100644
|
2018-08-24 16:40:14 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java
|
2019-05-06 04:58:04 +02:00
|
|
|
@@ -35,4 +35,14 @@ public class CraftSlime extends CraftMob implements Slime {
|
2018-08-24 16:40:14 +02:00
|
|
|
public EntityType getType() {
|
|
|
|
return EntityType.SLIME;
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // Paper start
|
|
|
|
+ public boolean canWander() {
|
|
|
|
+ return getHandle().canWander();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setWander(boolean canWander) {
|
|
|
|
+ getHandle().setWander(canWander);
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|