9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-22 08:29:28 +00:00
Files
Leaf/patches/server/0038-Fix-tracker-NPE.patch
2024-02-03 11:03:22 -05:00

79 lines
5.1 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 2b9968a8a3d0d66d9db5a83dcf2a44767a9fe412..da9c5d362a0bde281c95e9ebc413c51d66aaaa0f 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<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
@@ -1284,7 +1284,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
final Entity entity;
private final int range;
SectionPos lastSectionPos;
- public final Set<ServerPlayerConnection> seenBy = new it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet<>(); // Paper - Perf: optimise map impl
+ public final Set<ServerPlayerConnection> seenBy = Sets.newConcurrentHashSet(); // Paper - Perf: optimise map impl // Leaf - fix tracker NPE
public TrackedEntity(Entity entity, int i, int j, boolean flag) {
this.serverEntity = new ServerEntity(ChunkMap.this.level, entity, j, flag, this::broadcast, this.seenBy); // CraftBukkit
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index e841f12a43c4506f87b64b537a8c47bf54de5aa2..1273760f0c1dde908e2512efee2df5460e70eb42 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<ChunkHolder> copy = this.chunkMap.needsChangeBroadcasting.clone();
+ List<ChunkHolder> 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<Attribute, AttributeInstance> attributes = new Reference2ReferenceOpenHashMap<>(0);
- private final Set<AttributeInstance> dirtyAttributes = new ReferenceOpenHashSet<>(0);
+ private final Set<AttributeInstance> 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<Attribute, AttributeInstance> createInstance; // Gale - Airplane - reduce entity allocations