Skip to content

Commit 11398df

Browse files
committed
feat(custom-biome-colors): Allow empty colors for custom biomes
1 parent 1a5397d commit 11398df

4 files changed

Lines changed: 49 additions & 34 deletions

File tree

main/src/main/java/me/outspending/biomesapi/biome/CustomBiome.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -325,14 +325,14 @@ class Builder {
325325
private BiomeResourceKey resourceKey = null;
326326
private BiomeSettings settings = BiomeSettings.defaultSettings();
327327

328-
private int fogColor = 0;
329-
private int waterColor = 0;
330-
private int waterFogColor = 0;
331-
private int skyColor = 0;
332-
333-
private int foliageColor = 0;
334-
private int grassColor = 0;
335-
private int dryFoliageColor = 0;
328+
private int fogColor = -1;
329+
private int waterColor = -1;
330+
private int waterFogColor = -1;
331+
private int skyColor = -1;
332+
333+
private int foliageColor = -1;
334+
private int grassColor = -1;
335+
private int dryFoliageColor = -1;
336336

337337
private GrassColorModifier grassColorModifier = GrassColorModifier.NONE;
338338
private ParticleRenderer particleRenderer = ParticleRenderer.EMPTY;

main/src/main/java/me/outspending/biomesapi/biome/CustomBiomeImpl.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,22 @@ public final class CustomBiomeImpl implements CustomBiome {
3030
private final BiomeSettings settings;
3131

3232
// Required Colors
33-
private int fogColor;
34-
private int waterColor;
35-
private int waterFogColor;
36-
private int skyColor;
33+
private int fogColor = -1;
34+
private int waterColor = -1;
35+
private int waterFogColor = -1;
36+
private int skyColor = -1;
3737

3838
// Optional Colors
39-
private int foliageColor = 0;
40-
private int grassColor = 0;
41-
private int dryFoliageColor = 0;
39+
private int foliageColor = -1;
40+
private int grassColor = -1;
41+
private int dryFoliageColor = -1;
4242

4343
// Optional Settings
4444
private GrassColorModifier grassColorModifier = GrassColorModifier.NONE;
45-
private ParticleRenderer particleRenderer;
46-
private BlockReplacement[] blockReplacements;
45+
private ParticleRenderer particleRenderer = ParticleRenderer.EMPTY;
46+
private BlockReplacement[] blockReplacements = new BlockReplacement[0];
4747

48-
private WrappedEnvironmentAttributeMap environmentAttributeMap;
48+
private WrappedEnvironmentAttributeMap environmentAttributeMap = WrappedEnvironmentAttributeMap.EMPTY;
4949

5050
@AsOf("0.0.2")
5151
public CustomBiomeImpl(

main/src/main/java/me/outspending/biomesapi/registry/CustomBiomeRegistry.java

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,18 @@ public void register(@NotNull CustomBiome biome) {
7878
.temperatureAdjustment(settings.modifier().getModifier())
7979
.hasPrecipitation(settings.hasPrecipitation())
8080
.mobSpawnSettings(MobSpawnSettings.EMPTY)
81-
.generationSettings(BiomeGenerationSettings.EMPTY)
82-
.setAttribute(EnvironmentAttributes.FOG_COLOR, biome.getFogColor())
83-
.setAttribute(EnvironmentAttributes.SKY_COLOR, biome.getSkyColor())
84-
.setAttribute(EnvironmentAttributes.WATER_FOG_COLOR, biome.getWaterColor());
81+
.generationSettings(BiomeGenerationSettings.EMPTY);
82+
83+
// TODO: Replace with WrappedEnvironmentAttributeMap in the future
84+
if (biome.getFogColor() != -1) {
85+
biomeBuilder.setAttribute(EnvironmentAttributes.FOG_COLOR, biome.getFogColor());
86+
}
87+
if (biome.getSkyColor() != -1) {
88+
biomeBuilder.setAttribute(EnvironmentAttributes.SKY_COLOR, biome.getWaterColor());
89+
}
90+
if (biome.getWaterFogColor() != -1) {
91+
biomeBuilder.setAttribute(EnvironmentAttributes.WATER_FOG_COLOR, biome.getWaterFogColor());
92+
}
8593

8694
// Create a new Biome object with the settings and colors from the CustomBiome object
8795
BiomeSpecialEffects effects = SPECIAL_EFFECTS_HANDLER.build(biome);
@@ -100,8 +108,6 @@ public void register(@NotNull CustomBiome biome) {
100108
Registry.register(registry, resourceLocation, createdBiome);
101109
}
102110

103-
System.out.println(createdBiome.getAttributes());
104-
105111
// Add the custom biome to the list of registered biomes
106112
BiomeHandler.getRegisteredBiomes().add(biome);
107113
});
@@ -141,12 +147,21 @@ public void modify(@NotNull CustomBiome customBiome) {
141147
List<net.minecraft.world.attribute.AmbientParticle> particles = RENDERER_HANDLER.create(particleRenderer);
142148

143149

144-
EnvironmentAttributeMap environmentAttributeMap = EnvironmentAttributeMap.builder()
145-
.set(EnvironmentAttributes.FOG_COLOR, customBiome.getFogColor())
146-
.set(EnvironmentAttributes.SKY_COLOR, customBiome.getSkyColor())
147-
.set(EnvironmentAttributes.WATER_FOG_COLOR, customBiome.getWaterColor())
148-
.set(EnvironmentAttributes.AMBIENT_PARTICLES, particles)
149-
.build();
150+
EnvironmentAttributeMap.Builder environmentAttributeMapBuilder = EnvironmentAttributeMap.builder()
151+
.set(EnvironmentAttributes.AMBIENT_PARTICLES, particles);
152+
153+
// TODO: Replace with WrappedEnvironmentAttributeMap in the future
154+
if (customBiome.getFogColor() != -1) {
155+
environmentAttributeMapBuilder.set(EnvironmentAttributes.FOG_COLOR, customBiome.getFogColor());
156+
}
157+
if (customBiome.getSkyColor() != -1) {
158+
environmentAttributeMapBuilder.set(EnvironmentAttributes.SKY_COLOR, customBiome.getSkyColor());
159+
}
160+
if (customBiome.getWaterFogColor() != -1) {
161+
environmentAttributeMapBuilder.set(EnvironmentAttributes.WATER_FOG_COLOR, customBiome.getWaterFogColor());
162+
}
163+
164+
EnvironmentAttributeMap environmentAttributeMap = environmentAttributeMapBuilder.build();
150165

151166
BiomeSpecialEffects specialEffects = SPECIAL_EFFECTS_HANDLER.build(customBiome);
152167

main/src/main/java/me/outspending/biomesapi/registry/handlers/SpecialEffectsHandler.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@ public void handle(BiomeSpecialEffects value, @NotNull Biome.BiomeBuilder builde
2020
@Override
2121
public BiomeSpecialEffects build(@NotNull CustomBiome biome) {
2222
BiomeSpecialEffects.Builder builder = new BiomeSpecialEffects.Builder();
23-
if (biome.getFoliageColor() != 0) {
23+
if (biome.getFoliageColor() != -1) {
2424
builder.foliageColorOverride(biome.getFoliageColor());
2525
}
2626

27-
if (biome.getWaterColor() != 0) {
27+
if (biome.getWaterColor() != -1) {
2828
builder.waterColor(biome.getWaterColor());
2929
}
3030

31-
if (biome.getGrassColor() != 0) {
31+
if (biome.getGrassColor() != -1) {
3232
builder.grassColorOverride(biome.getGrassColor());
3333
}
3434

35-
if (biome.getDryFoliageColor() != 0) {
35+
if (biome.getDryFoliageColor() != -1) {
3636
builder.dryFoliageColorOverride(biome.getDryFoliageColor());
3737
}
3838

0 commit comments

Comments
 (0)