Moar
This commit is contained in:
@@ -1,11 +0,0 @@
|
||||
--- a/net/minecraft/world/level/gameevent/DynamicGameEventListener.java
|
||||
+++ b/net/minecraft/world/level/gameevent/DynamicGameEventListener.java
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
private static void ifChunkExists(LevelReader world, @Nullable SectionPos sectionPos, Consumer<GameEventListenerRegistry> dispatcherConsumer) {
|
||||
if (sectionPos != null) {
|
||||
- ChunkAccess chunkAccess = world.getChunk(sectionPos.x(), sectionPos.z(), ChunkStatus.FULL, false);
|
||||
+ ChunkAccess chunkAccess = world.getChunkIfLoadedImmediately(sectionPos.getX(), sectionPos.getZ()); // Paper - Perf: can cause sync loads while completing a chunk, resulting in deadlock
|
||||
if (chunkAccess != null) {
|
||||
dispatcherConsumer.accept(chunkAccess.getListenerRegistry(sectionPos.y()));
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
--- a/net/minecraft/world/level/gameevent/GameEvent.java
|
||||
+++ b/net/minecraft/world/level/gameevent/GameEvent.java
|
||||
@@ -85,7 +85,7 @@
|
||||
}
|
||||
|
||||
private static Holder.Reference<GameEvent> register(String id, int range) {
|
||||
- return Registry.registerForHolder(BuiltInRegistries.GAME_EVENT, ResourceLocation.withDefaultNamespace(id), new GameEvent(range));
|
||||
+ return io.papermc.paper.registry.PaperRegistryListenerManager.INSTANCE.registerForHolderWithListeners(BuiltInRegistries.GAME_EVENT, ResourceLocation.withDefaultNamespace(id), new GameEvent(range)); // Paper - run with listeners
|
||||
}
|
||||
|
||||
public static record Context(@Nullable Entity sourceEntity, @Nullable BlockState affectedState) {
|
||||
@@ -1,39 +0,0 @@
|
||||
--- a/net/minecraft/world/level/gameevent/GameEventDispatcher.java
|
||||
+++ b/net/minecraft/world/level/gameevent/GameEventDispatcher.java
|
||||
@@ -11,6 +11,12 @@
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
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 {
|
||||
|
||||
@@ -23,6 +29,14 @@
|
||||
public void post(Holder<GameEvent> event, Vec3 emitterPos, GameEvent.Context emitter) {
|
||||
int i = ((GameEvent) event.value()).notificationRadius();
|
||||
BlockPos blockposition = BlockPos.containing(emitterPos);
|
||||
+ // CraftBukkit start
|
||||
+ GenericGameEvent event1 = new GenericGameEvent(CraftGameEvent.minecraftToBukkit(event.value()), CraftLocation.toBukkit(blockposition, this.level.getWorld()), (emitter.sourceEntity() == null) ? null : emitter.sourceEntity().getBukkitEntity(), i, !Bukkit.isPrimaryThread());
|
||||
+ this.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);
|
||||
@@ -42,7 +56,7 @@
|
||||
|
||||
for (int l1 = j; l1 <= i1; ++l1) {
|
||||
for (int i2 = l; i2 <= k1; ++i2) {
|
||||
- LevelChunk chunk = this.level.getChunkSource().getChunkNow(l1, i2);
|
||||
+ LevelChunk chunk = (LevelChunk) this.level.getChunkIfLoadedImmediately(l1, i2); // Paper - Use getChunkIfLoadedImmediately
|
||||
|
||||
if (chunk != null) {
|
||||
for (int j2 = k; j2 <= j1; ++j2) {
|
||||
Reference in New Issue
Block a user