Fix SculkBloomEvent firing for block entity loading

This commit is contained in:
Jake Potrebic 2024-08-19 13:43:06 -07:00
parent b724ae078d
commit 8a940ca0ba

View file

@ -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);