mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-01 04:31:58 +01:00
1cfd363d32
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: fc460d1b PR-735: Add Villager#zombify c8c8331e PR-690: Add method to read ItemStack input 62845f2f SPIGOT-6829: Add per-player world border API CraftBukkit Changes: a459f4d4 PR-1033: Add Villager#zombify d65d1430 PR-975: Add method to read ItemStack input b5559f8c SPIGOT-6990: Fix setRepairCost(0) in Anvil 6c308e1b SPIGOT-6829: Add per-player world border API Spigot Changes: 42b61526 SPIGOT-7000: Generation and /locate issues when using custom structure seeds
57 lines
3.3 KiB
Diff
57 lines
3.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: SamB440 <sam@islandearth.net>
|
|
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 d02f507ac58bae5d4f669dae52cc01c35651cee5..f134a2e68d50fba021b19fac4c75fb35d0e252c6 100644
|
|
--- a/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;
|
|
|
|
import com.mojang.logging.LogUtils;
|
|
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;
|
|
@@ -185,6 +186,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 false;
|
|
+ this.setItem(ItemStack.fromBukkitCopy(event.getItemStack()), false);
|
|
+ }
|
|
+ // Paper end
|
|
this.dropItem(source.getEntity(), false);
|
|
this.playSound(this.getRemoveItemSound(), 1.0F, 1.0F);
|
|
}
|
|
@@ -427,13 +435,22 @@ public class ItemFrame extends HangingEntity {
|
|
return InteractionResult.FAIL;
|
|
}
|
|
}
|
|
-
|
|
- this.setItem(itemstack);
|
|
+ // Paper start - call PlayerItemFrameChangeEvent
|
|
+ var 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()));
|
|
+ // this.setItem(itemstack);
|
|
+ // Paper end
|
|
if (!player.getAbilities().instabuild) {
|
|
itemstack.shrink(1);
|
|
}
|
|
}
|
|
} else {
|
|
+ // Paper start - call PlayerItemFrameChangeEvent
|
|
+ var 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);
|
|
}
|