2021-06-11 14:02:28 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2022-08-01 16:01:20 +02:00
|
|
|
From: Nassim Jahnke <nassim@njahnke.dev>
|
2021-06-11 14:02:28 +02:00
|
|
|
Date: Fri, 29 Jan 2021 15:13:11 +0100
|
2024-01-19 13:22:30 +01:00
|
|
|
Subject: [PATCH] Expand EntityUnleashEvent
|
2021-06-11 14:02:28 +02:00
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
2024-01-19 17:54:05 +01:00
|
|
|
index d330b6d291cd2967358e892ccbc480bb3bd8022d..16d84042e2575418880897c728a99d1b8bbcdd15 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
2023-12-06 04:00:14 +01:00
|
|
|
@@ -1305,12 +1305,15 @@ public abstract class Mob extends LivingEntity implements Targeting {
|
2021-06-11 14:02:28 +02:00
|
|
|
return InteractionResult.PASS;
|
|
|
|
} else if (this.getLeashHolder() == player) {
|
|
|
|
// CraftBukkit start - fire PlayerUnleashEntityEvent
|
2022-10-02 09:56:36 +02:00
|
|
|
- if (CraftEventFactory.callPlayerUnleashEntityEvent(this, player, hand).isCancelled()) {
|
2021-06-11 14:02:28 +02:00
|
|
|
+ // Paper start - drop leash variable
|
2022-10-02 09:56:36 +02:00
|
|
|
+ org.bukkit.event.player.PlayerUnleashEntityEvent event = CraftEventFactory.callPlayerUnleashEntityEvent(this, player, hand, !player.getAbilities().instabuild);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ if (event.isCancelled()) {
|
|
|
|
+ // Paper end
|
|
|
|
((ServerPlayer) player).connection.send(new ClientboundSetEntityLinkPacket(this, this.getLeashHolder()));
|
|
|
|
return InteractionResult.PASS;
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2021-06-14 21:58:32 +02:00
|
|
|
- this.dropLeash(true, !player.getAbilities().instabuild);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ this.dropLeash(true, event.isDropLeash()); // Paper - drop leash variable
|
2023-03-14 21:25:13 +01:00
|
|
|
this.gameEvent(GameEvent.ENTITY_INTERACT, player);
|
2023-06-08 02:54:54 +02:00
|
|
|
return InteractionResult.sidedSuccess(this.level().isClientSide);
|
2021-06-11 14:02:28 +02:00
|
|
|
} else {
|
2023-12-06 04:00:14 +01:00
|
|
|
@@ -1478,8 +1481,11 @@ public abstract class Mob extends LivingEntity implements Targeting {
|
2021-06-11 14:02:28 +02:00
|
|
|
|
|
|
|
if (this.leashHolder != null) {
|
|
|
|
if (!this.isAlive() || !this.leashHolder.isAlive()) {
|
2023-06-08 02:54:54 +02:00
|
|
|
- this.level().getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), (!this.isAlive()) ? UnleashReason.PLAYER_UNLEASH : UnleashReason.HOLDER_GONE)); // CraftBukkit
|
2023-12-06 04:00:14 +01:00
|
|
|
- this.dropLeash(true, !this.leashHolder.pluginRemoved);// CraftBukkit - SPIGOT-7487: Don't drop leash, when the holder was removed by a plugin
|
2021-06-11 14:02:28 +02:00
|
|
|
+ // Paper start - drop leash variable
|
2023-12-06 04:00:14 +01:00
|
|
|
+ EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), (!this.isAlive()) ? EntityUnleashEvent.UnleashReason.PLAYER_UNLEASH : EntityUnleashEvent.UnleashReason.HOLDER_GONE, !this.leashHolder.pluginRemoved);
|
2023-06-08 02:54:54 +02:00
|
|
|
+ this.level().getCraftServer().getPluginManager().callEvent(event); // CraftBukkit
|
2021-06-11 14:02:28 +02:00
|
|
|
+ this.dropLeash(true, event.isDropLeash());
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2023-12-06 04:00:14 +01:00
|
|
|
@@ -1542,8 +1548,11 @@ public abstract class Mob extends LivingEntity implements Targeting {
|
2021-06-11 14:02:28 +02:00
|
|
|
boolean flag1 = super.startRiding(entity, force);
|
|
|
|
|
|
|
|
if (flag1 && this.isLeashed()) {
|
2023-06-08 02:54:54 +02:00
|
|
|
- this.level().getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit
|
2021-06-11 14:02:28 +02:00
|
|
|
- this.dropLeash(true, true);
|
|
|
|
+ // Paper start - drop leash variable
|
2023-06-08 02:54:54 +02:00
|
|
|
+ EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.UNKNOWN, true);
|
2024-01-19 13:22:30 +01:00
|
|
|
+ if (!event.callEvent()) { return flag1; }
|
2021-06-11 14:02:28 +02:00
|
|
|
+ this.dropLeash(true, event.isDropLeash());
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
return flag1;
|
2023-12-06 04:00:14 +01:00
|
|
|
@@ -1733,8 +1742,11 @@ public abstract class Mob extends LivingEntity implements Targeting {
|
2021-06-11 14:02:28 +02:00
|
|
|
@Override
|
|
|
|
protected void removeAfterChangingDimensions() {
|
|
|
|
super.removeAfterChangingDimensions();
|
2023-06-08 02:54:54 +02:00
|
|
|
- this.level().getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit
|
2021-06-11 14:02:28 +02:00
|
|
|
- this.dropLeash(true, false);
|
|
|
|
+ // Paper start - drop leash variable
|
2023-06-08 02:54:54 +02:00
|
|
|
+ EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.UNKNOWN, false);
|
2024-01-19 17:54:05 +01:00
|
|
|
+ this.level().getCraftServer().getPluginManager().callEvent(event); // CraftBukkit
|
2021-06-11 14:02:28 +02:00
|
|
|
+ this.dropLeash(true, event.isDropLeash());
|
|
|
|
+ // Paper end
|
2021-06-14 21:58:32 +02:00
|
|
|
this.getAllSlots().forEach((itemstack) -> {
|
2023-06-08 02:54:54 +02:00
|
|
|
if (!itemstack.isEmpty()) {
|
|
|
|
itemstack.setCount(0);
|
2021-06-11 14:02:28 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/PathfinderMob.java b/src/main/java/net/minecraft/world/entity/PathfinderMob.java
|
2024-01-19 17:54:05 +01:00
|
|
|
index 452f219fde958fb4dc775cd2c56c0576c45a8045..7ed610c67fcfa200c30e13a49146907f765bc5ed 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/PathfinderMob.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/PathfinderMob.java
|
2023-09-22 07:41:27 +02:00
|
|
|
@@ -57,8 +57,11 @@ public abstract class PathfinderMob extends Mob {
|
2021-06-11 14:02:28 +02:00
|
|
|
|
|
|
|
if (this instanceof TamableAnimal && ((TamableAnimal) this).isInSittingPose()) {
|
2023-06-08 02:54:54 +02:00
|
|
|
if (f > entity.level().paperConfig().misc.maxLeashDistance) { // Paper
|
|
|
|
- this.level().getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit
|
2021-06-11 14:02:28 +02:00
|
|
|
- this.dropLeash(true, true);
|
|
|
|
+ // Paper start - drop leash variable
|
|
|
|
+ EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE, true);
|
2024-01-19 17:54:05 +01:00
|
|
|
+ if (!event.callEvent()) return;
|
2021-06-11 14:02:28 +02:00
|
|
|
+ this.dropLeash(true, event.isDropLeash());
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
2023-09-22 07:41:27 +02:00
|
|
|
@@ -66,8 +69,11 @@ public abstract class PathfinderMob extends Mob {
|
2021-06-11 14:02:28 +02:00
|
|
|
|
|
|
|
this.onLeashDistance(f);
|
2023-06-08 02:54:54 +02:00
|
|
|
if (f > entity.level().paperConfig().misc.maxLeashDistance) { // Paper
|
|
|
|
- this.level().getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit
|
2021-06-11 14:02:28 +02:00
|
|
|
- this.dropLeash(true, true);
|
|
|
|
+ // Paper start - drop leash variable
|
|
|
|
+ EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE, true);
|
2024-01-19 17:54:05 +01:00
|
|
|
+ if (!event.callEvent()) return;
|
2021-06-11 14:02:28 +02:00
|
|
|
+ this.dropLeash(true, event.isDropLeash());
|
|
|
|
+ // Paper end
|
|
|
|
this.goalSelector.disableControlFlag(Goal.Flag.MOVE);
|
|
|
|
} else if (f > 6.0F) {
|
|
|
|
double d0 = (entity.getX() - this.getX()) / (double) f;
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java b/src/main/java/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java
|
2023-06-08 02:54:54 +02:00
|
|
|
index 16784fcc853e23689a854e7dc6c03ed8182a164e..4eb97572a97a8d98af37c4223f42fc63659bc0ca 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java
|
2023-03-14 21:25:13 +01:00
|
|
|
@@ -126,11 +126,14 @@ public class LeashFenceKnotEntity extends HangingEntity {
|
|
|
|
|
|
|
|
if (entityinsentient1.isLeashed() && entityinsentient1.getLeashHolder() == this) {
|
2021-06-11 14:02:28 +02:00
|
|
|
// CraftBukkit start
|
2023-03-14 21:25:13 +01:00
|
|
|
- if (CraftEventFactory.callPlayerUnleashEntityEvent(entityinsentient1, player, hand).isCancelled()) {
|
2021-06-11 14:02:28 +02:00
|
|
|
+ // Paper start - drop leash variable
|
2023-03-14 21:25:13 +01:00
|
|
|
+ org.bukkit.event.player.PlayerUnleashEntityEvent event = CraftEventFactory.callPlayerUnleashEntityEvent(entityinsentient1, player, hand, !player.getAbilities().instabuild);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ if (event.isCancelled()) {
|
|
|
|
+ // Paper end
|
|
|
|
die = false;
|
|
|
|
continue;
|
|
|
|
}
|
2023-03-14 21:25:13 +01:00
|
|
|
- entityinsentient1.dropLeash(true, !player.getAbilities().instabuild); // false -> survival mode boolean
|
|
|
|
+ entityinsentient1.dropLeash(true, event.isDropLeash()); // false -> survival mode boolean // Paper - drop leash variable
|
2021-06-11 14:02:28 +02:00
|
|
|
// CraftBukkit end
|
2023-03-14 21:25:13 +01:00
|
|
|
flag1 = true;
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
2024-01-14 16:31:39 +01:00
|
|
|
index 3fef79f0e3b8a05b11b77802b80acc8e5c584653..2d9d6d735a13e0e0fc1f277f48c7bdb05aa3352a 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
Updated Upstream (Bukkit/CraftBukkit) (#10034)
Upstream has released updates that appear 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:
f29cb801 Separate checkstyle-suppressions file is not required
86f99bbe SPIGOT-7540, PR-946: Add ServerTickManager API
d4119585 SPIGOT-6903, PR-945: Add BlockData#getMapColor
b7a2ed41 SPIGOT-7530, PR-947: Add Player#removeResourcePack
9dd56255 SPIGOT-7527, PR-944: Add WindCharge#explode()
994a6163 Attempt upgrade of resolver libraries
CraftBukkit Changes:
b3b43a6ad Add Checkstyle check for unused imports
13fb3358e SPIGOT-7544: Scoreboard#getEntries() doesn't get entries but class names
3dda99c06 SPIGOT-7540, PR-1312: Add ServerTickManager API
2ab4508c0 SPIGOT-6903, PR-1311: Add BlockData#getMapColor
1dbdbbed4 PR-1238: Remove unnecessary sign ticking
659728d2a MC-264285, SPIGOT-7439, PR-1237: Fix unbreakable flint and steel is completely consumed while igniting creeper
e37e29ce0 Increase outdated build delay
c00438b39 SPIGOT-7530, PR-1313: Add Player#removeResourcePack
492dd80ce SPIGOT-7527, PR-1310: Add WindCharge#explode()
e11fbb9d7 Upgrade MySQL driver
9f3a0bd2a Attempt upgrade of resolver libraries
60d16d7ca PR-1306: Centralize Bukkit and Minecraft entity conversion
Spigot Changes:
06d602e7 Rebuild patches
2023-12-17 03:09:28 +01:00
|
|
|
@@ -1637,8 +1637,10 @@ public class CraftEventFactory {
|
2023-11-11 21:25:45 +01:00
|
|
|
Bukkit.getPluginManager().callEvent(new PlayerRecipeBookSettingsChangeEvent(player.getBukkitEntity(), bukkitType, open, filter));
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
|
2022-10-02 09:56:36 +02:00
|
|
|
- public static PlayerUnleashEntityEvent callPlayerUnleashEntityEvent(Mob entity, net.minecraft.world.entity.player.Player player, InteractionHand enumhand) {
|
|
|
|
- PlayerUnleashEntityEvent event = new PlayerUnleashEntityEvent(entity.getBukkitEntity(), (Player) player.getBukkitEntity(), CraftEquipmentSlot.getHand(enumhand));
|
2021-06-11 14:02:28 +02:00
|
|
|
+ // Paper start - drop leash variable
|
2022-10-02 09:56:36 +02:00
|
|
|
+ public static PlayerUnleashEntityEvent callPlayerUnleashEntityEvent(Mob entity, net.minecraft.world.entity.player.Player player, InteractionHand enumhand, boolean dropLeash) {
|
|
|
|
+ PlayerUnleashEntityEvent event = new PlayerUnleashEntityEvent(entity.getBukkitEntity(), (Player) player.getBukkitEntity(), CraftEquipmentSlot.getHand(enumhand), dropLeash);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ // Paper end
|
2023-06-08 02:54:54 +02:00
|
|
|
entity.level().getCraftServer().getPluginManager().callEvent(event);
|
2021-06-11 14:02:28 +02:00
|
|
|
return event;
|
|
|
|
}
|