mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-12-24 01:27:37 +01:00
Cache biome object, further reduce diff
This commit is contained in:
parent
0ebbc2bbe5
commit
0f8174796c
@ -3,6 +3,7 @@ package org.dynmap.common;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.dynmap.hdmap.HDBlockModels;
|
||||
|
||||
@ -44,6 +45,7 @@ public class BiomeMap {
|
||||
private int watercolormult;
|
||||
private int grassmult;
|
||||
private int foliagemult;
|
||||
private Optional<?> biomeObj = Optional.empty();
|
||||
private final String id;
|
||||
private final String resourcelocation;
|
||||
private final int index;
|
||||
@ -300,10 +302,13 @@ public class BiomeMap {
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
public String getResourcelocation() {
|
||||
return resourcelocation;
|
||||
}
|
||||
public String toString() {
|
||||
return String.format("%s(%s)", id, resourcelocation);
|
||||
}
|
||||
public @SuppressWarnings("unchecked") <T> Optional<T> getBiomeObject() {
|
||||
return (Optional<T>) biomeObj;
|
||||
}
|
||||
public void setBiomeObject(Object biomeObj) {
|
||||
this.biomeObj = Optional.of(biomeObj);
|
||||
}
|
||||
}
|
||||
|
@ -57,9 +57,9 @@ public class BukkitVersionHelperSpigot116_4 extends BukkitVersionHelperGeneric {
|
||||
return names;
|
||||
}
|
||||
|
||||
private static IRegistry<BiomeBase> reg = null;
|
||||
private IRegistry<BiomeBase> reg = null;
|
||||
|
||||
public static IRegistry<BiomeBase> getBiomeReg() {
|
||||
private IRegistry<BiomeBase> getBiomeReg() {
|
||||
if (reg == null) {
|
||||
reg = MinecraftServer.getServer().getCustomRegistry().b(IRegistry.ay);
|
||||
}
|
||||
|
@ -66,15 +66,14 @@ public class MapChunkCache116_4 extends GenericMapChunkCache {
|
||||
}
|
||||
@Override
|
||||
public int getFoliageColor(BiomeMap bm, int[] colormap, int x, int z) {
|
||||
if (bm.getResourcelocation() == null) return colormap[bm.biomeLookup()];
|
||||
BiomeBase base = BukkitVersionHelperSpigot116_4.getBiomeReg().get(MinecraftKey.a(bm.getResourcelocation()));
|
||||
return BukkitVersionHelperSpigot116_4.getBiomeBaseFoliageMult(base).orElse(colormap[bm.biomeLookup()]);
|
||||
Optional<BiomeBase> base = bm.getBiomeObject();
|
||||
return BukkitVersionHelperSpigot116_4.getBiomeBaseFoliageMult(base.orElse(null)).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 = BukkitVersionHelperSpigot116_4.getBiomeReg().get(MinecraftKey.a(bm.getResourcelocation()));
|
||||
BiomeBase base = bm.<BiomeBase>getBiomeObject().orElse(null);
|
||||
if (base == null) return bm.getModifiedGrassMultiplier(colormap[bm.biomeLookup()]);
|
||||
int grassMult = BukkitVersionHelperSpigot116_4.getBiomeBaseGrassMult(base).orElse(colormap[bm.biomeLookup()]);
|
||||
BiomeFog.GrassColor modifier = BukkitVersionHelperSpigot116_4.getBiomeBaseGrassModifier(base);
|
||||
if (modifier == BiomeFog.GrassColor.DARK_FOREST) {
|
||||
|
@ -85,9 +85,9 @@ public class BukkitVersionHelperSpigot117 extends BukkitVersionHelper {
|
||||
return names;
|
||||
}
|
||||
|
||||
private static IRegistry<BiomeBase> reg = null;
|
||||
private IRegistry<BiomeBase> reg = null;
|
||||
|
||||
public static IRegistry<BiomeBase> getBiomeReg() {
|
||||
private IRegistry<BiomeBase> getBiomeReg() {
|
||||
if (reg == null) {
|
||||
reg = MinecraftServer.getServer().getCustomRegistry().b(IRegistry.aO);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package org.dynmap.bukkit.helper.v117;
|
||||
|
||||
import net.minecraft.resources.MinecraftKey;
|
||||
import net.minecraft.world.level.biome.BiomeBase;
|
||||
import net.minecraft.world.level.biome.BiomeFog;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_17_R1.CraftWorld;
|
||||
import org.dynmap.DynmapChunk;
|
||||
@ -19,6 +19,7 @@ import net.minecraft.world.level.chunk.storage.ChunkRegionLoader;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Container for managing chunks - dependent upon using chunk snapshots, since rendering is off server thread
|
||||
@ -72,15 +73,13 @@ public class MapChunkCache117 extends GenericMapChunkCache {
|
||||
|
||||
@Override
|
||||
public int getFoliageColor(BiomeMap bm, int[] colormap, int x, int z) {
|
||||
if (bm.getResourcelocation() == null) return colormap[bm.biomeLookup()];
|
||||
BiomeBase base = BukkitVersionHelperSpigot117.getBiomeReg().get(MinecraftKey.a(bm.getResourcelocation()));
|
||||
return base == null ? colormap[bm.biomeLookup()] : base.l().e().orElse(colormap[bm.biomeLookup()]);
|
||||
return bm.<BiomeBase>getBiomeObject().map(BiomeBase::l).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 = BukkitVersionHelperSpigot117.getBiomeReg().get(MinecraftKey.a(bm.getResourcelocation()));
|
||||
return base == null ? colormap[bm.biomeLookup()] : base.l().g().a(x, z, base.l().f().orElse(colormap[bm.biomeLookup()]));
|
||||
BiomeFog fog = bm.<BiomeBase>getBiomeObject().map(BiomeBase::l).orElse(null);
|
||||
if (fog == null) return colormap[bm.biomeLookup()];
|
||||
return fog.g().a(x, z, fog.f().orElse(colormap[bm.biomeLookup()]));
|
||||
}
|
||||
}
|
||||
|
@ -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()]));
|
||||
}
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ public class BukkitVersionHelperSpigot118 extends BukkitVersionHelper {
|
||||
|
||||
private static IRegistry<BiomeBase> reg = null;
|
||||
|
||||
public static IRegistry<BiomeBase> getBiomeReg() {
|
||||
private static IRegistry<BiomeBase> getBiomeReg() {
|
||||
if (reg == null) {
|
||||
reg = MinecraftServer.getServer().aV().d(IRegistry.aR);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package org.dynmap.bukkit.helper.v118;
|
||||
|
||||
import net.minecraft.resources.MinecraftKey;
|
||||
import net.minecraft.world.level.biome.BiomeBase;
|
||||
import net.minecraft.world.level.biome.BiomeFog;
|
||||
import org.bukkit.ChunkSnapshot;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
@ -91,15 +91,13 @@ public class MapChunkCache118 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.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.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()]));
|
||||
}
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ public class BukkitVersionHelperSpigot119 extends BukkitVersionHelper {
|
||||
|
||||
private static IRegistry<BiomeBase> reg = null;
|
||||
|
||||
public static IRegistry<BiomeBase> getBiomeReg() {
|
||||
private static IRegistry<BiomeBase> getBiomeReg() {
|
||||
if (reg == null) {
|
||||
reg = MinecraftServer.getServer().aX().d(IRegistry.aR);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package org.dynmap.bukkit.helper.v119;
|
||||
|
||||
import net.minecraft.resources.MinecraftKey;
|
||||
import net.minecraft.world.level.biome.BiomeBase;
|
||||
import net.minecraft.world.level.biome.BiomeFog;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
|
||||
import org.dynmap.DynmapChunk;
|
||||
@ -100,15 +100,13 @@ public class MapChunkCache119 extends GenericMapChunkCache {
|
||||
|
||||
@Override
|
||||
public int getFoliageColor(BiomeMap bm, int[] colormap, int x, int z) {
|
||||
if (bm.getResourcelocation() == null) return colormap[bm.biomeLookup()];
|
||||
BiomeBase base = BukkitVersionHelperSpigot119.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 = BukkitVersionHelperSpigot119.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()]));
|
||||
}
|
||||
}
|
||||
|
@ -875,6 +875,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
bmap.setWaterColorMultiplier(watermult);
|
||||
Log.verboseinfo("Set watercolormult for " + bmap.toString() + " (" + i + ") to " + Integer.toHexString(watermult));
|
||||
}
|
||||
bmap.setBiomeObject(bb);
|
||||
}
|
||||
}
|
||||
if(cnt > 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user