mirror of
https://github.com/BX-Team/DivineMC.git
synced 2025-12-19 14:59:25 +00:00
55 lines
2.8 KiB
Diff
55 lines
2.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
|
Date: Thu, 17 Jul 2025 20:53:13 +0300
|
|
Subject: [PATCH] C2ME: The End Biome Cache
|
|
|
|
This patch is based on the following mixins:
|
|
* "com/ishland/c2me/opts/worldgen/vanilla/mixin/the_end_biome_cache/MixinTheEndBiomeSource.java"
|
|
By: ishland <ishlandmc@yeah.net>
|
|
As part of: C2ME (https://github.com/RelativityMC/C2ME-fabric)
|
|
Licensed under: MIT (https://opensource.org/licenses/MIT)
|
|
|
|
diff --git a/net/minecraft/world/level/biome/TheEndBiomeSource.java b/net/minecraft/world/level/biome/TheEndBiomeSource.java
|
|
index cf3172be76fa4c7987ed569138439ff42f92fa7f..0545a0dd25917d75b511d507dc19a5ca7d45b9d9 100644
|
|
--- a/net/minecraft/world/level/biome/TheEndBiomeSource.java
|
|
+++ b/net/minecraft/world/level/biome/TheEndBiomeSource.java
|
|
@@ -55,8 +55,37 @@ public class TheEndBiomeSource extends BiomeSource {
|
|
return CODEC;
|
|
}
|
|
|
|
+ // DivineMC start - C2ME: The End Biome Cache
|
|
+ private final ThreadLocal<it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap<Holder<Biome>>> cache = ThreadLocal.withInitial(it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap::new);
|
|
+ private final int cacheCapacity = org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.endBiomeCacheCapacity;
|
|
+
|
|
@Override
|
|
- public Holder<Biome> getNoiseBiome(int x, int y, int z, Climate.Sampler sampler) {
|
|
+ public Holder<Biome> getNoiseBiome(int biomeX, int biomeY, int biomeZ, Climate.Sampler multiNoiseSampler) {
|
|
+ if (!org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.endBiomeCacheEnabled) {
|
|
+ return getVanillaNoiseBiome(biomeX, biomeY, biomeZ, multiNoiseSampler);
|
|
+ }
|
|
+
|
|
+ final long key = net.minecraft.world.level.ChunkPos.asLong(biomeX, biomeZ);
|
|
+ final it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap<Holder<Biome>> cacheThreadLocal = cache.get();
|
|
+ final Holder<Biome> biome = cacheThreadLocal.get(key);
|
|
+
|
|
+ if (biome != null) {
|
|
+ return biome;
|
|
+ } else {
|
|
+ final Holder<Biome> gennedBiome = getVanillaNoiseBiome(biomeX, biomeY, biomeZ, multiNoiseSampler);
|
|
+ cacheThreadLocal.put(key, gennedBiome);
|
|
+ if (cacheThreadLocal.size() > cacheCapacity) {
|
|
+ for (int i = 0; i < cacheCapacity / 16; i ++) {
|
|
+ cacheThreadLocal.removeFirst();
|
|
+ }
|
|
+ }
|
|
+
|
|
+ return gennedBiome;
|
|
+ }
|
|
+ }
|
|
+ // DivineMC end - C2ME: The End Biome Cache
|
|
+
|
|
+ private Holder<Biome> getVanillaNoiseBiome(int x, int y, int z, Climate.Sampler sampler) { // DivineMC - C2ME: The End Biome Cache
|
|
int blockPosX = QuartPos.toBlock(x);
|
|
int blockPosY = QuartPos.toBlock(y);
|
|
int blockPosZ = QuartPos.toBlock(z);
|