wip colour stuff

This commit is contained in:
Adubbz 2020-09-24 13:38:59 +10:00
parent f0663276d3
commit 39aec91eb2
3 changed files with 42 additions and 5 deletions

View file

@ -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<Biome> riverBiome;
protected BiomeMetadata(Map<BOPClimates, Integer> weights, @Nullable RegistryKey<Biome> beachBiome, @Nullable RegistryKey<Biome> riverBiome)
@Nullable
private final BiFunction<Double, Double, Integer> foliageColorFunction;
@Nullable
private final BiFunction<Double, Double, Integer> grassColorFunction;
protected BiomeMetadata(Map<BOPClimates, Integer> weights, @Nullable RegistryKey<Biome> beachBiome, @Nullable RegistryKey<Biome> riverBiome, BiFunction<Double, Double, Integer> foliageColorFunction, BiFunction<Double, Double, Integer> grassColorFunction)
{
this.weightMap = ImmutableMap.copyOf(weights);
this.beachBiome = beachBiome;
this.riverBiome = riverBiome;
this.foliageColorFunction = foliageColorFunction;
this.grassColorFunction = grassColorFunction;
}
public Map<BOPClimates, Integer> getWeightMap()
@ -52,6 +61,18 @@ public class BiomeMetadata
return this.riverBiome;
}
@Nullable
public BiFunction<Double, Double, Integer> getFoliageColorFunction()
{
return this.foliageColorFunction;
}
@Nullable
public BiFunction<Double, Double, Integer> getGrassColorFunction()
{
return this.grassColorFunction;
}
public boolean hasWeights()
{
return !this.weightMap.isEmpty() && !this.weightMap.entrySet().stream().allMatch((entry) -> entry.getValue().equals(0));

View file

@ -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<BOPClimates, Integer> weightMap = new HashMap<BOPClimates, Integer>();
private RegistryKey<Biome> beachBiome = Biomes.BEACH;
private RegistryKey<Biome> riverBiome = Biomes.RIVER;
private BiFunction<Double, Double, Integer> foliageColorFunction;
private BiFunction<Double, Double, Integer> 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<Double, Double, Integer> func)
{
this.foliageColorFunction = func;
}
public void setGrassColorFunction(BiFunction<Double, Double, Integer> func)
{
this.grassColorFunction = func;
}
public static int calculateSkyColor(float temperature)
{
float lvt_1_1_ = temperature / 3.0F;

View file

@ -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;
}*/
}
}