diff --git a/src/main/java/biomesoplenty/common/biome/BiomeMetadata.java b/src/main/java/biomesoplenty/common/biome/BiomeMetadata.java index 3b5d9d5fb..42ebd2a21 100644 --- a/src/main/java/biomesoplenty/common/biome/BiomeMetadata.java +++ b/src/main/java/biomesoplenty/common/biome/BiomeMetadata.java @@ -17,6 +17,7 @@ import net.minecraft.world.biome.Biomes; import javax.annotation.Nullable; import java.util.HashMap; import java.util.Map; +import java.util.function.BiFunction; public class BiomeMetadata { @@ -28,11 +29,19 @@ public class BiomeMetadata @Nullable private final RegistryKey riverBiome; - protected BiomeMetadata(Map weights, @Nullable RegistryKey beachBiome, @Nullable RegistryKey riverBiome) + @Nullable + private final BiFunction foliageColorFunction; + + @Nullable + private final BiFunction grassColorFunction; + + protected BiomeMetadata(Map weights, @Nullable RegistryKey beachBiome, @Nullable RegistryKey riverBiome, BiFunction foliageColorFunction, BiFunction grassColorFunction) { this.weightMap = ImmutableMap.copyOf(weights); this.beachBiome = beachBiome; this.riverBiome = riverBiome; + this.foliageColorFunction = foliageColorFunction; + this.grassColorFunction = grassColorFunction; } public Map getWeightMap() @@ -52,6 +61,18 @@ public class BiomeMetadata return this.riverBiome; } + @Nullable + public BiFunction getFoliageColorFunction() + { + return this.foliageColorFunction; + } + + @Nullable + public BiFunction getGrassColorFunction() + { + return this.grassColorFunction; + } + public boolean hasWeights() { return !this.weightMap.isEmpty() && !this.weightMap.entrySet().stream().allMatch((entry) -> entry.getValue().equals(0)); diff --git a/src/main/java/biomesoplenty/common/biome/BiomeTemplate.java b/src/main/java/biomesoplenty/common/biome/BiomeTemplate.java index e3822e29d..3c9e6fb03 100644 --- a/src/main/java/biomesoplenty/common/biome/BiomeTemplate.java +++ b/src/main/java/biomesoplenty/common/biome/BiomeTemplate.java @@ -25,12 +25,15 @@ import net.minecraftforge.registries.ForgeRegistries; import java.util.HashMap; import java.util.Map; +import java.util.function.BiFunction; public class BiomeTemplate { private Map weightMap = new HashMap(); private RegistryKey beachBiome = Biomes.BEACH; private RegistryKey riverBiome = Biomes.RIVER; + private BiFunction foliageColorFunction; + private BiFunction grassColorFunction; protected void configureBiome(Biome.Builder builder) {} protected void configureGeneration(BiomeGenerationSettingsRegistryBuilder builder) {} @@ -63,7 +66,7 @@ public class BiomeTemplate public final BiomeMetadata buildMetadata() { - return new BiomeMetadata(this.weightMap, this.beachBiome, this.riverBiome); + return new BiomeMetadata(this.weightMap, this.beachBiome, this.riverBiome, this.foliageColorFunction, this.grassColorFunction); } public void addWeight(BOPClimates climate, int weight) @@ -81,6 +84,16 @@ public class BiomeTemplate this.riverBiome = biome; } + public void setFoliageColorFunction(BiFunction func) + { + this.foliageColorFunction = func; + } + + public void setGrassColorFunction(BiFunction func) + { + this.grassColorFunction = func; + } + public static int calculateSkyColor(float temperature) { float lvt_1_1_ = temperature / 3.0F; diff --git a/src/main/java/biomesoplenty/common/biome/overworld/SilkgladeBiome.java b/src/main/java/biomesoplenty/common/biome/overworld/SilkgladeBiome.java index 1e4033e67..487d0a96d 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/SilkgladeBiome.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/SilkgladeBiome.java @@ -13,6 +13,7 @@ import biomesoplenty.common.biome.BiomeTemplate; import biomesoplenty.common.world.biome.BiomeFeatureHelper; import biomesoplenty.common.world.gen.feature.BOPConfiguredFeatures; import biomesoplenty.common.world.gen.feature.BOPFeatures; +import biomesoplenty.core.BiomesOPlenty; import com.google.common.collect.ImmutableList; import net.minecraft.block.Blocks; import net.minecraft.entity.EntityClassification; @@ -33,6 +34,7 @@ public class SilkgladeBiome extends BiomeTemplate this.addWeight(BOPClimates.DRY_TEMPERATE, 1); this.setBeachBiome(null); this.setRiverBiome(null); + this.setGrassColorFunction(this::getGrassColor); } @Override @@ -89,9 +91,10 @@ public class SilkgladeBiome extends BiomeTemplate builder.addSpawn(EntityClassification.MONSTER, new MobSpawnInfo.Spawners(EntityType.SLIME, 100, 4, 4)); } - //TODO: Change grass color to use new system in special effects - /*public int getGrassColor(double x, double z) { + private int getGrassColor(double x, double z) + { + BiomesOPlenty.logger.info("Color!"); double d0 = Biome.BIOME_INFO_NOISE.getValue(x * 0.0225D, z * 0.0225D, false); return d0 < -0.1D ? 0xB2B39F : 0x939F76; - }*/ + } }