Water tint
This commit is contained in:
+1
-1
@@ -624,7 +624,7 @@ export function validate_block(json: unknown): Problems {
|
||||
if (json.tint !== undefined) {
|
||||
const tint = json.tint;
|
||||
if (!is_object(tint) || !is_tint_color(tint.color)) {
|
||||
problems.push('tint.color must be "grass", "foliage" or a color like "#80a755"');
|
||||
problems.push('tint.color must be "grass", "foliage", "water" or a color like "#80a755"');
|
||||
} else if (
|
||||
tint.textures !== undefined &&
|
||||
!(Array.isArray(tint.textures) && tint.textures.every((name) => typeof name === "string"))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// what color each biome tints grass and leaves, as 0xRRGGBB, minecraft's grass and foliage colors. blocks pick them
|
||||
// with "tint"
|
||||
// what color each biome tints grass, leaves and water, as 0xRRGGBB, minecraft's grass, foliage and water colors.
|
||||
// blocks pick them with "tint"
|
||||
export const BIOME_GRASS_COLORS: Record<string, number> = {
|
||||
"bworld:deep_ocean": 0x8eb971,
|
||||
"bworld:deep_frozen_ocean": 0x80b497,
|
||||
@@ -58,9 +58,39 @@ export const BIOME_FOLIAGE_COLORS: Record<string, number> = {
|
||||
"bworld:frozen_peaks": 0x60a17b,
|
||||
};
|
||||
|
||||
export const BIOME_WATER_COLORS: Record<string, number> = {
|
||||
"bworld:deep_ocean": 0x3f76e4,
|
||||
"bworld:deep_frozen_ocean": 0x3938c9,
|
||||
"bworld:deep_lukewarm_ocean": 0x45adf2,
|
||||
"bworld:ocean": 0x3f76e4,
|
||||
"bworld:frozen_ocean": 0x3938c9,
|
||||
"bworld:warm_ocean": 0x43d5ee,
|
||||
"bworld:river": 0x3f76e4,
|
||||
"bworld:frozen_river": 0x3938c9,
|
||||
"bworld:beach": 0x3f76e4,
|
||||
"bworld:snowy_beach": 0x3d57d6,
|
||||
"bworld:stony_shore": 0x3f76e4,
|
||||
"bworld:plains": 0x3f76e4,
|
||||
"bworld:meadow": 0x0e4ecf,
|
||||
"bworld:forest": 0x3f76e4,
|
||||
"bworld:dark_forest": 0x3f76e4,
|
||||
"bworld:swamp": 0x617b64,
|
||||
"bworld:taiga": 0x3f76e4,
|
||||
"bworld:snowy_plains": 0x3f76e4,
|
||||
"bworld:snowy_taiga": 0x3d57d6,
|
||||
"bworld:savanna": 0x3f76e4,
|
||||
"bworld:jungle": 0x3f76e4,
|
||||
"bworld:desert": 0x3f76e4,
|
||||
"bworld:snowy_slopes": 0x3f76e4,
|
||||
"bworld:stony_peaks": 0x3f76e4,
|
||||
"bworld:jagged_peaks": 0x3f76e4,
|
||||
"bworld:frozen_peaks": 0x3f76e4,
|
||||
};
|
||||
|
||||
// biomes mods add without a color, and items, which aren't in any biome
|
||||
export const DEFAULT_GRASS_COLOR = BIOME_GRASS_COLORS["bworld:plains"];
|
||||
export const DEFAULT_FOLIAGE_COLOR = BIOME_FOLIAGE_COLORS["bworld:plains"];
|
||||
export const DEFAULT_WATER_COLOR = BIOME_WATER_COLORS["bworld:plains"];
|
||||
|
||||
export function grass_color(biome: string | undefined) {
|
||||
return (biome !== undefined ? BIOME_GRASS_COLORS[biome] : undefined) ?? DEFAULT_GRASS_COLOR;
|
||||
@@ -70,16 +100,22 @@ export function foliage_color(biome: string | undefined) {
|
||||
return (biome !== undefined ? BIOME_FOLIAGE_COLORS[biome] : undefined) ?? DEFAULT_FOLIAGE_COLOR;
|
||||
}
|
||||
|
||||
// a block's "tint" color: the biome's grass or foliage color, or a fixed one like "#80a755"
|
||||
export type TintColor = "grass" | "foliage" | `#${string}`;
|
||||
|
||||
export function is_tint_color(value: unknown): value is TintColor {
|
||||
return value === "grass" || value === "foliage" || (typeof value === "string" && /^#[0-9a-fA-F]{6}$/.test(value));
|
||||
export function water_color(biome: string | undefined) {
|
||||
return (biome !== undefined ? BIOME_WATER_COLORS[biome] : undefined) ?? DEFAULT_WATER_COLOR;
|
||||
}
|
||||
|
||||
// the color outside any biome, for items: the default grass or foliage color, or the fixed one
|
||||
// a block's "tint" color: the biome's grass, foliage or water color, or a fixed one like "#80a755"
|
||||
export type TintColor = "grass" | "foliage" | "water" | `#${string}`;
|
||||
|
||||
export function is_tint_color(value: unknown): value is TintColor {
|
||||
return value === "grass" || value === "foliage" || value === "water" ||
|
||||
(typeof value === "string" && /^#[0-9a-fA-F]{6}$/.test(value));
|
||||
}
|
||||
|
||||
// the color outside any biome, for items: the default grass, foliage or water color, or the fixed one
|
||||
export function tint_without_biome(color: TintColor) {
|
||||
if (color === "grass") return DEFAULT_GRASS_COLOR;
|
||||
if (color === "foliage") return DEFAULT_FOLIAGE_COLOR;
|
||||
if (color === "water") return DEFAULT_WATER_COLOR;
|
||||
return parseInt(color.slice(1), 16);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user