9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-20 07:29:24 +00:00
Files
Leaf/patches/server/0042-Fix-tracker-NPE.patch
2024-05-21 19:21:31 +08:00

46 lines
3.5 KiB
Diff

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 822604900ccfe18d8e73c746af2d3d0fc36a2734..5e95d84c37d2d36d62a0b5b3f55bf28bd40bf7ee 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -244,7 +244,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<ChunkHolder> needsChangeBroadcasting = new it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet<>();
+ public final Set<ChunkHolder> 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 e769e8d8e853b2731d85b75d273b029fd08861fa..6e19dc2d167e47ead14aba57bb2ae2fa5eb2282a 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -640,7 +640,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<ChunkHolder> copy = this.chunkMap.needsChangeBroadcasting.clone();
+ List<ChunkHolder> copy = new java.util.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 894082d9a8e2aa05f86948bfd335090f37a4ba07..679f3295d3e6cf6fa8ff535d60b39ad5fa771b5d 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
@@ -20,7 +20,7 @@ import org.slf4j.Logger;
public class AttributeMap {
private static final Logger LOGGER = LogUtils.getLogger();
private final Map<Holder<Attribute>, AttributeInstance> attributes = new Object2ObjectOpenHashMap<>();
- private final Set<AttributeInstance> dirtyAttributes = new ObjectOpenHashSet<>();
+ private final Set<AttributeInstance> dirtyAttributes = com.google.common.collect.Sets.newConcurrentHashSet(); // Leaf - Fix tracker NPE
private final AttributeSupplier supplier;
private final java.util.function.Function<Holder<Attribute>, AttributeInstance> createInstance; // Gale - Airplane - reduce entity allocations
private final net.minecraft.world.entity.LivingEntity entity; // Purpur