Skip to content

Commit a5cf227

Browse files
author
Harry Bridgen
committed
Fix leash event for boats and elytra
1 parent bd74bf6 commit a5cf227

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

paper-server/patches/sources/net/minecraft/world/entity/vehicle/boat/AbstractBoat.java.patch

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,23 @@
8484
this.setDeltaMovement(this.getDeltaMovement().multiply(1.0, 0.0, 1.0));
8585
this.lastYd = 0.0;
8686
}
87-
@@ -708,12 +_,12 @@
87+
@@ -708,12 +_,20 @@
8888
}
8989

9090
@Override
9191
- public void remove(Entity.RemovalReason reason) {
9292
+ public void remove(Entity.RemovalReason reason, org.bukkit.event.entity.EntityRemoveEvent.@Nullable Cause eventCause) { // CraftBukkit - add Bukkit remove cause
9393
if (!this.level().isClientSide() && reason.shouldDestroy() && this.isLeashed()) {
94-
this.dropLeash();
94+
- this.dropLeash();
95+
+ // Paper start - Fire EntityUnleashEvent on boat destruction
96+
+ final org.bukkit.event.entity.EntityUnleashEvent event = new org.bukkit.event.entity.EntityUnleashEvent(this.getBukkitEntity(), org.bukkit.event.entity.EntityUnleashEvent.UnleashReason.HOLDER_GONE, true);
97+
+ event.callEvent();
98+
+ if (event.isDropLeash()) {
99+
+ this.dropLeash();
100+
+ } else {
101+
+ this.removeLeash();
102+
+ }
103+
+ // Paper end - Fire EntityUnleashEvent on boat destruction
95104
}
96105

97106
- super.remove(reason);

paper-server/patches/sources/net/minecraft/world/item/FireworkRocketItem.java.patch

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
}
2727

2828
return InteractionResult.SUCCESS;
29-
@@ -60,13 +_,24 @@
29+
@@ -60,13 +_,26 @@
3030
if (player.isFallFlying()) {
3131
ItemStack itemInHand = player.getItemInHand(hand);
3232
if (level instanceof ServerLevel serverLevel) {
@@ -37,9 +37,11 @@
3737
+ com.destroystokyo.paper.event.player.PlayerElytraBoostEvent event = new com.destroystokyo.paper.event.player.PlayerElytraBoostEvent((org.bukkit.entity.Player) player.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemInHand), (org.bukkit.entity.Firework) delayed.projectile().getBukkitEntity(), org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(hand));
3838
+ if (event.callEvent() && delayed.attemptSpawn()) {
3939
+ player.awardStat(Stats.ITEM_USED.get(this)); // Moved up from below
40-
+ if (player.dropAllLeashConnections(null)) {
40+
+ // Paper start - Fire EntityUnleashEvent on elytra firework boost
41+
+ if (player.dropAllLeashConnections(player, hand)) {
4142
+ level.playSound(null, player, SoundEvents.LEAD_BREAK, SoundSource.NEUTRAL, 1.0F, 1.0F);
4243
+ }
44+
+ // Paper end - Fire EntityUnleashEvent on elytra firework boost
4345
+ if (event.shouldConsume() && !player.hasInfiniteMaterials()) {
4446
+ itemInHand.shrink(1); // Moved up from below
4547
+ } else {

0 commit comments

Comments
 (0)