From 8a940ca0baaefb75acae00dff53eab0d5ea51557 Mon Sep 17 00:00:00 2001 From: Jake Potrebic <jake.m.potrebic@gmail.com> Date: Mon, 19 Aug 2024 13:43:06 -0700 Subject: [PATCH] Fix SculkBloomEvent firing for block entity loading --- .../level/block/SculkSpreader.java.patch | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/SculkSpreader.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/SculkSpreader.java.patch index ac78e04b92..a334f182c5 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/SculkSpreader.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/SculkSpreader.java.patch @@ -40,7 +40,15 @@ Logger logger = SculkSpreader.LOGGER; Objects.requireNonNull(logger); -@@ -126,7 +133,7 @@ +@@ -119,14 +126,14 @@ + int i = Math.min(list.size(), 32); + + for (int j = 0; j < i; ++j) { +- this.addCursor((SculkSpreader.ChargeCursor) list.get(j)); ++ this.addCursor((SculkSpreader.ChargeCursor) list.get(j), false); // Paper - don't fire event for block entity loading + } + } + } public void save(CompoundTag nbt) { @@ -49,12 +57,22 @@ Logger logger = SculkSpreader.LOGGER; Objects.requireNonNull(logger); -@@ -147,6 +154,19 @@ +@@ -139,14 +146,27 @@ + while (charge > 0) { + int j = Math.min(charge, 1000); - private void addCursor(SculkSpreader.ChargeCursor cursor) { +- this.addCursor(new SculkSpreader.ChargeCursor(pos, j)); ++ this.addCursor(new SculkSpreader.ChargeCursor(pos, j), true); // Paper - allow firing event for other causes + charge -= j; + } + + } + +- private void addCursor(SculkSpreader.ChargeCursor cursor) { ++ private void addCursor(SculkSpreader.ChargeCursor cursor, boolean fireEvent) { // Paper - add boolean to conditionally fire SculkBloomEvent if (this.cursors.size() < 32) { + // CraftBukkit start -+ if (!this.isWorldGeneration()) { // CraftBukkit - SPIGOT-7475: Don't call event during world generation ++ if (!this.isWorldGeneration() && fireEvent) { // CraftBukkit - SPIGOT-7475: Don't call event during world generation // Paper - add boolean to conditionally fire SculkBloomEvent + CraftBlock bukkitBlock = CraftBlock.at(this.level, cursor.pos); + SculkBloomEvent event = new SculkBloomEvent(bukkitBlock, cursor.getCharge()); + Bukkit.getPluginManager().callEvent(event);