3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-18 12:30:06 +01:00
Paper/nms-patches/EntityLeash.patch

66 Zeilen
2.9 KiB
Diff

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/EntityLeash.java
+++ b/net/minecraft/server/EntityLeash.java
2020-06-25 02:00:00 +02:00
@@ -4,6 +4,8 @@
2016-02-29 22:32:46 +01:00
import java.util.List;
2016-05-10 13:47:39 +02:00
import javax.annotation.Nullable;
2020-06-25 02:00:00 +02:00
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class EntityLeash extends EntityHanging {
public EntityLeash(EntityTypes<? extends EntityLeash> entitytypes, World world) {
2019-12-10 23:00:00 +01:00
@@ -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);
2019-04-23 04:00:00 +02:00
+ if (valid) ((WorldServer) world).chunkCheck(this); // CraftBukkit
2018-09-26 09:19:16 +02:00
}
2019-04-23 04:00:00 +02:00
@Override
2019-12-10 23:00:00 +01:00
@@ -75,22 +78,42 @@
2016-11-17 02:41:03 +01:00
while (iterator.hasNext()) {
entityinsentient = (EntityInsentient) iterator.next();
2019-04-23 04:00:00 +02:00
if (entityinsentient.getLeashHolder() == entityhuman) {
2016-11-17 02:41:03 +01:00
+ // 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;
}
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
iterator = list.iterator();
2016-11-17 02:41:03 +01:00
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
}
}