Merge pull request #3862 from mastermc05/colorful-biomes

Colorful biomes
This commit is contained in:
mikeprimm 2022-11-29 15:37:42 -06:00 committed by GitHub
commit 7d1a273e6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
34 changed files with 347 additions and 2 deletions

View File

@ -3,6 +3,7 @@ package org.dynmap.common;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import org.dynmap.hdmap.HDBlockModels; import org.dynmap.hdmap.HDBlockModels;
@ -44,6 +45,7 @@ public class BiomeMap {
private int watercolormult; private int watercolormult;
private int grassmult; private int grassmult;
private int foliagemult; private int foliagemult;
private Optional<?> biomeObj = Optional.empty();
private final String id; private final String id;
private final String resourcelocation; private final String resourcelocation;
private final int index; private final int index;
@ -308,4 +310,10 @@ public class BiomeMap {
public String toString() { public String toString() {
return String.format("%s(%s)", id, resourcelocation); 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);
}
} }

View File

@ -181,7 +181,7 @@ public abstract class GenericMapChunkCache extends MapChunkCache {
for (int dz = -1; dz <= 1; dz++) { for (int dz = -1; dz <= 1; dz++) {
BiomeMap bm = getBiomeRel(dx, dz); BiomeMap bm = getBiomeRel(dx, dz);
if (bm == BiomeMap.NULL) continue; if (bm == BiomeMap.NULL) continue;
int rmult = bm.getModifiedGrassMultiplier(colormap[bm.biomeLookup()]); int rmult = getGrassColor(bm, colormap, getX() + dx, getZ() + dz);
raccum += (rmult >> 16) & 0xFF; raccum += (rmult >> 16) & 0xFF;
gaccum += (rmult >> 8) & 0xFF; gaccum += (rmult >> 8) & 0xFF;
baccum += rmult & 0xFF; baccum += rmult & 0xFF;
@ -212,7 +212,7 @@ public abstract class GenericMapChunkCache extends MapChunkCache {
for (int dz = -1; dz <= 1; dz++) { for (int dz = -1; dz <= 1; dz++) {
BiomeMap bm = getBiomeRel(dx, dz); BiomeMap bm = getBiomeRel(dx, dz);
if (bm == BiomeMap.NULL) continue; if (bm == BiomeMap.NULL) continue;
int rmult = bm.getModifiedFoliageMultiplier(colormap[bm.biomeLookup()]); int rmult = getFoliageColor(bm, colormap, getX() + dx, getZ() + dz);
raccum += (rmult >> 16) & 0xFF; raccum += (rmult >> 16) & 0xFF;
gaccum += (rmult >> 8) & 0xFF; gaccum += (rmult >> 8) & 0xFF;
baccum += rmult & 0xFF; baccum += rmult & 0xFF;
@ -546,6 +546,14 @@ public abstract class GenericMapChunkCache extends MapChunkCache {
} }
} }
public int getGrassColor(BiomeMap bm, int[] colormap, int x, int z) {
return bm.getModifiedGrassMultiplier(colormap[bm.biomeLookup()]);
}
public int getFoliageColor(BiomeMap bm, int[] colormap, int x, int z) {
return bm.getModifiedFoliageMultiplier(colormap[bm.biomeLookup()]);
}
private class OurEndMapIterator extends OurMapIterator { private class OurEndMapIterator extends OurMapIterator {
OurEndMapIterator(int x0, int y0, int z0) { OurEndMapIterator(int x0, int y0, int z0) {
super(x0, y0, z0); super(x0, y0, z0);

View File

@ -20,6 +20,7 @@ import java.lang.reflect.Method;
import java.util.HashMap; import java.util.HashMap;
import java.util.IdentityHashMap; import java.util.IdentityHashMap;
import java.util.List; import java.util.List;
import java.util.Optional;
/** /**
@ -28,10 +29,16 @@ import java.util.List;
public class BukkitVersionHelperSpigot116_4 extends BukkitVersionHelperGeneric { public class BukkitVersionHelperSpigot116_4 extends BukkitVersionHelperGeneric {
private final boolean unsafeAsync; private final boolean unsafeAsync;
private Field watercolorfield; private Field watercolorfield;
private static Field grassColorField;
private static Field foliageColorField;
private static Field grassColorModifierField;
public BukkitVersionHelperSpigot116_4() { public BukkitVersionHelperSpigot116_4() {
Class biomefog = getNMSClass("net.minecraft.server.BiomeFog"); Class biomefog = getNMSClass("net.minecraft.server.BiomeFog");
watercolorfield = getPrivateField(biomefog, new String[] { "c" }, int.class); watercolorfield = getPrivateField(biomefog, new String[] { "c" }, int.class);
grassColorField = getPrivateField(biomefog, new String[] { "g" }, Optional.class);
foliageColorField = getPrivateField(biomefog, new String[] { "f" }, Optional.class);
grassColorModifierField = getPrivateField(biomefog, new String[] { "h" }, BiomeFog.GrassColor.class);
this.unsafeAsync = true; this.unsafeAsync = true;
} }
@ -160,6 +167,29 @@ public class BukkitVersionHelperSpigot116_4 extends BukkitVersionHelperGeneric {
} }
return 0xFFFFFF; return 0xFFFFFF;
} }
@SuppressWarnings("unchecked")
public static Optional<Integer> getBiomeBaseGrassMult(BiomeBase bb) {
if (bb == null) return Optional.empty();
try {
return (Optional<Integer>) grassColorField.get(bb.l());
} catch (IllegalArgumentException | IllegalAccessException ignored) {}
return Optional.empty();
}
@SuppressWarnings("unchecked")
public static Optional<Integer> getBiomeBaseFoliageMult(BiomeBase bb) {
if (bb == null) return Optional.empty();
try {
return (Optional<Integer>) foliageColorField.get(bb.l());
} catch (IllegalArgumentException | IllegalAccessException ignored) {}
return Optional.empty();
}
public static BiomeFog.GrassColor getBiomeBaseGrassModifier(BiomeBase bb) {
if (bb == null) return BiomeFog.GrassColor.NONE;
try {
return (BiomeFog.GrassColor) grassColorModifierField.get(bb.l());
} catch (IllegalArgumentException | IllegalAccessException ignored) {}
return BiomeFog.GrassColor.NONE;
}
/** Get temperature from biomebase */ /** Get temperature from biomebase */
@Override @Override

View File

@ -6,12 +6,14 @@ import org.bukkit.World;
import org.bukkit.craftbukkit.v1_16_R3.CraftWorld; import org.bukkit.craftbukkit.v1_16_R3.CraftWorld;
import org.dynmap.DynmapChunk; import org.dynmap.DynmapChunk;
import org.dynmap.bukkit.helper.BukkitWorld; import org.dynmap.bukkit.helper.BukkitWorld;
import org.dynmap.common.BiomeMap;
import org.dynmap.common.chunk.GenericChunk; import org.dynmap.common.chunk.GenericChunk;
import org.dynmap.common.chunk.GenericChunkCache; import org.dynmap.common.chunk.GenericChunkCache;
import org.dynmap.common.chunk.GenericMapChunkCache; import org.dynmap.common.chunk.GenericMapChunkCache;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.Optional;
/** /**
* Container for managing chunks - dependent upon using chunk snapshots, since rendering is off server thread * Container for managing chunks - dependent upon using chunk snapshots, since rendering is off server thread
@ -62,5 +64,26 @@ public class MapChunkCache116_4 extends GenericMapChunkCache {
this.w = dw.getWorld(); this.w = dw.getWorld();
super.setChunks(dw, chunks); super.setChunks(dw, chunks);
} }
@Override
public int getFoliageColor(BiomeMap bm, int[] colormap, int x, int z) {
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) {
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) {
return ((grassMult & 0xfefefe) + 0x28340a) >> 1;
} else if (modifier == BiomeFog.GrassColor.SWAMP) {
double var5 = BiomeBase.f.a(x * 0.0225, z * 0.0225, false);
return var5 < -0.1 ? 0x4c763c : 0x6a7039;
} else {
return grassMult;
}
}
} }

View File

@ -1,9 +1,12 @@
package org.dynmap.bukkit.helper.v117; package org.dynmap.bukkit.helper.v117;
import net.minecraft.world.level.biome.BiomeBase;
import net.minecraft.world.level.biome.BiomeFog;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.craftbukkit.v1_17_R1.CraftWorld; import org.bukkit.craftbukkit.v1_17_R1.CraftWorld;
import org.dynmap.DynmapChunk; import org.dynmap.DynmapChunk;
import org.dynmap.bukkit.helper.BukkitWorld; import org.dynmap.bukkit.helper.BukkitWorld;
import org.dynmap.common.BiomeMap;
import org.dynmap.common.chunk.GenericChunk; import org.dynmap.common.chunk.GenericChunk;
import org.dynmap.common.chunk.GenericChunkCache; import org.dynmap.common.chunk.GenericChunkCache;
import org.dynmap.common.chunk.GenericMapChunkCache; import org.dynmap.common.chunk.GenericMapChunkCache;
@ -16,6 +19,7 @@ import net.minecraft.world.level.chunk.storage.ChunkRegionLoader;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.Optional;
/** /**
* Container for managing chunks - dependent upon using chunk snapshots, since rendering is off server thread * Container for managing chunks - dependent upon using chunk snapshots, since rendering is off server thread
@ -66,4 +70,16 @@ public class MapChunkCache117 extends GenericMapChunkCache {
this.w = dw.getWorld(); this.w = dw.getWorld();
super.setChunks(dw, chunks); super.setChunks(dw, chunks);
} }
@Override
public int getFoliageColor(BiomeMap bm, int[] colormap, int x, int z) {
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) {
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()]));
}
} }

View File

@ -1,6 +1,8 @@
package org.dynmap.bukkit.helper.v118_2; package org.dynmap.bukkit.helper.v118_2;
import net.minecraft.server.MinecraftServer; 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.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.craftbukkit.v1_18_R2.CraftServer; import org.bukkit.craftbukkit.v1_18_R2.CraftServer;
@ -9,6 +11,7 @@ import org.dynmap.DynmapChunk;
import org.dynmap.MapManager; import org.dynmap.MapManager;
import org.dynmap.bukkit.helper.BukkitVersionHelper; import org.dynmap.bukkit.helper.BukkitVersionHelper;
import org.dynmap.bukkit.helper.BukkitWorld; import org.dynmap.bukkit.helper.BukkitWorld;
import org.dynmap.common.BiomeMap;
import org.dynmap.common.chunk.GenericChunk; import org.dynmap.common.chunk.GenericChunk;
import org.dynmap.common.chunk.GenericChunkCache; import org.dynmap.common.chunk.GenericChunkCache;
import org.dynmap.common.chunk.GenericMapChunkCache; import org.dynmap.common.chunk.GenericMapChunkCache;
@ -96,4 +99,16 @@ public class MapChunkCache118_2 extends GenericMapChunkCache {
this.w = dw.getWorld(); this.w = dw.getWorld();
super.setChunks(dw, chunks); super.setChunks(dw, chunks);
} }
@Override
public int getFoliageColor(BiomeMap bm, int[] colormap, int x, int z) {
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) {
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()]));
}
} }

View File

@ -1,5 +1,7 @@
package org.dynmap.bukkit.helper.v118; package org.dynmap.bukkit.helper.v118;
import net.minecraft.world.level.biome.BiomeBase;
import net.minecraft.world.level.biome.BiomeFog;
import org.bukkit.ChunkSnapshot; import org.bukkit.ChunkSnapshot;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
@ -85,4 +87,17 @@ public class MapChunkCache118 extends GenericMapChunkCache {
this.w = dw.getWorld(); this.w = dw.getWorld();
super.setChunks(dw, chunks); super.setChunks(dw, chunks);
} }
@Override
public int getFoliageColor(BiomeMap bm, int[] colormap, int x, int z) {
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) {
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()]));
}
} }

View File

@ -1,10 +1,13 @@
package org.dynmap.bukkit.helper.v119; package org.dynmap.bukkit.helper.v119;
import net.minecraft.world.level.biome.BiomeBase;
import net.minecraft.world.level.biome.BiomeFog;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld; import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
import org.dynmap.DynmapChunk; import org.dynmap.DynmapChunk;
import org.dynmap.bukkit.helper.BukkitVersionHelper; import org.dynmap.bukkit.helper.BukkitVersionHelper;
import org.dynmap.bukkit.helper.BukkitWorld; import org.dynmap.bukkit.helper.BukkitWorld;
import org.dynmap.common.BiomeMap;
import org.dynmap.common.chunk.GenericChunk; import org.dynmap.common.chunk.GenericChunk;
import org.dynmap.common.chunk.GenericChunkCache; import org.dynmap.common.chunk.GenericChunkCache;
import org.dynmap.common.chunk.GenericMapChunkCache; import org.dynmap.common.chunk.GenericMapChunkCache;
@ -94,4 +97,16 @@ public class MapChunkCache119 extends GenericMapChunkCache {
this.w = dw.getWorld(); this.w = dw.getWorld();
super.setChunks(dw, chunks); super.setChunks(dw, chunks);
} }
@Override
public int getFoliageColor(BiomeMap bm, int[] colormap, int x, int z) {
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) {
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()]));
}
} }

View File

@ -396,6 +396,7 @@ public class DynmapPlugin {
bmap.setWaterColorMultiplier(watermult); bmap.setWaterColorMultiplier(watermult);
Log.verboseinfo("Set watercolormult for " + bmap.toString() + " (" + i + ") to " + Integer.toHexString(watermult)); Log.verboseinfo("Set watercolormult for " + bmap.toString() + " (" + i + ") to " + Integer.toHexString(watermult));
} }
bmap.setBiomeObject(bb);
} }
} }
if (cnt > 0) if (cnt > 0)

View File

@ -7,12 +7,16 @@ import net.minecraft.server.world.ThreadedAnvilChunkStorage;
import net.minecraft.util.math.ChunkPos; import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.ChunkSerializer; import net.minecraft.world.ChunkSerializer;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.BiomeEffects;
import net.minecraft.world.chunk.ChunkManager; import net.minecraft.world.chunk.ChunkManager;
import net.minecraft.world.chunk.ChunkStatus; import net.minecraft.world.chunk.ChunkStatus;
import org.dynmap.DynmapChunk; import org.dynmap.DynmapChunk;
import org.dynmap.Log; import org.dynmap.Log;
import org.dynmap.common.BiomeMap;
import org.dynmap.common.chunk.GenericChunk; import org.dynmap.common.chunk.GenericChunk;
import org.dynmap.common.chunk.GenericMapChunkCache; import org.dynmap.common.chunk.GenericMapChunkCache;
import org.dynmap.fabric_1_16_4.mixin.BiomeEffectsAccessor;
import java.util.*; import java.util.*;
@ -85,5 +89,29 @@ public class FabricMapChunkCache extends GenericMapChunkCache {
} }
return gc; return gc;
} }
@Override
public int getFoliageColor(BiomeMap bm, int[] colormap, int x, int z) {
return bm.<Biome>getBiomeObject()
.map(Biome::getEffects)
.map(BiomeEffectsAccessor.class::cast)
.flatMap(BiomeEffectsAccessor::getFoliageColor)
.orElse(colormap[bm.biomeLookup()]);
}
@Override
public int getGrassColor(BiomeMap bm, int[] colormap, int x, int z) {
BiomeEffectsAccessor effects = (BiomeEffectsAccessor) bm.<Biome>getBiomeObject().map(Biome::getEffects).orElse(null);
if (effects == null) return colormap[bm.biomeLookup()];
int grassMult = effects.getGrassColor().orElse(colormap[bm.biomeLookup()]);
BiomeEffects.GrassColorModifier modifier = effects.getGrassColorModifier();
if (modifier == BiomeEffects.GrassColorModifier.DARK_FOREST) {
return ((grassMult & 0xfefefe) + 0x28340a) >> 1;
} else if (modifier == BiomeEffects.GrassColorModifier.SWAMP) {
double var5 = Biome.FOLIAGE_NOISE.sample(x * 0.0225, z * 0.0225, false);
return var5 < -0.1 ? 0x4c763c : 0x6a7039;
} else {
return grassMult;
}
}
} }

View File

@ -4,8 +4,16 @@ import net.minecraft.world.biome.BiomeEffects;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor; import org.spongepowered.asm.mixin.gen.Accessor;
import java.util.Optional;
@Mixin(BiomeEffects.class) @Mixin(BiomeEffects.class)
public interface BiomeEffectsAccessor { public interface BiomeEffectsAccessor {
@Accessor @Accessor
int getWaterColor(); int getWaterColor();
@Accessor
Optional<Integer> getFoliageColor();
@Accessor
Optional<Integer> getGrassColor();
@Accessor
BiomeEffects.GrassColorModifier getGrassColorModifier();
} }

View File

@ -397,6 +397,7 @@ public class DynmapPlugin {
bmap.setWaterColorMultiplier(watermult); bmap.setWaterColorMultiplier(watermult);
Log.verboseinfo("Set watercolormult for " + bmap.toString() + " (" + i + ") to " + Integer.toHexString(watermult)); Log.verboseinfo("Set watercolormult for " + bmap.toString() + " (" + i + ") to " + Integer.toHexString(watermult));
} }
bmap.setBiomeObject(bb);
} }
} }
if (cnt > 0) if (cnt > 0)

View File

@ -7,10 +7,13 @@ import net.minecraft.server.world.ThreadedAnvilChunkStorage;
import net.minecraft.util.math.ChunkPos; import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.ChunkSerializer; import net.minecraft.world.ChunkSerializer;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.BiomeEffects;
import net.minecraft.world.chunk.ChunkManager; import net.minecraft.world.chunk.ChunkManager;
import net.minecraft.world.chunk.ChunkStatus; import net.minecraft.world.chunk.ChunkStatus;
import org.dynmap.DynmapChunk; import org.dynmap.DynmapChunk;
import org.dynmap.Log; import org.dynmap.Log;
import org.dynmap.common.BiomeMap;
import org.dynmap.common.chunk.GenericChunk; import org.dynmap.common.chunk.GenericChunk;
import org.dynmap.common.chunk.GenericMapChunkCache; import org.dynmap.common.chunk.GenericMapChunkCache;
@ -83,4 +86,15 @@ public class FabricMapChunkCache extends GenericMapChunkCache {
} }
return gc; return gc;
} }
@Override
public int getFoliageColor(BiomeMap bm, int[] colormap, int x, int z) {
return bm.<Biome>getBiomeObject().map(Biome::getEffects).flatMap(BiomeEffects::getFoliageColor).orElse(colormap[bm.biomeLookup()]);
}
@Override
public int getGrassColor(BiomeMap bm, int[] colormap, int x, int z) {
BiomeEffects effects = bm.<Biome>getBiomeObject().map(Biome::getEffects).orElse(null);
if (effects == null) return colormap[bm.biomeLookup()];
return effects.getGrassColorModifier().getModifiedGrassColor(x, z, effects.getGrassColor().orElse(colormap[bm.biomeLookup()]));
}
} }

View File

@ -374,6 +374,7 @@ public class DynmapPlugin {
bmap.setWaterColorMultiplier(watermult); bmap.setWaterColorMultiplier(watermult);
Log.verboseinfo("Set watercolormult for " + bmap.toString() + " (" + i + ") to " + Integer.toHexString(watermult)); Log.verboseinfo("Set watercolormult for " + bmap.toString() + " (" + i + ") to " + Integer.toHexString(watermult));
} }
bmap.setBiomeObject(bb);
} }
} }
if (cnt > 0) if (cnt > 0)

View File

@ -12,6 +12,7 @@ import net.minecraft.util.registry.Registry;
import net.minecraft.world.ChunkSerializer; import net.minecraft.world.ChunkSerializer;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.BiomeEffects;
import net.minecraft.world.chunk.ChunkManager; import net.minecraft.world.chunk.ChunkManager;
import net.minecraft.world.chunk.ChunkStatus; import net.minecraft.world.chunk.ChunkStatus;
@ -100,4 +101,15 @@ public class FabricMapChunkCache extends GenericMapChunkCache {
} }
return gc; return gc;
} }
@Override
public int getFoliageColor(BiomeMap bm, int[] colormap, int x, int z) {
return bm.<Biome>getBiomeObject().map(Biome::getEffects).flatMap(BiomeEffects::getFoliageColor).orElse(colormap[bm.biomeLookup()]);
}
@Override
public int getGrassColor(BiomeMap bm, int[] colormap, int x, int z) {
BiomeEffects effects = bm.<Biome>getBiomeObject().map(Biome::getEffects).orElse(null);
if (effects == null) return colormap[bm.biomeLookup()];
return effects.getGrassColorModifier().getModifiedGrassColor(x, z, effects.getGrassColor().orElse(colormap[bm.biomeLookup()]));
}
} }

View File

@ -367,6 +367,7 @@ public class DynmapPlugin {
bmap.setWaterColorMultiplier(watermult); bmap.setWaterColorMultiplier(watermult);
Log.verboseinfo("Set watercolormult for " + bmap.toString() + " (" + i + ") to " + Integer.toHexString(watermult)); Log.verboseinfo("Set watercolormult for " + bmap.toString() + " (" + i + ") to " + Integer.toHexString(watermult));
} }
bmap.setBiomeObject(bb);
} }
} }
if (cnt > 0) if (cnt > 0)

View File

@ -12,6 +12,7 @@ import net.minecraft.util.registry.Registry;
import net.minecraft.world.ChunkSerializer; import net.minecraft.world.ChunkSerializer;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.BiomeEffects;
import net.minecraft.world.chunk.ChunkManager; import net.minecraft.world.chunk.ChunkManager;
import net.minecraft.world.chunk.ChunkStatus; import net.minecraft.world.chunk.ChunkStatus;
@ -100,4 +101,15 @@ public class FabricMapChunkCache extends GenericMapChunkCache {
} }
return gc; return gc;
} }
@Override
public int getFoliageColor(BiomeMap bm, int[] colormap, int x, int z) {
return bm.<Biome>getBiomeObject().map(Biome::getEffects).flatMap(BiomeEffects::getFoliageColor).orElse(colormap[bm.biomeLookup()]);
}
@Override
public int getGrassColor(BiomeMap bm, int[] colormap, int x, int z) {
BiomeEffects effects = bm.<Biome>getBiomeObject().map(Biome::getEffects).orElse(null);
if (effects == null) return colormap[bm.biomeLookup()];
return effects.getGrassColorModifier().getModifiedGrassColor(x, z, effects.getGrassColor().orElse(colormap[bm.biomeLookup()]));
}
} }

View File

@ -362,6 +362,7 @@ public class DynmapPlugin {
bmap.setWaterColorMultiplier(watermult); bmap.setWaterColorMultiplier(watermult);
Log.verboseinfo("Set watercolormult for " + bmap.toString() + " (" + i + ") to " + Integer.toHexString(watermult)); Log.verboseinfo("Set watercolormult for " + bmap.toString() + " (" + i + ") to " + Integer.toHexString(watermult));
} }
bmap.setBiomeObject(bb);
} }
} }
if (cnt > 0) if (cnt > 0)

View File

@ -12,6 +12,7 @@ import net.minecraft.util.registry.Registry;
import net.minecraft.world.ChunkSerializer; import net.minecraft.world.ChunkSerializer;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.BiomeEffects;
import net.minecraft.world.chunk.ChunkManager; import net.minecraft.world.chunk.ChunkManager;
import net.minecraft.world.chunk.ChunkStatus; import net.minecraft.world.chunk.ChunkStatus;
@ -101,4 +102,15 @@ public class FabricMapChunkCache extends GenericMapChunkCache {
} }
return gc; return gc;
} }
@Override
public int getFoliageColor(BiomeMap bm, int[] colormap, int x, int z) {
return bm.<Biome>getBiomeObject().map(Biome::getEffects).flatMap(BiomeEffects::getFoliageColor).orElse(colormap[bm.biomeLookup()]);
}
@Override
public int getGrassColor(BiomeMap bm, int[] colormap, int x, int z) {
BiomeEffects effects = bm.<Biome>getBiomeObject().map(Biome::getEffects).orElse(null);
if (effects == null) return colormap[bm.biomeLookup()];
return effects.getGrassColorModifier().getModifiedGrassColor(x, z, effects.getGrassColor().orElse(colormap[bm.biomeLookup()]));
}
} }

View File

@ -362,6 +362,7 @@ public class DynmapPlugin {
bmap.setWaterColorMultiplier(watermult); bmap.setWaterColorMultiplier(watermult);
Log.verboseinfo("Set watercolormult for " + bmap.toString() + " (" + i + ") to " + Integer.toHexString(watermult)); Log.verboseinfo("Set watercolormult for " + bmap.toString() + " (" + i + ") to " + Integer.toHexString(watermult));
} }
bmap.setBiomeObject(bb);
} }
} }
if (cnt > 0) if (cnt > 0)

View File

@ -12,6 +12,7 @@ import net.minecraft.util.registry.Registry;
import net.minecraft.world.ChunkSerializer; import net.minecraft.world.ChunkSerializer;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.BiomeEffects;
import net.minecraft.world.chunk.ChunkManager; import net.minecraft.world.chunk.ChunkManager;
import net.minecraft.world.chunk.ChunkStatus; import net.minecraft.world.chunk.ChunkStatus;
@ -101,4 +102,15 @@ public class FabricMapChunkCache extends GenericMapChunkCache {
} }
return gc; return gc;
} }
@Override
public int getFoliageColor(BiomeMap bm, int[] colormap, int x, int z) {
return bm.<Biome>getBiomeObject().map(Biome::getEffects).flatMap(BiomeEffects::getFoliageColor).orElse(colormap[bm.biomeLookup()]);
}
@Override
public int getGrassColor(BiomeMap bm, int[] colormap, int x, int z) {
BiomeEffects effects = bm.<Biome>getBiomeObject().map(Biome::getEffects).orElse(null);
if (effects == null) return colormap[bm.biomeLookup()];
return effects.getGrassColorModifier().getModifiedGrassColor(x, z, effects.getGrassColor().orElse(colormap[bm.biomeLookup()]));
}
} }

View File

@ -1442,6 +1442,7 @@ public class DynmapPlugin
bmap.setWaterColorMultiplier(watermult); bmap.setWaterColorMultiplier(watermult);
Log.verboseinfo("Set watercolormult for " + bmap.toString() + " (" + i + ") to " + Integer.toHexString(watermult)); Log.verboseinfo("Set watercolormult for " + bmap.toString() + " (" + i + ") to " + Integer.toHexString(watermult));
} }
bmap.setBiomeObject(bb);
} }
} }
if(cnt > 0) if(cnt > 0)

View File

@ -4,6 +4,8 @@ import java.util.List;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.math.ChunkPos; import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.BiomeAmbience;
import net.minecraft.world.chunk.AbstractChunkProvider; import net.minecraft.world.chunk.AbstractChunkProvider;
import net.minecraft.world.chunk.ChunkStatus; import net.minecraft.world.chunk.ChunkStatus;
import net.minecraft.world.chunk.IChunk; import net.minecraft.world.chunk.IChunk;
@ -13,6 +15,7 @@ import net.minecraft.world.server.ServerWorld;
import org.dynmap.DynmapChunk; import org.dynmap.DynmapChunk;
import org.dynmap.Log; import org.dynmap.Log;
import org.dynmap.common.BiomeMap;
import org.dynmap.common.chunk.GenericChunk; import org.dynmap.common.chunk.GenericChunk;
import org.dynmap.common.chunk.GenericChunkCache; import org.dynmap.common.chunk.GenericChunkCache;
import org.dynmap.common.chunk.GenericMapChunkCache; import org.dynmap.common.chunk.GenericMapChunkCache;
@ -77,4 +80,25 @@ public class ForgeMapChunkCache extends GenericMapChunkCache {
return null; return null;
} }
} }
@Override
public int getFoliageColor(BiomeMap bm, int[] colormap, int x, int z) {
return bm.<Biome>getBiomeObject().map(Biome::getAmbience)
.flatMap(BiomeAmbience::getFoliageColor)
.orElse(colormap[bm.biomeLookup()]);
}
@Override
public int getGrassColor(BiomeMap bm, int[] colormap, int x, int z) {
BiomeAmbience effects = bm.<Biome>getBiomeObject().map(Biome::getAmbience).orElse(null);
if (effects == null) return colormap[bm.biomeLookup()];
BiomeAmbience.GrassColorModifier modifier = effects.getGrassColorModifier();
if (modifier == BiomeAmbience.GrassColorModifier.DARK_FOREST) {
return ((effects.getGrassColor().orElse(colormap[bm.biomeLookup()]) & 0xfefefe) + 0x28340a) >> 1;
} else if (modifier == BiomeAmbience.GrassColorModifier.SWAMP) {
double d0 = Biome.INFO_NOISE.noiseAt(x * 0.0225D, z * 0.0225D, false);
return d0 < -0.1D ? 0x4c763c : 0x6a7039;
} else {
return effects.getGrassColor().orElse(colormap[bm.biomeLookup()]);
}
}
} }

View File

@ -1422,6 +1422,7 @@ public class DynmapPlugin
bmap.setWaterColorMultiplier(watermult); bmap.setWaterColorMultiplier(watermult);
Log.verboseinfo("Set watercolormult for " + bmap.toString() + " (" + i + ") to " + Integer.toHexString(watermult)); Log.verboseinfo("Set watercolormult for " + bmap.toString() + " (" + i + ") to " + Integer.toHexString(watermult));
} }
bmap.setBiomeObject(bb);
} }
} }
if(cnt > 0) if(cnt > 0)

View File

@ -2,8 +2,11 @@ package org.dynmap.forge_1_17_1;
import java.util.List; import java.util.List;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.biome.BiomeSpecialEffects;
import org.dynmap.DynmapChunk; import org.dynmap.DynmapChunk;
import org.dynmap.Log; import org.dynmap.Log;
import org.dynmap.common.BiomeMap;
import org.dynmap.common.chunk.GenericChunk; import org.dynmap.common.chunk.GenericChunk;
import org.dynmap.common.chunk.GenericChunkCache; import org.dynmap.common.chunk.GenericChunkCache;
import org.dynmap.common.chunk.GenericMapChunkCache; import org.dynmap.common.chunk.GenericMapChunkCache;
@ -70,4 +73,17 @@ public class ForgeMapChunkCache extends GenericMapChunkCache {
return null; return null;
} }
} }
@Override
public int getFoliageColor(BiomeMap bm, int[] colormap, int x, int z) {
return bm.<Biome>getBiomeObject().map(Biome::getSpecialEffects)
.flatMap(BiomeSpecialEffects::getFoliageColorOverride)
.orElse(colormap[bm.biomeLookup()]);
}
@Override
public int getGrassColor(BiomeMap bm, int[] colormap, int x, int z) {
BiomeSpecialEffects effects = bm.<Biome>getBiomeObject().map(Biome::getSpecialEffects).orElse(null);
if (effects == null) return colormap[bm.biomeLookup()];
return effects.getGrassColorModifier().modifyColor(x, z, effects.getGrassColorOverride().orElse(colormap[bm.biomeLookup()]));
}
} }

View File

@ -1423,6 +1423,7 @@ public class DynmapPlugin
bmap.setWaterColorMultiplier(watermult); bmap.setWaterColorMultiplier(watermult);
Log.verboseinfo("Set watercolormult for " + bmap.toString() + " (" + i + ") to " + Integer.toHexString(watermult)); Log.verboseinfo("Set watercolormult for " + bmap.toString() + " (" + i + ") to " + Integer.toHexString(watermult));
} }
bmap.setBiomeObject(bb);
} }
} }
if(cnt > 0) if(cnt > 0)

View File

@ -2,8 +2,11 @@ package org.dynmap.forge_1_18_2;
import java.util.List; import java.util.List;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.biome.BiomeSpecialEffects;
import org.dynmap.DynmapChunk; import org.dynmap.DynmapChunk;
import org.dynmap.Log; import org.dynmap.Log;
import org.dynmap.common.BiomeMap;
import org.dynmap.common.chunk.GenericChunk; import org.dynmap.common.chunk.GenericChunk;
import org.dynmap.common.chunk.GenericChunkCache; import org.dynmap.common.chunk.GenericChunkCache;
import org.dynmap.common.chunk.GenericMapChunkCache; import org.dynmap.common.chunk.GenericMapChunkCache;
@ -86,4 +89,17 @@ public class ForgeMapChunkCache extends GenericMapChunkCache {
return null; return null;
} }
} }
@Override
public int getFoliageColor(BiomeMap bm, int[] colormap, int x, int z) {
return bm.<Biome>getBiomeObject().map(Biome::getSpecialEffects)
.flatMap(BiomeSpecialEffects::getFoliageColorOverride)
.orElse(colormap[bm.biomeLookup()]);
}
@Override
public int getGrassColor(BiomeMap bm, int[] colormap, int x, int z) {
BiomeSpecialEffects effects = bm.<Biome>getBiomeObject().map(Biome::getSpecialEffects).orElse(null);
if (effects == null) return colormap[bm.biomeLookup()];
return effects.getGrassColorModifier().modifyColor(x, z, effects.getGrassColorOverride().orElse(colormap[bm.biomeLookup()]));
}
} }

View File

@ -1423,6 +1423,7 @@ public class DynmapPlugin
bmap.setWaterColorMultiplier(watermult); bmap.setWaterColorMultiplier(watermult);
Log.verboseinfo("Set watercolormult for " + bmap.toString() + " (" + i + ") to " + Integer.toHexString(watermult)); Log.verboseinfo("Set watercolormult for " + bmap.toString() + " (" + i + ") to " + Integer.toHexString(watermult));
} }
bmap.setBiomeObject(bb);
} }
} }
if(cnt > 0) if(cnt > 0)

View File

@ -2,8 +2,11 @@ package org.dynmap.forge_1_18;
import java.util.List; import java.util.List;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.biome.BiomeSpecialEffects;
import org.dynmap.DynmapChunk; import org.dynmap.DynmapChunk;
import org.dynmap.Log; import org.dynmap.Log;
import org.dynmap.common.BiomeMap;
import org.dynmap.common.chunk.GenericChunk; import org.dynmap.common.chunk.GenericChunk;
import org.dynmap.common.chunk.GenericChunkCache; import org.dynmap.common.chunk.GenericChunkCache;
import org.dynmap.common.chunk.GenericMapChunkCache; import org.dynmap.common.chunk.GenericMapChunkCache;
@ -86,4 +89,17 @@ public class ForgeMapChunkCache extends GenericMapChunkCache {
return null; return null;
} }
} }
@Override
public int getFoliageColor(BiomeMap bm, int[] colormap, int x, int z) {
return bm.<Biome>getBiomeObject().map(Biome::getSpecialEffects)
.flatMap(BiomeSpecialEffects::getFoliageColorOverride)
.orElse(colormap[bm.biomeLookup()]);
}
@Override
public int getGrassColor(BiomeMap bm, int[] colormap, int x, int z) {
BiomeSpecialEffects effects = bm.<Biome>getBiomeObject().map(Biome::getSpecialEffects).orElse(null);
if (effects == null) return colormap[bm.biomeLookup()];
return effects.getGrassColorModifier().modifyColor(x, z, effects.getGrassColorOverride().orElse(colormap[bm.biomeLookup()]));
}
} }

View File

@ -1424,6 +1424,7 @@ public class DynmapPlugin
bmap.setWaterColorMultiplier(watermult); bmap.setWaterColorMultiplier(watermult);
Log.verboseinfo("Set watercolormult for " + bmap.toString() + " (" + i + ") to " + Integer.toHexString(watermult)); Log.verboseinfo("Set watercolormult for " + bmap.toString() + " (" + i + ") to " + Integer.toHexString(watermult));
} }
bmap.setBiomeObject(bb);
} }
} }
if(cnt > 0) if(cnt > 0)

View File

@ -3,8 +3,11 @@ package org.dynmap.forge_1_19_2;
import java.util.List; import java.util.List;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.biome.BiomeSpecialEffects;
import org.dynmap.DynmapChunk; import org.dynmap.DynmapChunk;
import org.dynmap.Log; import org.dynmap.Log;
import org.dynmap.common.BiomeMap;
import org.dynmap.common.chunk.GenericChunk; import org.dynmap.common.chunk.GenericChunk;
import org.dynmap.common.chunk.GenericChunkCache; import org.dynmap.common.chunk.GenericChunkCache;
import org.dynmap.common.chunk.GenericMapChunkCache; import org.dynmap.common.chunk.GenericMapChunkCache;
@ -87,4 +90,17 @@ public class ForgeMapChunkCache extends GenericMapChunkCache {
return null; return null;
} }
} }
@Override
public int getFoliageColor(BiomeMap bm, int[] colormap, int x, int z) {
return bm.<Biome>getBiomeObject().map(Biome::getSpecialEffects)
.flatMap(BiomeSpecialEffects::getFoliageColorOverride)
.orElse(colormap[bm.biomeLookup()]);
}
@Override
public int getGrassColor(BiomeMap bm, int[] colormap, int x, int z) {
BiomeSpecialEffects effects = bm.<Biome>getBiomeObject().map(Biome::getSpecialEffects).orElse(null);
if (effects == null) return colormap[bm.biomeLookup()];
return effects.getGrassColorModifier().modifyColor(x, z, effects.getGrassColorOverride().orElse(colormap[bm.biomeLookup()]));
}
} }

View File

@ -1424,6 +1424,7 @@ public class DynmapPlugin
bmap.setWaterColorMultiplier(watermult); bmap.setWaterColorMultiplier(watermult);
Log.verboseinfo("Set watercolormult for " + bmap.toString() + " (" + i + ") to " + Integer.toHexString(watermult)); Log.verboseinfo("Set watercolormult for " + bmap.toString() + " (" + i + ") to " + Integer.toHexString(watermult));
} }
bmap.setBiomeObject(bb);
} }
} }
if(cnt > 0) if(cnt > 0)

View File

@ -3,8 +3,11 @@ package org.dynmap.forge_1_19;
import java.util.List; import java.util.List;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.biome.BiomeSpecialEffects;
import org.dynmap.DynmapChunk; import org.dynmap.DynmapChunk;
import org.dynmap.Log; import org.dynmap.Log;
import org.dynmap.common.BiomeMap;
import org.dynmap.common.chunk.GenericChunk; import org.dynmap.common.chunk.GenericChunk;
import org.dynmap.common.chunk.GenericChunkCache; import org.dynmap.common.chunk.GenericChunkCache;
import org.dynmap.common.chunk.GenericMapChunkCache; import org.dynmap.common.chunk.GenericMapChunkCache;
@ -87,4 +90,17 @@ public class ForgeMapChunkCache extends GenericMapChunkCache {
return null; return null;
} }
} }
@Override
public int getFoliageColor(BiomeMap bm, int[] colormap, int x, int z) {
return bm.<Biome>getBiomeObject().map(Biome::getSpecialEffects)
.flatMap(BiomeSpecialEffects::getFoliageColorOverride)
.orElse(colormap[bm.biomeLookup()]);
}
@Override
public int getGrassColor(BiomeMap bm, int[] colormap, int x, int z) {
BiomeSpecialEffects effects = bm.<Biome>getBiomeObject().map(Biome::getSpecialEffects).orElse(null);
if (effects == null) return colormap[bm.biomeLookup()];
return effects.getGrassColorModifier().modifyColor(x, z, effects.getGrassColorOverride().orElse(colormap[bm.biomeLookup()]));
}
} }

View File

@ -875,6 +875,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
bmap.setWaterColorMultiplier(watermult); bmap.setWaterColorMultiplier(watermult);
Log.verboseinfo("Set watercolormult for " + bmap.toString() + " (" + i + ") to " + Integer.toHexString(watermult)); Log.verboseinfo("Set watercolormult for " + bmap.toString() + " (" + i + ") to " + Integer.toHexString(watermult));
} }
bmap.setBiomeObject(bb);
} }
} }
if(cnt > 0) { if(cnt > 0) {