Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,22 @@ public void setWaterFogColor(int color) {
throw new UnsupportedOperationException();
}

public int getSkyColor() {
throw new UnsupportedOperationException();
}

public void setSkyColor(int color) {
throw new UnsupportedOperationException();
}

public int getSkyLightColor() {
throw new UnsupportedOperationException();
}

public void setSkyLightColor(int color) {
throw new UnsupportedOperationException();
}

public abstract void setTo(Block block);

public ColorTag getColor(int x, int y) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,71 @@ else if (attribute.startsWith("water", 2)) {
object.biome.setPrecipitation(input.asEnum(BiomeNMS.DownfallType.class));
}
});

if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_21)) {

// <--[tag]
// @attribute <BiomeTag.sky_color>
// @returns ColorTag
// @mechanism BiomeTag.sky_color
// @description
// Returns the biome's sky color.
// @example
// # Sends the player a message in their current biome's sky color.
// - narrate "You are currently seeing sky that looks like <&color[<player.location.biome.sky_color>]>this!"
// -->
tagProcessor.registerTag(ColorTag.class, "sky_color", (attribute, object) -> {
return ColorTag.fromRGB(object.biome.getSkyColor());
});

// <--[tag]
// @attribute <BiomeTag.sky_light_color>
// @returns ColorTag
// @mechanism BiomeTag.sky_light_color
// @description
// Returns the biome's skylight color.
// @example
// # Sends the player a message in their current biome's skylight color.
// - narrate "You are currently seeing skylight that looks like <&color[<player.location.biome.sky_light_color>]>this!"
// -->
tagProcessor.registerTag(ColorTag.class, "sky_light_color", (attribute, object) -> {
return ColorTag.fromRGB(object.biome.getSkyLightColor());
});

// <--[mechanism]
// @object BiomeTag
// @name sky_color
// @input ColorTag
// @description
// Sets the biome's sky color.
// @tags
// <BiomeTag.sky_color>
// @example
// # Makes the plains biome's sky color red permanently, using a server start event to keep it applied.
// on server start:
// - adjust <biome[plains]> sky_color:red
// -->
tagProcessor.registerMechanism("sky_color", false, ColorTag.class, (object, mechanism, input) -> {
object.biome.setSkyColor(input.asRGB());
});

// <--[mechanism]
// @object BiomeTag
// @name sky_light_color
// @input ColorTag
// @description
// Sets the biome's skylight color.
// @tags
// <BiomeTag.sky_light_color>
// @example
// # Makes the plains biome's skylight color red permanently, using a server start event to keep it applied.
// on server start:
// - adjust <biome[plains]> sky_light_color:red
// -->
tagProcessor.registerMechanism("sky_light_color", false, ColorTag.class, (object, mechanism, input) -> {
object.biome.setSkyLightColor(input.asRGB());
});
}
}

public static final ObjectTagProcessor<BiomeTag> tagProcessor = new ObjectTagProcessor<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,26 @@ public void setWaterFogColor(int color) {
setEnvironmentAttribute(EnvironmentAttributes.WATER_FOG_COLOR, color);
}

@Override
public int getSkyColor() {
return getEnvironmentAttribute(EnvironmentAttributes.SKY_COLOR);
}

@Override
public void setSkyColor(int color) {
setEnvironmentAttribute(EnvironmentAttributes.SKY_COLOR, color);
}

@Override
public int getSkyLightColor() {
return getEnvironmentAttribute(EnvironmentAttributes.SKY_LIGHT_COLOR);
}

@Override
public void setSkyLightColor(int color) {
setEnvironmentAttribute(EnvironmentAttributes.SKY_LIGHT_COLOR, color);
}

public <T> T getEnvironmentAttribute(EnvironmentAttribute<T> attribute) {
return biomeHolder.value().getAttributes().applyModifier(attribute, attribute.defaultValue());
}
Expand Down