From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com> Date: Wed, 2 Aug 2023 16:14:12 +0800 Subject: [PATCH] Fix tracker NPE diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java index e95f6053982f9637c195243ceab37061b31355b5..af1cd2916a892b4c20ca26187a801ed713325a73 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java @@ -241,7 +241,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider public final io.papermc.paper.util.player.NearbyPlayers nearbyPlayers; // Paper end // Paper start - optimise chunk tick iteration - public final it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet needsChangeBroadcasting = new it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet<>(); + public final Set needsChangeBroadcasting = Sets.newConcurrentHashSet(); // Leaf - Fix tracker NPE public final com.destroystokyo.paper.util.misc.PlayerAreaMap playerMobSpawnMap = new gg.pufferfish.pufferfish.util.AsyncPlayerAreaMap(this.pooledLinkedPlayerHashSets); // Pufferfish // Paper end - optimise chunk tick iteration diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java index 93ec0bdece165e5a5058f9a7ed2fd67dbcef2ab4..70b35ce82701454017b44e8a2fb3b45fefc6420e 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java @@ -9,6 +9,7 @@ import java.io.IOException; import java.util.Arrays; import java.util.Iterator; import java.util.List; +import java.util.ArrayList; // Leaf import java.util.Objects; import java.util.Optional; import java.util.concurrent.CompletableFuture; @@ -642,7 +643,7 @@ public class ServerChunkCache extends ChunkSource { // Paper - optimise chunk tick iteration // Paper start - optimise chunk tick iteration if (!this.chunkMap.needsChangeBroadcasting.isEmpty()) { - it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet copy = this.chunkMap.needsChangeBroadcasting.clone(); + List copy = new ArrayList<>(this.chunkMap.needsChangeBroadcasting); // Leaf - Fix tracker NPE this.chunkMap.needsChangeBroadcasting.clear(); for (ChunkHolder holder : copy) { holder.broadcastChanges(holder.getFullChunkNowUnchecked()); // LevelChunks are NEVER unloaded diff --git a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java index 7394c2d99499faaa4489a7eee1dd8b73ec08668d..d1603df4f829a7f3690970965f5549c99620db01 100644 --- a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java +++ b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java @@ -1,6 +1,7 @@ package net.minecraft.world.entity.ai.attributes; import com.google.common.collect.Multimap; +import com.google.common.collect.Sets; // Leaf import com.mojang.logging.LogUtils; import java.util.Collection; import java.util.Map; @@ -10,7 +11,6 @@ import java.util.stream.Collectors; import javax.annotation.Nullable; import it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap; -import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet; import net.minecraft.Util; import net.minecraft.core.Holder; import net.minecraft.core.registries.BuiltInRegistries; @@ -23,7 +23,7 @@ public class AttributeMap { private static final Logger LOGGER = LogUtils.getLogger(); // Gale start - Lithium - replace AI attributes with optimized collections private final Map attributes = new Reference2ReferenceOpenHashMap<>(0); - private final Set dirtyAttributes = new ReferenceOpenHashSet<>(0); + private final Set dirtyAttributes = Sets.newConcurrentHashSet(); // Leaf - Fix tracker NPE // Gale end - Lithium - replace AI attributes with optimized collections private final AttributeSupplier supplier; private final java.util.function.Function createInstance; // Gale - Airplane - reduce entity allocations