craftbukkit/nms-patches/net/minecraft/world/level/gameevent/GameEventDispatcher.patch

32 lines
1.5 KiB
Diff
Raw Normal View History

2022-12-08 03:00:00 +11:00
--- a/net/minecraft/world/level/gameevent/GameEventDispatcher.java
+++ b/net/minecraft/world/level/gameevent/GameEventDispatcher.java
2024-04-24 01:15:00 +10:00
@@ -12,6 +12,13 @@
2022-12-08 03:00:00 +11:00
import net.minecraft.world.level.chunk.Chunk;
import net.minecraft.world.phys.Vec3D;
+// CraftBukkit start
+import org.bukkit.Bukkit;
+import org.bukkit.craftbukkit.CraftGameEvent;
+import org.bukkit.craftbukkit.util.CraftLocation;
2022-12-08 03:00:00 +11:00
+import org.bukkit.event.world.GenericGameEvent;
+// CraftBukkit end
+
public class GameEventDispatcher {
private final WorldServer level;
2024-04-24 01:15:00 +10:00
@@ -23,6 +30,14 @@
public void post(Holder<GameEvent> holder, Vec3D vec3d, GameEvent.a gameevent_a) {
int i = ((GameEvent) holder.value()).notificationRadius();
2023-03-15 03:30:00 +11:00
BlockPosition blockposition = BlockPosition.containing(vec3d);
2022-12-08 03:00:00 +11:00
+ // CraftBukkit start
2024-04-24 01:15:00 +10:00
+ GenericGameEvent event = new GenericGameEvent(CraftGameEvent.minecraftToBukkit(holder.value()), CraftLocation.toBukkit(blockposition, level.getWorld()), (gameevent_a.sourceEntity() == null) ? null : gameevent_a.sourceEntity().getBukkitEntity(), i, !Bukkit.isPrimaryThread());
2022-12-08 03:00:00 +11:00
+ level.getCraftServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ return;
+ }
+ i = event.getRadius();
+ // CraftBukkit end
int j = SectionPosition.blockToSectionCoord(blockposition.getX() - i);
int k = SectionPosition.blockToSectionCoord(blockposition.getY() - i);
int l = SectionPosition.blockToSectionCoord(blockposition.getZ() - i);