Cache biome object, further reduce diff
This commit is contained in:
parent
0ebbc2bbe5
commit
0f8174796c
12 changed files with 41 additions and 43 deletions
|
|
@ -111,7 +111,7 @@ public class BukkitVersionHelperSpigot118_2 extends BukkitVersionHelper {
|
|||
|
||||
private static IRegistry<BiomeBase> reg = null;
|
||||
|
||||
public static IRegistry<BiomeBase> getBiomeReg() {
|
||||
private static IRegistry<BiomeBase> getBiomeReg() {
|
||||
if (reg == null) {
|
||||
reg = MinecraftServer.getServer().aU().d(IRegistry.aP);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
package org.dynmap.bukkit.helper.v118_2;
|
||||
|
||||
import net.minecraft.resources.MinecraftKey;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.level.biome.BiomeBase;
|
||||
import net.minecraft.world.level.biome.BiomeFog;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.CraftServer;
|
||||
|
|
@ -102,15 +102,13 @@ public class MapChunkCache118_2 extends GenericMapChunkCache {
|
|||
|
||||
@Override
|
||||
public int getFoliageColor(BiomeMap bm, int[] colormap, int x, int z) {
|
||||
if (bm.getResourcelocation() == null) return colormap[bm.biomeLookup()];
|
||||
BiomeBase base = BukkitVersionHelperSpigot118_2.getBiomeReg().a(MinecraftKey.a(bm.getResourcelocation()));
|
||||
return base == null ? colormap[bm.biomeLookup()] : base.j().e().orElse(colormap[bm.biomeLookup()]);
|
||||
return bm.<BiomeBase>getBiomeObject().map(BiomeBase::j).flatMap(BiomeFog::e).orElse(colormap[bm.biomeLookup()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGrassColor(BiomeMap bm, int[] colormap, int x, int z) {
|
||||
if (bm.getResourcelocation() == null) return colormap[bm.biomeLookup()];
|
||||
BiomeBase base = BukkitVersionHelperSpigot118_2.getBiomeReg().a(MinecraftKey.a(bm.getResourcelocation()));
|
||||
return base == null ? colormap[bm.biomeLookup()] : base.j().g().a(x, z, base.j().f().orElse(colormap[bm.biomeLookup()]));
|
||||
BiomeFog fog = bm.<BiomeBase>getBiomeObject().map(BiomeBase::j).orElse(null);
|
||||
if (fog == null) return colormap[bm.biomeLookup()];
|
||||
return fog.g().a(x, z, fog.f().orElse(colormap[bm.biomeLookup()]));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue