aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0723-Add-PlayerItemFrameChangeEvent.patch
diff options
context:
space:
mode:
authorbooky10 <[email protected]>2023-11-04 20:20:01 +0100
committerGitHub <[email protected]>2023-11-04 20:20:01 +0100
commitf78d7ce8ffb7e4b6fd5ee256f5e3678ea04fd807 (patch)
tree8e7abee5129e15a919630824c4f194a2811f7242 /patches/server/0723-Add-PlayerItemFrameChangeEvent.patch
parent44057da46727138e19d951b56e98ad8c25c1f869 (diff)
downloadPaper-f78d7ce8ffb7e4b6fd5ee256f5e3678ea04fd807.tar.gz
Paper-f78d7ce8ffb7e4b6fd5ee256f5e3678ea04fd807.zip
Remove "fix-curing-zombie-villager-discount" exploit option (#9895)
Diffstat (limited to 'patches/server/0723-Add-PlayerItemFrameChangeEvent.patch')
-rw-r--r--patches/server/0723-Add-PlayerItemFrameChangeEvent.patch60
1 files changed, 60 insertions, 0 deletions
diff --git a/patches/server/0723-Add-PlayerItemFrameChangeEvent.patch b/patches/server/0723-Add-PlayerItemFrameChangeEvent.patch
new file mode 100644
index 0000000000..6214bdbdef
--- /dev/null
+++ b/patches/server/0723-Add-PlayerItemFrameChangeEvent.patch
@@ -0,0 +1,60 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: SamB440 <[email protected]>
+Date: Mon, 15 Nov 2021 18:10:10 +0000
+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
+index dc999068891bfdfd4873ca939b4c4389d63f4415..a86472cce8e8fcde16d761842fe443a619f6e305 100644
+--- a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
++++ b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
+@@ -3,6 +3,7 @@ package net.minecraft.world.entity.decoration;
+ import com.mojang.logging.LogUtils;
+ import java.util.OptionalInt;
+ import javax.annotation.Nullable;
++import io.papermc.paper.event.player.PlayerItemFrameChangeEvent; // Paper
+ import net.minecraft.core.BlockPos;
+ import net.minecraft.core.Direction;
+ import net.minecraft.nbt.CompoundTag;
+@@ -190,6 +191,13 @@ public class ItemFrame extends HangingEntity {
+ return true;
+ }
+ // CraftBukkit end
++ // Paper start - call PlayerItemFrameChangeEvent
++ 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);
++ 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);
++ }
++ // Paper end
+ this.dropItem(source.getEntity(), false);
+ this.gameEvent(GameEvent.BLOCK_CHANGE, source.getEntity());
+ this.playSound(this.getRemoveItemSound(), 1.0F, 1.0F);
+@@ -456,13 +464,26 @@ public class ItemFrame extends HangingEntity {
+ }
+ }
+
+- this.setItem(itemstack);
++ // Paper start - call PlayerItemFrameChangeEvent
++ PlayerItemFrameChangeEvent event = new PlayerItemFrameChangeEvent((org.bukkit.entity.Player) player.getBukkitEntity(), (org.bukkit.entity.ItemFrame) this.getBukkitEntity(), itemstack.asBukkitCopy(), PlayerItemFrameChangeEvent.ItemFrameChangeAction.PLACE);
++ if (!event.callEvent()) {
++ return InteractionResult.FAIL;
++ }
++ this.setItem(ItemStack.fromBukkitCopy(event.getItemStack()));
++ // Paper end
+ this.gameEvent(GameEvent.BLOCK_CHANGE, player);
+ if (!player.getAbilities().instabuild) {
+ itemstack.shrink(1);
+ }
+ }
+ } else {
++ // Paper start - call PlayerItemFrameChangeEvent
++ PlayerItemFrameChangeEvent event = new PlayerItemFrameChangeEvent((org.bukkit.entity.Player) player.getBukkitEntity(), (org.bukkit.entity.ItemFrame) this.getBukkitEntity(), this.getItem().asBukkitCopy(), PlayerItemFrameChangeEvent.ItemFrameChangeAction.ROTATE);
++ if (!event.callEvent()) {
++ return InteractionResult.FAIL;
++ }
++ setItem(ItemStack.fromBukkitCopy(event.getItemStack()), false, false);
++ // Paper end
+ this.playSound(this.getRotateItemSound(), 1.0F, 1.0F);
+ this.setRotation(this.getRotation() + 1);
+ this.gameEvent(GameEvent.BLOCK_CHANGE, player);