9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-19 15:09:25 +00:00
Files
Leaf/leaf-server/minecraft-patches/features/0251-optimize-structure-map.patch
hayanesuru 23b7b02eee optimize chunk map (#438)
* rebase

* optimize LivingEntity#travel

* cleanup

* Replace fluid height map

* reuse array list in Entity#collide

* cleanup

* fix fire and liquid collision shape

* fix checkInside

* inline betweenClosed

* cleanup

* optimize getOnPos

* optimize equals in getOnPos

* update mainSupportingBlockPos on dirty

* cleanup

* rename

* merge same patch

* rebase and remove properly

* [ci skip] cleanup

* rebase and rebuild

* fix async locator

* remove async locator

* cleanup

* rebase

---------

Co-authored-by: Taiyou06 <kaandindar21@gmail.com>
2025-08-19 20:48:26 +02:00

47 lines
2.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: hayanesuru <hayanesuru@outlook.jp>
Date: Tue, 3 Jun 2025 15:41:12 +0900
Subject: [PATCH] optimize structure map
diff --git a/net/minecraft/world/level/chunk/ChunkAccess.java b/net/minecraft/world/level/chunk/ChunkAccess.java
index 7fc5e56586f2fe8ea1a7437b42da893383878880..585765134da9d99e994e9ac250c7c757d33b3698 100644
--- a/net/minecraft/world/level/chunk/ChunkAccess.java
+++ b/net/minecraft/world/level/chunk/ChunkAccess.java
@@ -77,8 +77,8 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh
protected BlendingData blendingData;
public final Map<Heightmap.Types, Heightmap> heightmaps = Maps.newEnumMap(Heightmap.Types.class);
// Paper - rewrite chunk system
- private final Map<Structure, StructureStart> structureStarts = Maps.newHashMap();
- private final Map<Structure, LongSet> structuresRefences = Maps.newHashMap();
+ private final Map<Structure, StructureStart> structureStarts = new it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap<>(); // Leaf - optimize structure map
+ private final Map<Structure, LongSet> structuresRefences = new it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap<>(); // Leaf - optimize structure map
protected final Map<BlockPos, CompoundTag> pendingBlockEntities = Maps.newHashMap();
public final Map<BlockPos, BlockEntity> blockEntities = new Object2ObjectOpenHashMap<>();
protected final LevelHeightAccessor levelHeightAccessor;
@@ -304,7 +304,7 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh
}
public Map<Structure, StructureStart> getAllStarts() {
- return Collections.unmodifiableMap(this.structureStarts);
+ return this.structureStarts; // Leaf - optimize structure map
}
public void setAllStarts(Map<Structure, StructureStart> structureStarts) {
@@ -320,13 +320,13 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh
@Override
public void addReferenceForStructure(Structure structure, long reference) {
- this.structuresRefences.computeIfAbsent(structure, key -> new LongOpenHashSet()).add(reference);
+ this.structuresRefences.computeIfAbsent(structure, key -> new it.unimi.dsi.fastutil.longs.LongArraySet()).add(reference); // Leaf - optimize structure map
this.markUnsaved();
}
@Override
public Map<Structure, LongSet> getAllReferences() {
- return Collections.unmodifiableMap(this.structuresRefences);
+ return this.structuresRefences; // Leaf - optimize structure map
}
@Override