diff options
Diffstat (limited to 'patch-remap/mache-vineflower-stripped/net/minecraft/world/item/HangingEntityItem.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower-stripped/net/minecraft/world/item/HangingEntityItem.java.patch | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/world/item/HangingEntityItem.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/world/item/HangingEntityItem.java.patch new file mode 100644 index 0000000000..af58c26e59 --- /dev/null +++ b/patch-remap/mache-vineflower-stripped/net/minecraft/world/item/HangingEntityItem.java.patch @@ -0,0 +1,44 @@ +--- a/net/minecraft/world/item/HangingEntityItem.java ++++ b/net/minecraft/world/item/HangingEntityItem.java +@@ -22,6 +21,11 @@ + import net.minecraft.world.level.Level; + import net.minecraft.world.level.gameevent.GameEvent; + ++// CraftBukkit start ++import org.bukkit.entity.Player; ++import org.bukkit.event.hanging.HangingPlaceEvent; ++// CraftBukkit end ++ + public class HangingEntityItem extends Item { + private static final Component TOOLTIP_RANDOM_VARIANT = Component.translatable("painting.random").withStyle(ChatFormatting.GRAY); + private final EntityType<? extends HangingEntity> type; +@@ -65,11 +74,24 @@ + EntityType.updateCustomEntityTag(level, player, hangingEntity, tag); + } + +- if (hangingEntity.survives()) { +- if (!level.isClientSide) { +- hangingEntity.playPlacementSound(); +- level.gameEvent(player, GameEvent.ENTITY_PLACE, hangingEntity.position()); +- level.addFreshEntity(hangingEntity); ++ if (((HangingEntity) object).survives()) { ++ if (!world.isClientSide) { ++ // CraftBukkit start - fire HangingPlaceEvent ++ Player who = (context.getPlayer() == null) ? null : (Player) context.getPlayer().getBukkitEntity(); ++ org.bukkit.block.Block blockClicked = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); ++ org.bukkit.block.BlockFace blockFace = org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(enumdirection); ++ org.bukkit.inventory.EquipmentSlot hand = org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(context.getHand()); ++ ++ HangingPlaceEvent event = new HangingPlaceEvent((org.bukkit.entity.Hanging) ((HangingEntity) object).getBukkitEntity(), who, blockClicked, blockFace, hand, org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); ++ world.getCraftServer().getPluginManager().callEvent(event); ++ ++ if (event.isCancelled()) { ++ return InteractionResult.FAIL; ++ } ++ // CraftBukkit end ++ ((HangingEntity) object).playPlacementSound(); ++ world.gameEvent((Entity) entityhuman, GameEvent.ENTITY_PLACE, ((HangingEntity) object).position()); ++ world.addFreshEntity((Entity) object); + } + + itemInHand.shrink(1); |