mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2024-11-22 10:35:42 +01:00
c2fd399caf
* add config for sand duping (#352)
* Lithium: cache chunk gen sea level (#349)
based off: a55cfd1c91
* PaperPR: Inline shift fields in EnumDirection (#350)
* Introducing: Yatoclip (#360)
* New async nbt cache (#347)
* update pom
* whoops
* Try to address path issue and improve Jenkins build speed
* Detailed lag and crash reports (#369)
Added "Suspected Plugins" to Watchdog and crash reports
* Drop sand duping
* Add branch specific versions
* Remove copyright
* Revert mysql-connector-java version bump
* Small fixes
* More detailed lag and crash reports
* Don't use branch information when generating metadata
* Fix Jenkins Builds version command
* Fixup patches
* Fix patch notes
* Pull Request compatibility for branch detection
* Fix Pull Request compatibility for branch detection
* Set context classloader before launch
* Inject server jar to SystemClassLoader before launch
* Try fix compile in java8
* Run tests on CodeMC and Github Actions
Co-authored-by: Simon Gardling <Titaniumtown@gmail.com>
Co-authored-by: Zoe <duplexsys@protonmail.com>
Co-authored-by: Hugo Planque <12386279+HookWoods@users.noreply.github.com>
53 lines
3.2 KiB
Diff
53 lines
3.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: SuperCoder7979 <25208576+SuperCoder7979@users.noreply.github.com>
|
|
Date: Fri, 22 Jan 2021 16:38:19 -0500
|
|
Subject: [PATCH] lithium: cache chunk gen sea level
|
|
|
|
Chunk generator settings are passed to the noise chunk generator through a supplier, which retrieves a given chunk generator settings registry key from the registry. The problem arises as this setting is retrieved from the supplier to get the sea level, which is called every single time a block is placed by the generator, for a total of 65536 registry lookups per chunk. As you can imagine this isn't all that fast and removing it speeds up the chunk generation time by a moderate amount (13% of CPU time spent in populateNoise without the patch vs 10% with the patch). My solution to this was to stick the supplier into a Lazy<> so it's computed once and then cached, but I'm open to suggestions. (The sea level can't be computed ahead of time due to a quirk in the new registry system, which would have been the best option here.)
|
|
|
|
This code was originally made by SuperCoder7979 in a Pull Request to lithium (https://github.com/jellysquid3/lithium-fabric/pull/179)
|
|
|
|
This code was orignally licensed under the LGPL-3.0 license.
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/ChunkGeneratorAbstract.java b/src/main/java/net/minecraft/server/ChunkGeneratorAbstract.java
|
|
index fa60285c0c48147ad09b9197bfe577f504dd34bd..de469f9b4f0fecc05dca7a5aacd1308db6f80a18 100644
|
|
--- a/src/main/java/net/minecraft/server/ChunkGeneratorAbstract.java
|
|
+++ b/src/main/java/net/minecraft/server/ChunkGeneratorAbstract.java
|
|
@@ -17,6 +17,7 @@ import javax.annotation.Nullable;
|
|
|
|
public final class ChunkGeneratorAbstract extends ChunkGenerator {
|
|
|
|
+ private int cachedSeaLevel; // Yatopia - lithium cache chunk gen settings
|
|
public static final Codec<ChunkGeneratorAbstract> d = RecordCodecBuilder.create((instance) -> {
|
|
return instance.group(WorldChunkManager.a.fieldOf("biome_source").forGetter((chunkgeneratorabstract) -> {
|
|
return chunkgeneratorabstract.b;
|
|
@@ -101,6 +102,7 @@ public final class ChunkGeneratorAbstract extends ChunkGenerator {
|
|
} else {
|
|
this.v = null;
|
|
}
|
|
+ this.cachedSeaLevel = ((GeneratorSettingBase) this.h.get()).g(); // Yatopia - lithium cache chunk gen settings
|
|
|
|
}
|
|
|
|
@@ -688,10 +690,18 @@ public final class ChunkGeneratorAbstract extends ChunkGenerator {
|
|
return this.x;
|
|
}
|
|
|
|
+ // Yatopia start - lithium cache chunk gen settings
|
|
+ /**
|
|
+ * Use cached sea level instead of retrieving from the registry every time.
|
|
+ * This method is called for every block in the chunk so this will save a lot of registry lookups.
|
|
+ *
|
|
+ * @author SuperCoder79
|
|
+ */
|
|
@Override
|
|
- public int getSeaLevel() {
|
|
- return ((GeneratorSettingBase) this.h.get()).g();
|
|
+ public int getSeaLevel() { // Cached method of getting sealevel
|
|
+ return this.cachedSeaLevel;
|
|
}
|
|
+ // Yatopia end
|
|
|
|
@Override
|
|
public List<BiomeSettingsMobs.c> getMobsFor(BiomeBase biomebase, StructureManager structuremanager, EnumCreatureType enumcreaturetype, BlockPosition blockposition) {
|