diff options
author | Noah van der Aa <[email protected]> | 2024-09-29 23:28:48 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2024-09-29 14:28:48 -0700 |
commit | e3c8a8eef16eb2051b541cabc7419549c3e1e1f6 (patch) | |
tree | b13fac7f1a2dc493e32f1dbfec6f02e8371bc28f /patches/server | |
parent | f9c7f2a5c125e92a986f146ba859de189e26814b (diff) | |
download | Paper-e3c8a8eef16eb2051b541cabc7419549c3e1e1f6.tar.gz Paper-e3c8a8eef16eb2051b541cabc7419549c3e1e1f6.zip |
Add PlayerInsertLecternBookEvent [1.20 port] (#7305)
* Add PlayerInsertLecternBookEvent
* Rebase
Additionally, moves the event call higher up and removes the lectern
block state clone from the event.
* jSpecify
* Shrink correctly
* style fixups
* move methods
* rename param to cancel
* fix javadocs
* more javadoc fixes
* fix co-author on patch from yesterday
* last fix
---------
Co-authored-by: Mariell Hoversholm <[email protected]>
Co-authored-by: Bjarne Koll <[email protected]>
Diffstat (limited to 'patches/server')
-rw-r--r-- | patches/server/0203-Expand-Explosions-API.patch | 2 | ||||
-rw-r--r-- | patches/server/1063-Add-PlayerInsertLecternBookEvent.patch | 36 |
2 files changed, 37 insertions, 1 deletions
diff --git a/patches/server/0203-Expand-Explosions-API.patch b/patches/server/0203-Expand-Explosions-API.patch index 472715a97d..cdd9028746 100644 --- a/patches/server/0203-Expand-Explosions-API.patch +++ b/patches/server/0203-Expand-Explosions-API.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Expand Explosions API Add Entity as a Source capability, and add more API choices, and on Location. -Co-authored-by: Slqmy <[email protected]> +Co-authored-by: Esoteric Enderman <[email protected]> Co-authored-by: Bjarne Koll <[email protected]> diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java diff --git a/patches/server/1063-Add-PlayerInsertLecternBookEvent.patch b/patches/server/1063-Add-PlayerInsertLecternBookEvent.patch new file mode 100644 index 0000000000..c41a641e01 --- /dev/null +++ b/patches/server/1063-Add-PlayerInsertLecternBookEvent.patch @@ -0,0 +1,36 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Mariell Hoversholm <[email protected]> +Date: Sun, 29 Sep 2024 16:21:26 +0200 +Subject: [PATCH] Add PlayerInsertLecternBookEvent + + +diff --git a/src/main/java/net/minecraft/world/level/block/LecternBlock.java b/src/main/java/net/minecraft/world/level/block/LecternBlock.java +index ebb79907391fe3128d3d16fbe9d8cb0b22bcc9f7..3a1e2f62b297f384cc0dcfb828e523a37c703d6f 100644 +--- a/src/main/java/net/minecraft/world/level/block/LecternBlock.java ++++ b/src/main/java/net/minecraft/world/level/block/LecternBlock.java +@@ -157,7 +157,24 @@ public class LecternBlock extends BaseEntityBlock { + BlockEntity tileentity = world.getBlockEntity(pos); + + if (tileentity instanceof LecternBlockEntity tileentitylectern) { +- tileentitylectern.setBook(stack.consumeAndReturn(1, user)); ++ // Paper start - Add PlayerInsertLecternBookEvent ++ ItemStack eventSourcedBookStack = null; ++ if (user instanceof final net.minecraft.server.level.ServerPlayer serverPlayer) { ++ final io.papermc.paper.event.player.PlayerInsertLecternBookEvent event = new io.papermc.paper.event.player.PlayerInsertLecternBookEvent( ++ serverPlayer.getBukkitEntity(), ++ org.bukkit.craftbukkit.block.CraftBlock.at(world, pos), ++ org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(stack.copyWithCount(1)) ++ ); ++ if (!event.callEvent()) return; ++ eventSourcedBookStack = org.bukkit.craftbukkit.inventory.CraftItemStack.unwrap(event.getBook()); ++ } ++ if (eventSourcedBookStack == null) { ++ eventSourcedBookStack = stack.consumeAndReturn(1, user); ++ } else { ++ stack.consume(1, user); ++ } ++ tileentitylectern.setBook(eventSourcedBookStack); ++ // Paper end - Add PlayerInsertLecternBookEvent + LecternBlock.resetBookState(user, world, pos, state, true); + world.playSound((Player) null, pos, SoundEvents.BOOK_PUT, SoundSource.BLOCKS, 1.0F, 1.0F); + } |