13
0
geforkt von Mirrors/Paper
Paper/nms-patches/EntityLeash.patch
2020-06-25 10:00:00 +10:00

66 Zeilen
2.9 KiB
Diff

--- a/net/minecraft/server/EntityLeash.java
+++ b/net/minecraft/server/EntityLeash.java
@@ -4,6 +4,8 @@
import java.util.List;
import javax.annotation.Nullable;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class EntityLeash extends EntityHanging {
public EntityLeash(EntityTypes<? extends EntityLeash> entitytypes, World world) {
@@ -29,6 +31,7 @@
@Override
protected void updateBoundingBox() {
this.setPositionRaw((double) this.blockPosition.getX() + 0.5D, (double) this.blockPosition.getY() + 0.5D, (double) this.blockPosition.getZ() + 0.5D);
+ if (valid) ((WorldServer) world).chunkCheck(this); // CraftBukkit
}
@Override
@@ -75,22 +78,42 @@
while (iterator.hasNext()) {
entityinsentient = (EntityInsentient) iterator.next();
if (entityinsentient.getLeashHolder() == entityhuman) {
+ // CraftBukkit start
+ if (CraftEventFactory.callPlayerLeashEntityEvent(entityinsentient, this, entityhuman).isCancelled()) {
+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(entityinsentient, entityinsentient.getLeashHolder()));
+ continue;
+ }
+ // CraftBukkit end
entityinsentient.setLeashHolder(this, true);
flag = true;
}
}
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
iterator = list.iterator();
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
}
}
+ // CraftBukkit start
+ if (die) {
+ this.die();
+ }
+ // CraftBukkit end
}
}