Archiviert
13
0
Dieses Repository wurde am 2024-12-25 archiviert. Du kannst Dateien ansehen und es klonen, aber nicht pushen oder Issues/Pull-Requests öffnen.
Paper-Old/nms-patches/EntityLeash.patch

60 Zeilen
2.8 KiB
Diff

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/EntityLeash.java
+++ b/net/minecraft/server/EntityLeash.java
2016-02-29 22:32:46 +01:00
@@ -1,5 +1,7 @@
package net.minecraft.server;
2016-02-29 22:32:46 +01:00
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+
2016-02-29 22:32:46 +01:00
import java.util.Iterator;
import java.util.List;
2016-05-10 13:47:39 +02:00
import javax.annotation.Nullable;
@@ -74,6 +76,12 @@
while (iterator.hasNext()) {
entityinsentient = (EntityInsentient) iterator.next();
2016-02-29 22:32:46 +01:00
if (entityinsentient.isLeashed() && entityinsentient.getLeashHolder() == entityhuman) {
+ // CraftBukkit start
2016-02-29 22:32:46 +01:00
+ if (CraftEventFactory.callPlayerLeashEntityEvent(entityinsentient, this, entityhuman).isCancelled()) {
+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(entityinsentient, entityinsentient.getLeashHolder()));
+ continue;
+ }
+ // CraftBukkit end
2016-02-29 22:32:46 +01:00
entityinsentient.setLeashHolder(this, true);
flag = true;
}
2016-05-10 13:47:39 +02:00
@@ -81,8 +89,11 @@
2016-02-29 22:32:46 +01:00
}
if (!flag) {
- this.die();
- if (entityhuman.abilities.canInstantlyBuild) {
+ // CraftBukkit start - Move below
+ // this.die();
+ boolean die = true;
+ // CraftBukkit end
+ if (true || entityhuman.abilities.canInstantlyBuild) { // CraftBukkit - Process for non-creative as well
d0 = 7.0D;
2016-06-09 03:43:49 +02:00
list = this.world.a(EntityInsentient.class, new AxisAlignedBB(this.locX - 7.0D, this.locY - 7.0D, this.locZ - 7.0D, this.locX + 7.0D, this.locY + 7.0D, this.locZ + 7.0D));
2016-02-29 22:32:46 +01:00
iterator = list.iterator();
2016-05-10 13:47:39 +02:00
@@ -90,9 +101,20 @@
2016-02-29 22:32:46 +01:00
while (iterator.hasNext()) {
entityinsentient = (EntityInsentient) iterator.next();
if (entityinsentient.isLeashed() && entityinsentient.getLeashHolder() == this) {
- entityinsentient.unleash(true, false);
+ // CraftBukkit start
+ if (CraftEventFactory.callPlayerUnleashEntityEvent(entityinsentient, entityhuman).isCancelled()) {
+ die = false;
+ continue;
+ }
+ entityinsentient.unleash(true, !entityhuman.abilities.canInstantlyBuild); // false -> survival mode boolean
+ // CraftBukkit end
}
}
2016-02-29 22:32:46 +01:00
+ // CraftBukkit start
+ if (die) {
+ this.die();
+ }
+ // CraftBukkit end
}
}