aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower/net/minecraft/world/level/gameevent/GameEventDispatcher.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/level/gameevent/GameEventDispatcher.java.patch')
-rw-r--r--patch-remap/mache-vineflower/net/minecraft/world/level/gameevent/GameEventDispatcher.java.patch110
1 files changed, 110 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/level/gameevent/GameEventDispatcher.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/level/gameevent/GameEventDispatcher.java.patch
new file mode 100644
index 0000000000..7d2eaa34c0
--- /dev/null
+++ b/patch-remap/mache-vineflower/net/minecraft/world/level/gameevent/GameEventDispatcher.java.patch
@@ -0,0 +1,110 @@
+--- a/net/minecraft/world/level/gameevent/GameEventDispatcher.java
++++ b/net/minecraft/world/level/gameevent/GameEventDispatcher.java
+@@ -2,15 +2,23 @@
+
+ import java.util.ArrayList;
+ import java.util.Collections;
++import java.util.Iterator;
+ import java.util.List;
+ import net.minecraft.core.BlockPos;
+ import net.minecraft.core.SectionPos;
+ import net.minecraft.network.protocol.game.DebugPackets;
+ import net.minecraft.server.level.ServerLevel;
+-import net.minecraft.world.level.chunk.ChunkAccess;
++import net.minecraft.world.level.chunk.LevelChunk;
+ import net.minecraft.world.phys.Vec3;
++// CraftBukkit start
++import org.bukkit.Bukkit;
++import org.bukkit.craftbukkit.CraftGameEvent;
++import org.bukkit.craftbukkit.util.CraftLocation;
++import org.bukkit.event.world.GenericGameEvent;
++// CraftBukkit end
+
+ public class GameEventDispatcher {
++
+ private final ServerLevel level;
+
+ public GameEventDispatcher(ServerLevel level) {
+@@ -18,30 +26,40 @@
+ }
+
+ public void post(GameEvent event, Vec3 pos, GameEvent.Context context) {
+- int notificationRadius = event.getNotificationRadius();
+- BlockPos blockPos = BlockPos.containing(pos);
+- int i = SectionPos.blockToSectionCoord(blockPos.getX() - notificationRadius);
+- int i1 = SectionPos.blockToSectionCoord(blockPos.getY() - notificationRadius);
+- int i2 = SectionPos.blockToSectionCoord(blockPos.getZ() - notificationRadius);
+- int i3 = SectionPos.blockToSectionCoord(blockPos.getX() + notificationRadius);
+- int i4 = SectionPos.blockToSectionCoord(blockPos.getY() + notificationRadius);
+- int i5 = SectionPos.blockToSectionCoord(blockPos.getZ() + notificationRadius);
+- List<GameEvent.ListenerInfo> list = new ArrayList<>();
+- GameEventListenerRegistry.ListenerVisitor listenerVisitor = (listener, pos1) -> {
+- if (listener.getDeliveryMode() == GameEventListener.DeliveryMode.BY_DISTANCE) {
+- list.add(new GameEvent.ListenerInfo(event, pos, context, listener, pos1));
++ int i = event.getNotificationRadius();
++ BlockPos blockposition = BlockPos.containing(pos);
++ // CraftBukkit start
++ GenericGameEvent event1 = new GenericGameEvent(CraftGameEvent.minecraftToBukkit(event), CraftLocation.toBukkit(blockposition, level.getWorld()), (context.sourceEntity() == null) ? null : context.sourceEntity().getBukkitEntity(), i, !Bukkit.isPrimaryThread());
++ level.getCraftServer().getPluginManager().callEvent(event1);
++ if (event1.isCancelled()) {
++ return;
++ }
++ i = event1.getRadius();
++ // CraftBukkit end
++ int j = SectionPos.blockToSectionCoord(blockposition.getX() - i);
++ int k = SectionPos.blockToSectionCoord(blockposition.getY() - i);
++ int l = SectionPos.blockToSectionCoord(blockposition.getZ() - i);
++ int i1 = SectionPos.blockToSectionCoord(blockposition.getX() + i);
++ int j1 = SectionPos.blockToSectionCoord(blockposition.getY() + i);
++ int k1 = SectionPos.blockToSectionCoord(blockposition.getZ() + i);
++ List<GameEvent.ListenerInfo> list = new ArrayList();
++ GameEventListenerRegistry.ListenerVisitor gameeventlistenerregistry_a = (gameeventlistener, vec3d1) -> {
++ if (gameeventlistener.getDeliveryMode() == GameEventListener.a.BY_DISTANCE) {
++ list.add(new GameEvent.ListenerInfo(event, pos, context, gameeventlistener, vec3d1));
+ } else {
+- listener.handleGameEvent(this.level, event, context, pos);
++ gameeventlistener.handleGameEvent(this.level, event, context, pos);
+ }
++
+ };
+ boolean flag = false;
+
+- for (int i6 = i; i6 <= i3; i6++) {
+- for (int i7 = i2; i7 <= i5; i7++) {
+- ChunkAccess chunkNow = this.level.getChunkSource().getChunkNow(i6, i7);
+- if (chunkNow != null) {
+- for (int i8 = i1; i8 <= i4; i8++) {
+- flag |= chunkNow.getListenerRegistry(i8).visitInRangeListeners(event, pos, context, listenerVisitor);
++ for (int l1 = j; l1 <= i1; ++l1) {
++ for (int i2 = l; i2 <= k1; ++i2) {
++ LevelChunk chunk = this.level.getChunkSource().getChunkNow(l1, i2);
++
++ if (chunk != null) {
++ for (int j2 = k; j2 <= j1; ++j2) {
++ flag |= chunk.getListenerRegistry(j2).visitInRangeListeners(event, pos, context, gameeventlistenerregistry_a);
+ }
+ }
+ }
+@@ -54,14 +72,19 @@
+ if (flag) {
+ DebugPackets.sendGameEventInfo(this.level, event, pos);
+ }
++
+ }
+
+ private void handleGameEventMessagesInQueue(List<GameEvent.ListenerInfo> listenerInfos) {
+ Collections.sort(listenerInfos);
++ Iterator iterator = listenerInfos.iterator();
+
+- for (GameEvent.ListenerInfo listenerInfo : listenerInfos) {
+- GameEventListener gameEventListener = listenerInfo.recipient();
+- gameEventListener.handleGameEvent(this.level, listenerInfo.gameEvent(), listenerInfo.context(), listenerInfo.source());
++ while (iterator.hasNext()) {
++ GameEvent.ListenerInfo gameevent_b = (GameEvent.ListenerInfo) iterator.next();
++ GameEventListener gameeventlistener = gameevent_b.recipient();
++
++ gameeventlistener.handleGameEvent(this.level, gameevent_b.gameEvent(), gameevent_b.context(), gameevent_b.source());
+ }
++
+ }
+ }