From 01b1d667971bb7aa3be0805ea1f583781273e101 Mon Sep 17 00:00:00 2001 From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com> Date: Wed, 11 Jun 2025 20:05:17 +0800 Subject: [PATCH] Fix Fix some beacon event issues In 1.21.5, mojang split the `onRemove` logic in `LevelChunk#setBlockState` to 3 steps, `preRemoveSideEffects`, then remove block entity, then do `affectNeighborsAfterRemoval`. beacon deactive call event should move to step 1 instead 3, to keep ollow the original fix logic. Also always call deactive event on everytime beacon gets removed, to follow the Paper's behavior. --- ...aperPR-Fix-some-beacon-event-issues.patch} | 37 +++++++++---------- todos.md | 3 -- 2 files changed, 17 insertions(+), 23 deletions(-) rename leaf-server/minecraft-patches/features/{0173-PaperPR-Fix-some-beacon-event-issues.patch => 0172-PaperPR-Fix-some-beacon-event-issues.patch} (85%) diff --git a/leaf-server/minecraft-patches/features/0173-PaperPR-Fix-some-beacon-event-issues.patch b/leaf-server/minecraft-patches/features/0172-PaperPR-Fix-some-beacon-event-issues.patch similarity index 85% rename from leaf-server/minecraft-patches/features/0173-PaperPR-Fix-some-beacon-event-issues.patch rename to leaf-server/minecraft-patches/features/0172-PaperPR-Fix-some-beacon-event-issues.patch index d0fe3f5f..982c2005 100644 --- a/leaf-server/minecraft-patches/features/0173-PaperPR-Fix-some-beacon-event-issues.patch +++ b/leaf-server/minecraft-patches/features/0172-PaperPR-Fix-some-beacon-event-issues.patch @@ -13,27 +13,8 @@ Moves the deactivate event call into the onRemove method for the beacon block it The field I added feels a bit wrong but it works, it's to prevent the activation event being called immediately after loading, can't see any better way to differentiate between a newly placed beacon and a newly loaded one. -diff --git a/net/minecraft/world/level/block/BeaconBlock.java b/net/minecraft/world/level/block/BeaconBlock.java -index 66eee067b4ffdd72393ca813de995062be5b7a90..52b24df965202a80e409d60484cff1a288d55bbd 100644 ---- a/net/minecraft/world/level/block/BeaconBlock.java -+++ b/net/minecraft/world/level/block/BeaconBlock.java -@@ -52,4 +52,14 @@ public class BeaconBlock extends BaseEntityBlock implements BeaconBeamBlock { - - return InteractionResult.SUCCESS; - } -+ -+ // Paper start - BeaconDeactivatedEvent -+ @Override -+ protected void affectNeighborsAfterRemoval(BlockState state, net.minecraft.server.level.ServerLevel level, BlockPos pos, boolean movedByPiston) { -+ if (level.getBlockEntity(pos) instanceof BeaconBlockEntity beacon && beacon.levels > 0 && !beacon.getBeamSections().isEmpty()) { -+ org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(level, pos); -+ new io.papermc.paper.event.block.BeaconDeactivatedEvent(block).callEvent(); -+ } -+ } -+ // Paper end - } diff --git a/net/minecraft/world/level/block/entity/BeaconBlockEntity.java b/net/minecraft/world/level/block/entity/BeaconBlockEntity.java -index bc7b9d6faded66e95c38cfc5571b09c05af30deb..dc5e21981394c5607dabbc8afaa8f6097f94d90f 100644 +index bc7b9d6faded66e95c38cfc5571b09c05af30deb..0714dd9d0136dc254687fcfe3ce56b92bbfeb676 100644 --- a/net/minecraft/world/level/block/entity/BeaconBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BeaconBlockEntity.java @@ -172,6 +172,8 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name @@ -95,3 +76,19 @@ index bc7b9d6faded66e95c38cfc5571b09c05af30deb..dc5e21981394c5607dabbc8afaa8f609 this.name = parseCustomNameSafe(tag.get("CustomName"), registries); this.lockKey = LockCode.fromTag(tag, registries); this.effectRange = tag.getDoubleOr(PAPER_RANGE_TAG, -1); // Paper - Custom beacon ranges +@@ -497,4 +501,15 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name + super.setLevel(level); + this.lastCheckY = level.getMinY() - 1; + } ++ ++ // Paper start - BeaconDeactivatedEvent ++ @Override ++ public void preRemoveSideEffects(BlockPos pos, BlockState state) { ++ BeaconBlockEntity beacon = this; ++ if (true /*beacon.levels > 0 && !beacon.getBeamSections().isEmpty()*/) { // Calling deactive everytime on remove to keep consistent with Paper's behavior ++ org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(this.level, pos); ++ new io.papermc.paper.event.block.BeaconDeactivatedEvent(block).callEvent(); ++ } ++ } ++ // Paper end + } diff --git a/todos.md b/todos.md index d721eef5..6cabe23d 100644 --- a/todos.md +++ b/todos.md @@ -7,9 +7,6 @@ - [ ] Use different state to separate different configs reload # 1.21.5 -- [ ] Check beacon issues fix - [ ] Remove stream in Inventory and check new changes -- [ ] Check Purpur's Projectile offset config, in BowItem shoot -- [ ] Remove Gale's attribute patch - [ ] Check SparklyPaper's mapitem update skip - [ ] Update from Leaf 1.21.4 (curr commit: `ccab3256c296857eeacd4d0c23f2e1b8aae3b36c`)