mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-23 17:09:29 +00:00
79 lines
5.0 KiB
Diff
79 lines
5.0 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 6c3c4ec6cef581da45f6cdbb68cb74ea099a93a0..80badf34e9af7ef656f33e1bfe76208362778c3b 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
|
@@ -242,7 +242,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
|
|
|
|
@@ -1299,7 +1299,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 - optimise map impl
|
|
+ public final Set<ServerPlayerConnection> seenBy = Sets.newConcurrentHashSet(); // Paper - 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 ba0fe0786479fcfd81202a02fe8feb382986116e..e413ebfb34a10b1ca8a323a9511ed48721919cea 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
|
@@ -10,6 +10,7 @@ import java.util.Arrays;
|
|
import java.util.Collections;
|
|
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;
|
|
@@ -652,7 +653,7 @@ public class ServerChunkCache extends ChunkSource {
|
|
|
|
// 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 635037fb2a44a422b42d7c3c27cc7638c7715635..4fa17d2ba40bfd0159c182b909f9ab936e3ddf39 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
|