Search in sources :

Example 1 with IDensitySelector

use of com.ferreusveritas.dynamictrees.api.worldgen.BiomePropertySelectors.IDensitySelector in project DynamicTrees by DynamicTreesTeam.

the class JsonBiomePropertyApplierDensity method readDensitySelector.

private static IDensitySelector readDensitySelector(JsonObject mainObject, Biome biome) {
    JsonElement scaleElement = mainObject.get("scale");
    if (scaleElement != null && scaleElement.isJsonArray()) {
        return createScaleDensitySelector(scaleElement.getAsJsonArray());
    }
    JsonElement staticElement = mainObject.get("static");
    if (staticElement != null && staticElement.isJsonPrimitive() && staticElement.getAsJsonPrimitive().isNumber()) {
        return (rnd, n) -> staticElement.getAsJsonPrimitive().getAsFloat();
    }
    JsonElement mathElement = mainObject.get("math");
    if (mathElement != null) {
        JsonMath m = new JsonMath(mathElement, biome);
        return (rnd, n) -> m.apply(rnd, (float) n);
    }
    return null;
}
Also used : JsonElement(com.google.gson.JsonElement) JsonObject(com.google.gson.JsonObject) JsonArray(com.google.gson.JsonArray) List(java.util.List) MathHelper(net.minecraft.util.math.MathHelper) BiomeDataBase(com.ferreusveritas.dynamictrees.worldgen.BiomeDataBase) Operation(com.ferreusveritas.dynamictrees.worldgen.BiomeDataBase.Operation) JsonPrimitive(com.google.gson.JsonPrimitive) IDensitySelector(com.ferreusveritas.dynamictrees.api.worldgen.BiomePropertySelectors.IDensitySelector) Biome(net.minecraft.world.biome.Biome) ArrayList(java.util.ArrayList) JsonElement(com.google.gson.JsonElement)

Aggregations

IDensitySelector (com.ferreusveritas.dynamictrees.api.worldgen.BiomePropertySelectors.IDensitySelector)1 BiomeDataBase (com.ferreusveritas.dynamictrees.worldgen.BiomeDataBase)1 Operation (com.ferreusveritas.dynamictrees.worldgen.BiomeDataBase.Operation)1 JsonArray (com.google.gson.JsonArray)1 JsonElement (com.google.gson.JsonElement)1 JsonObject (com.google.gson.JsonObject)1 JsonPrimitive (com.google.gson.JsonPrimitive)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 MathHelper (net.minecraft.util.math.MathHelper)1 Biome (net.minecraft.world.biome.Biome)1