Fix cancelling PlayerItemFrameChangeEvent (#7761)

This commit is contained in:
Jake Potrebic 2022-05-09 17:22:57 -07:00 committed by GitHub
parent 5928327f90
commit 9fd870db0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Add PlayerItemFrameChangeEvent
diff --git a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java diff --git a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
index d02f507ac58bae5d4f669dae52cc01c35651cee5..f134a2e68d50fba021b19fac4c75fb35d0e252c6 100644 index d02f507ac58bae5d4f669dae52cc01c35651cee5..a6d94e99d18cd569545981014af733ba8fdb4d31 100644
--- a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java --- a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
+++ b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java +++ b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
@@ -2,6 +2,7 @@ package net.minecraft.world.entity.decoration; @@ -2,6 +2,7 @@ package net.minecraft.world.entity.decoration;
@ -23,7 +23,7 @@ index d02f507ac58bae5d4f669dae52cc01c35651cee5..f134a2e68d50fba021b19fac4c75fb35
+ // Paper start - call PlayerItemFrameChangeEvent + // Paper start - call PlayerItemFrameChangeEvent
+ if (source.getEntity() instanceof Player player) { + if (source.getEntity() instanceof Player player) {
+ var event = new PlayerItemFrameChangeEvent((org.bukkit.entity.Player) player.getBukkitEntity(), (org.bukkit.entity.ItemFrame) this.getBukkitEntity(), this.getItem().asBukkitCopy(), PlayerItemFrameChangeEvent.ItemFrameChangeAction.REMOVE); + var event = new PlayerItemFrameChangeEvent((org.bukkit.entity.Player) player.getBukkitEntity(), (org.bukkit.entity.ItemFrame) this.getBukkitEntity(), this.getItem().asBukkitCopy(), PlayerItemFrameChangeEvent.ItemFrameChangeAction.REMOVE);
+ if (!event.callEvent()) return false; + if (!event.callEvent()) return true; // return true here because you aren't cancelling the damage, just the change
+ this.setItem(ItemStack.fromBukkitCopy(event.getItemStack()), false); + this.setItem(ItemStack.fromBukkitCopy(event.getItemStack()), false);
+ } + }
+ // Paper end + // Paper end