From 4f3189c0a678a0c3f46b3f7b24cb082830d7f0d4 Mon Sep 17 00:00:00 2001 From: Mgazul Date: Sun, 26 Nov 2023 14:05:18 +0800 Subject: [PATCH] Fixed #2829 --- .../minecraft/net/minecraft/world/IWorld.java.patch | 9 +++------ .../dispatcher/BlockEventDispatcher.java | 12 +++++++----- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/patches/minecraft/net/minecraft/world/IWorld.java.patch b/patches/minecraft/net/minecraft/world/IWorld.java.patch index 9fcafc57f0..a1673bc5a8 100644 --- a/patches/minecraft/net/minecraft/world/IWorld.java.patch +++ b/patches/minecraft/net/minecraft/world/IWorld.java.patch @@ -8,13 +8,10 @@ import net.minecraft.world.storage.IWorldInfo; public interface IWorld extends IBiomeReader, IDayTimeReader { -@@ -52,5 +_,9 @@ - +@@ -53,4 +_,6 @@ default void func_217379_c(int p_217379_1_, BlockPos p_217379_2_, int p_217379_3_) { this.func_217378_a((PlayerEntity)null, p_217379_1_, p_217379_2_, p_217379_3_); -+ } -+ -+ default ServerWorld getMinecraftWorld() { -+ return this.getMinecraftWorld(); } ++ ++ ServerWorld getMinecraftWorld(); } diff --git a/src/main/java/com/mohistmc/eventhandler/dispatcher/BlockEventDispatcher.java b/src/main/java/com/mohistmc/eventhandler/dispatcher/BlockEventDispatcher.java index d61f225a39..9bd62b84a1 100644 --- a/src/main/java/com/mohistmc/eventhandler/dispatcher/BlockEventDispatcher.java +++ b/src/main/java/com/mohistmc/eventhandler/dispatcher/BlockEventDispatcher.java @@ -104,17 +104,19 @@ public void onMultiPlace(BlockEvent.EntityMultiPlaceEvent event) { for (BlockSnapshot snapshot : event.getReplacedBlockSnapshots()) { placedBlocks.add(CraftCustomSnapshot.fromBlockSnapshot(snapshot, true).getState()); } - CraftBlock againstBlock = CraftBlock.at(event.getWorld(), event.getPos().relative(direction.getOpposite())); + CraftBlock againstBlock = CraftBlock.at((ServerWorld)event.getWorld(), event.getPos().relative(direction.getOpposite())); ItemStack bukkitStack; if (hand == Hand.MAIN_HAND) { bukkitStack = player.getInventory().getItemInMainHand(); } else { bukkitStack = player.getInventory().getItemInOffHand(); } - BlockPlaceEvent placeEvent = new BlockMultiPlaceEvent(placedBlocks, againstBlock, bukkitStack, player, !event.isCanceled()); - placeEvent.setCancelled(event.isCanceled()); - Bukkit.getPluginManager().callEvent(placeEvent); - event.setCanceled(placeEvent.isCancelled() || !placeEvent.canBuild()); + if (placedBlocks.get(0).isPlaced()) { + BlockPlaceEvent placeEvent = new BlockMultiPlaceEvent(placedBlocks, againstBlock, bukkitStack, player, !event.isCanceled()); + placeEvent.setCancelled(event.isCanceled()); + Bukkit.getPluginManager().callEvent(placeEvent); + event.setCanceled(placeEvent.isCancelled() || !placeEvent.canBuild()); + } } } }