Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-17 03:50:08 +01:00
fb25dc17c6
Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: da08d022 SPIGOT-4700: Add PlayerFishEvent.State.REEL_IN 0cef14e4 Remove draft API from selectEntities CraftBukkit Changes:a46fdbc6
Remove outdated build delay.3697519b
SPIGOT-4708: Fix ExactChoice recipes neglecting material9ead7009
SPIGOT-4677: Add minecraft.admin.command_feedback permissionc3749a23
Remove the Damage tag from items when it is 0.f74c7b95
SPIGOT-4706: Can't interact with active item494eef45
Mention requirement of JIRA ticket for bug fixes51d62dec
SPIGOT-4702: Exception when middle clicking certain slotsbe557e69
SPIGOT-4700: Add PlayerFishEvent.State.REEL_IN
169 Zeilen
6.9 KiB
Diff
169 Zeilen
6.9 KiB
Diff
From fec723b8d5ee06df01c78f30e25beba1b4d7df2d Mon Sep 17 00:00:00 2001
|
|
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
|
|
index f92bf02b87..81966542ee 100644
|
|
--- a/src/main/java/net/minecraft/server/EntitySlime.java
|
|
+++ b/src/main/java/net/minecraft/server/EntitySlime.java
|
|
@@ -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 java.util.ArrayList;
|
|
import java.util.List;
|
|
@@ -61,6 +69,7 @@ public class EntitySlime extends EntityInsentient implements IMonster {
|
|
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) {
|
|
@@ -73,6 +82,11 @@ public class EntitySlime extends EntityInsentient implements IMonster {
|
|
|
|
this.setSize(i + 1, false);
|
|
this.bD = nbttagcompound.getBoolean("wasOnGround");
|
|
+ // 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
|
|
}
|
|
|
|
public boolean dy() {
|
|
@@ -323,7 +337,7 @@ public class EntitySlime extends EntityInsentient implements IMonster {
|
|
}
|
|
|
|
public boolean a() {
|
|
- return true;
|
|
+ return this.a.canWander && new SlimeWanderEvent((Slime) this.a.getBukkitEntity()).callEvent(); // Paper
|
|
}
|
|
|
|
public void e() {
|
|
@@ -342,7 +356,7 @@ public class EntitySlime extends EntityInsentient implements IMonster {
|
|
}
|
|
|
|
public boolean a() {
|
|
- return this.a.isInWater() || this.a.ax();
|
|
+ return (this.a.isInWater() || this.a.ax()) && this.a.canWander && new SlimeSwimEvent((Slime) this.a.getBukkitEntity()).callEvent(); // Paper
|
|
}
|
|
|
|
public void e() {
|
|
@@ -366,13 +380,17 @@ public class EntitySlime extends EntityInsentient implements IMonster {
|
|
}
|
|
|
|
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
|
|
+ SlimeChangeDirectionEvent event = new SlimeChangeDirectionEvent((Slime) this.a.getBukkitEntity(), (float) this.a.getRandom().nextInt(360));
|
|
+ if (!this.a.canWander || !event.callEvent()) return;
|
|
+ this.b = event.getNewYaw();
|
|
+ // Paper end
|
|
}
|
|
|
|
((EntitySlime.ControllerMoveSlime) this.a.getControllerMove()).a(this.b, false);
|
|
@@ -392,7 +410,15 @@ public class EntitySlime extends EntityInsentient implements IMonster {
|
|
public boolean a() {
|
|
EntityLiving entityliving = this.a.getGoalTarget();
|
|
|
|
- return entityliving == null ? false : (!entityliving.isAlive() ? false : !(entityliving instanceof EntityHuman) || !((EntityHuman) entityliving).abilities.isInvulnerable);
|
|
+ // Paper start
|
|
+ if (entityliving == null || !entityliving.isAlive()) {
|
|
+ return false;
|
|
+ }
|
|
+ if (entityliving instanceof EntityHuman && ((EntityHuman) entityliving).abilities.isInvulnerable) {
|
|
+ return false;
|
|
+ }
|
|
+ return this.a.canWander && new SlimeTargetLivingEntityEvent((Slime) this.a.getBukkitEntity(), (LivingEntity) entityliving.getBukkitEntity()).callEvent();
|
|
+ // Paper end
|
|
}
|
|
|
|
public void c() {
|
|
@@ -403,13 +429,28 @@ public class EntitySlime extends EntityInsentient implements IMonster {
|
|
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
|
|
+ if (entityliving == null || !entityliving.isAlive()) {
|
|
+ return false;
|
|
+ }
|
|
+ if (entityliving instanceof EntityHuman && ((EntityHuman) entityliving).abilities.isInvulnerable) {
|
|
+ return false;
|
|
+ }
|
|
+ return --this.b > 0 && this.a.canWander && new SlimeTargetLivingEntityEvent((Slime) this.a.getBukkitEntity(), (LivingEntity) entityliving.getBukkitEntity()).callEvent();
|
|
+ // Paper end
|
|
}
|
|
|
|
public void e() {
|
|
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 {
|
|
@@ -467,4 +508,15 @@ public class EntitySlime extends EntityInsentient implements IMonster {
|
|
}
|
|
}
|
|
}
|
|
+
|
|
+ // 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
|
|
index 18e7ef80ac..8403c1e01c 100644
|
|
--- 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
|
|
}
|
|
--
|
|
2.21.0
|
|
|