mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-19 15:09:25 +00:00
remove clear biome cache
This commit is contained in:
@@ -6,7 +6,7 @@ Subject: [PATCH] optimise ChunkGenerator#getMobsAt
|
|||||||
inline fillStartsForStructure
|
inline fillStartsForStructure
|
||||||
|
|
||||||
diff --git a/net/minecraft/world/level/StructureManager.java b/net/minecraft/world/level/StructureManager.java
|
diff --git a/net/minecraft/world/level/StructureManager.java b/net/minecraft/world/level/StructureManager.java
|
||||||
index 8bc6a6c86cd8db53feefba7508b6031ba67e242e..0785bb41560aae7edd4a727fe2403a064c9b5d9f 100644
|
index 8bc6a6c86cd8db53feefba7508b6031ba67e242e..20a2bc31a8082afd4f758bd7e91691bbc58ba16e 100644
|
||||||
--- a/net/minecraft/world/level/StructureManager.java
|
--- a/net/minecraft/world/level/StructureManager.java
|
||||||
+++ b/net/minecraft/world/level/StructureManager.java
|
+++ b/net/minecraft/world/level/StructureManager.java
|
||||||
@@ -78,7 +78,7 @@ public class StructureManager {
|
@@ -78,7 +78,7 @@ public class StructureManager {
|
||||||
@@ -18,11 +18,22 @@ index 8bc6a6c86cd8db53feefba7508b6031ba67e242e..0785bb41560aae7edd4a727fe2403a06
|
|||||||
StructureStart startForStructure = this.getStartForStructure(
|
StructureStart startForStructure = this.getStartForStructure(
|
||||||
sectionPos, structure, this.level.getChunk(sectionPos.x(), sectionPos.z(), ChunkStatus.STRUCTURE_STARTS)
|
sectionPos, structure, this.level.getChunk(sectionPos.x(), sectionPos.z(), ChunkStatus.STRUCTURE_STARTS)
|
||||||
);
|
);
|
||||||
|
@@ -173,8 +173,8 @@ public class StructureManager {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<Structure, LongSet> getAllStructuresAt(BlockPos pos) {
|
||||||
|
- SectionPos sectionPos = SectionPos.of(pos);
|
||||||
|
- return this.level.getChunk(sectionPos.x(), sectionPos.z(), ChunkStatus.STRUCTURE_REFERENCES).getAllReferences();
|
||||||
|
+ // SectionPos sectionPos = SectionPos.of(pos); // Leaf
|
||||||
|
+ return this.level.getChunk(pos.getX() >> 4, pos.getZ() >> 4, ChunkStatus.STRUCTURE_REFERENCES).getAllReferences(); // Leaf
|
||||||
|
}
|
||||||
|
|
||||||
|
public StructureCheckResult checkStructurePresence(ChunkPos chunkPos, Structure structure, StructurePlacement placement, boolean skipKnownStructures) {
|
||||||
diff --git a/net/minecraft/world/level/chunk/ChunkGenerator.java b/net/minecraft/world/level/chunk/ChunkGenerator.java
|
diff --git a/net/minecraft/world/level/chunk/ChunkGenerator.java b/net/minecraft/world/level/chunk/ChunkGenerator.java
|
||||||
index 176adfcaa0fc458043d4bc05ead1861864b63606..9cc9ba1f008635ab713a4547ca3cdbfafcee9ffc 100644
|
index 176adfcaa0fc458043d4bc05ead1861864b63606..87df3cd0981e94c28b816eb231942499c266a8da 100644
|
||||||
--- a/net/minecraft/world/level/chunk/ChunkGenerator.java
|
--- a/net/minecraft/world/level/chunk/ChunkGenerator.java
|
||||||
+++ b/net/minecraft/world/level/chunk/ChunkGenerator.java
|
+++ b/net/minecraft/world/level/chunk/ChunkGenerator.java
|
||||||
@@ -501,18 +501,21 @@ public abstract class ChunkGenerator {
|
@@ -501,18 +501,20 @@ public abstract class ChunkGenerator {
|
||||||
Structure structure = entry.getKey();
|
Structure structure = entry.getKey();
|
||||||
StructureSpawnOverride structureSpawnOverride = structure.spawnOverrides().get(category);
|
StructureSpawnOverride structureSpawnOverride = structure.spawnOverrides().get(category);
|
||||||
if (structureSpawnOverride != null) {
|
if (structureSpawnOverride != null) {
|
||||||
@@ -35,9 +46,8 @@ index 176adfcaa0fc458043d4bc05ead1861864b63606..9cc9ba1f008635ab713a4547ca3cdbfa
|
|||||||
- mutableBoolean.setTrue();
|
- mutableBoolean.setTrue();
|
||||||
+ // Leaf start
|
+ // Leaf start
|
||||||
+ for (long l : entry.getValue()) {
|
+ for (long l : entry.getValue()) {
|
||||||
+ SectionPos sectionPos = SectionPos.of(ChunkPos.getX(l), structureManager.level.getMinSectionY(), ChunkPos.getZ(l)); // Leaf
|
|
||||||
+ StructureStart startForStructure = structureManager.getStartForStructure(
|
+ StructureStart startForStructure = structureManager.getStartForStructure(
|
||||||
+ sectionPos, structure, structureManager.level.getChunk(sectionPos.x(), sectionPos.z(), ChunkStatus.STRUCTURE_STARTS)
|
+ null, structure, structureManager.level.getChunk(ChunkPos.getX(l), ChunkPos.getZ(l), ChunkStatus.STRUCTURE_STARTS)
|
||||||
+ );
|
+ );
|
||||||
+ if (startForStructure != null && startForStructure.isValid()) {
|
+ if (startForStructure != null && startForStructure.isValid()) {
|
||||||
+ if (structureSpawnOverride.boundingBox() == StructureSpawnOverride.BoundingBoxType.PIECE
|
+ if (structureSpawnOverride.boundingBox() == StructureSpawnOverride.BoundingBoxType.PIECE
|
||||||
|
|||||||
@@ -17,18 +17,6 @@ index a26a5311f87873e0d4d26fda9cb8956a32ee81e8..9405f1f211db3fa2d313429866de454e
|
|||||||
&& (!this.structures.isPresent() || isLoaded && level.structureManager().getStructureWithPieceAt(blockPos, this.structures.get()).isValid())
|
&& (!this.structures.isPresent() || isLoaded && level.structureManager().getStructureWithPieceAt(blockPos, this.structures.get()).isValid())
|
||||||
&& (!this.smokey.isPresent() || isLoaded && this.smokey.get() == CampfireBlock.isSmokeyPos(level, blockPos))
|
&& (!this.smokey.isPresent() || isLoaded && this.smokey.get() == CampfireBlock.isSmokeyPos(level, blockPos))
|
||||||
&& (!this.light.isPresent() || this.light.get().matches(level, blockPos))
|
&& (!this.light.isPresent() || this.light.get().matches(level, blockPos))
|
||||||
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
|
|
||||||
index eb849c57992658005e0f514c6f7923f8ca43bebf..29dc898b2586868da961616524eaad824f0a24b3 100644
|
|
||||||
--- a/net/minecraft/server/level/ServerLevel.java
|
|
||||||
+++ b/net/minecraft/server/level/ServerLevel.java
|
|
||||||
@@ -899,6 +899,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
||||||
this.advanceWeatherCycle();
|
|
||||||
}
|
|
||||||
|
|
||||||
+ if (runsNormally && (random.nextInt(32) == 0)) this.getBiomeManager().clearCache(); // Leaf - cache getBiome
|
|
||||||
// Leaf start - SparklyPaper - parallel world ticking
|
|
||||||
if (!org.dreeam.leaf.config.modules.async.SparklyPaperParallelWorldTicking.enabled) {
|
|
||||||
this.moonrise$midTickTasks();
|
|
||||||
diff --git a/net/minecraft/world/level/LevelReader.java b/net/minecraft/world/level/LevelReader.java
|
diff --git a/net/minecraft/world/level/LevelReader.java b/net/minecraft/world/level/LevelReader.java
|
||||||
index 26c8c1e5598daf3550aef05b12218c47bda6618b..91b2fc5b2da6566b05fef1111665b895cadad343 100644
|
index 26c8c1e5598daf3550aef05b12218c47bda6618b..91b2fc5b2da6566b05fef1111665b895cadad343 100644
|
||||||
--- a/net/minecraft/world/level/LevelReader.java
|
--- a/net/minecraft/world/level/LevelReader.java
|
||||||
@@ -69,7 +57,7 @@ index ce2621a87dec1befb016b3437ceb2d02ed6d0b75..c0d941af10ffe8c158dab9db40c7c576
|
|||||||
|
|
||||||
public static boolean isInNetherFortressBounds(BlockPos pos, ServerLevel level, MobCategory category, StructureManager structureManager) {
|
public static boolean isInNetherFortressBounds(BlockPos pos, ServerLevel level, MobCategory category, StructureManager structureManager) {
|
||||||
diff --git a/net/minecraft/world/level/biome/BiomeManager.java b/net/minecraft/world/level/biome/BiomeManager.java
|
diff --git a/net/minecraft/world/level/biome/BiomeManager.java b/net/minecraft/world/level/biome/BiomeManager.java
|
||||||
index a48175a7ebb1788ace46395621ed78d910178a53..c9e3011ff873ace4d25727a5d82e249b8f028de0 100644
|
index a48175a7ebb1788ace46395621ed78d910178a53..4c0c74b73651cdbc98f0c8f101832e4c23fd0f8d 100644
|
||||||
--- a/net/minecraft/world/level/biome/BiomeManager.java
|
--- a/net/minecraft/world/level/biome/BiomeManager.java
|
||||||
+++ b/net/minecraft/world/level/biome/BiomeManager.java
|
+++ b/net/minecraft/world/level/biome/BiomeManager.java
|
||||||
@@ -15,6 +15,10 @@ public class BiomeManager {
|
@@ -15,6 +15,10 @@ public class BiomeManager {
|
||||||
@@ -83,14 +71,11 @@ index a48175a7ebb1788ace46395621ed78d910178a53..c9e3011ff873ace4d25727a5d82e249b
|
|||||||
|
|
||||||
public BiomeManager(BiomeManager.NoiseBiomeSource noiseBiomeSource, long biomeZoomSeed) {
|
public BiomeManager(BiomeManager.NoiseBiomeSource noiseBiomeSource, long biomeZoomSeed) {
|
||||||
this.noiseBiomeSource = noiseBiomeSource;
|
this.noiseBiomeSource = noiseBiomeSource;
|
||||||
@@ -29,6 +33,40 @@ public class BiomeManager {
|
@@ -29,6 +33,37 @@ public class BiomeManager {
|
||||||
return new BiomeManager(newSource, this.biomeZoomSeed);
|
return new BiomeManager(newSource, this.biomeZoomSeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
+ // Leaf start - cache getBiome
|
+ // Leaf start - cache getBiome
|
||||||
+ public void clearCache() {
|
|
||||||
+ java.util.Arrays.fill(this.biomeCache, null);
|
|
||||||
+ }
|
|
||||||
+ public Holder<Biome> getBiomeCached(BlockPos pos) {
|
+ public Holder<Biome> getBiomeCached(BlockPos pos) {
|
||||||
+ int xMinus2 = pos.getX() - 2;
|
+ int xMinus2 = pos.getX() - 2;
|
||||||
+ int yMinus2 = pos.getY() - 2;
|
+ int yMinus2 = pos.getY() - 2;
|
||||||
@@ -124,7 +109,7 @@ index a48175a7ebb1788ace46395621ed78d910178a53..c9e3011ff873ace4d25727a5d82e249b
|
|||||||
public Holder<Biome> getBiome(BlockPos pos) {
|
public Holder<Biome> getBiome(BlockPos pos) {
|
||||||
// Leaf start - Carpet-Fixes - Optimized getBiome method
|
// Leaf start - Carpet-Fixes - Optimized getBiome method
|
||||||
int xMinus2 = pos.getX() - 2;
|
int xMinus2 = pos.getX() - 2;
|
||||||
@@ -126,9 +164,18 @@ public class BiomeManager {
|
@@ -126,9 +161,18 @@ public class BiomeManager {
|
||||||
return Mth.square(zNoise + fiddle2) + Mth.square(yNoise + fiddle1) + Mth.square(xNoise + fiddle);
|
return Mth.square(zNoise + fiddle2) + Mth.square(yNoise + fiddle1) + Mth.square(xNoise + fiddle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user