Search in sources :

Example 1 with FunctionPredicate

use of com.almuradev.content.component.predicate.FunctionPredicate in project Almura by AlmuraDev.

the class Growth method getOrLoadTemperatureRequiredRangeForBiome.

@Nullable
public DoubleRange getOrLoadTemperatureRequiredRangeForBiome(final Biome biome) {
    @Nullable DoubleRange found = this.biomeTemperatureRequiredRanges.get(biome);
    if (found == null) {
        for (final Map.Entry<FunctionPredicate<Biome, ResourceLocation>, DoubleRange> entry : this.biomeTemperatureRequiredPredicates.entrySet()) {
            final FunctionPredicate<Biome, ResourceLocation> predicate = entry.getKey();
            if (predicate.test(biome)) {
                final DoubleRange range = entry.getValue();
                this.biomeTemperatureRequiredRanges.put(biome, range);
                found = range;
                break;
            }
        }
    }
    if (found == null && this.globalTemperatureRequiredRange != null) {
        this.biomeTemperatureRequiredRanges.put(biome, this.globalTemperatureRequiredRange);
        found = this.globalTemperatureRequiredRange;
    }
    return found;
}
Also used : DoubleRange(com.almuradev.toolbox.util.math.DoubleRange) Biome(net.minecraft.world.biome.Biome) ResourceLocation(net.minecraft.util.ResourceLocation) FunctionPredicate(com.almuradev.content.component.predicate.FunctionPredicate) HashMap(java.util.HashMap) Map(java.util.Map) Nullable(javax.annotation.Nullable) Nullable(javax.annotation.Nullable)

Example 2 with FunctionPredicate

use of com.almuradev.content.component.predicate.FunctionPredicate in project Almura by AlmuraDev.

the class Growth method getOrLoadChanceRangeForBiome.

@Nullable
public DoubleRange getOrLoadChanceRangeForBiome(final Biome biome) {
    @Nullable DoubleRange found = this.biomeChanceRanges.get(biome);
    if (found == null) {
        for (final Map.Entry<FunctionPredicate<Biome, ResourceLocation>, DoubleRange> entry : this.biomeChancePredicates.entrySet()) {
            final FunctionPredicate<Biome, ResourceLocation> predicate = entry.getKey();
            if (predicate.test(biome)) {
                final DoubleRange range = entry.getValue();
                this.biomeChanceRanges.put(biome, range);
                found = range;
                break;
            }
        }
    }
    if (found == null && this.globalChanceRange != null) {
        this.biomeChanceRanges.put(biome, this.globalChanceRange);
        found = this.globalChanceRange;
    }
    return found;
}
Also used : DoubleRange(com.almuradev.toolbox.util.math.DoubleRange) Biome(net.minecraft.world.biome.Biome) ResourceLocation(net.minecraft.util.ResourceLocation) FunctionPredicate(com.almuradev.content.component.predicate.FunctionPredicate) HashMap(java.util.HashMap) Map(java.util.Map) Nullable(javax.annotation.Nullable) Nullable(javax.annotation.Nullable)

Example 3 with FunctionPredicate

use of com.almuradev.content.component.predicate.FunctionPredicate in project Almura by AlmuraDev.

the class Grass method getOrLoadChanceRangeForBiome.

@Nullable
public DoubleRange getOrLoadChanceRangeForBiome(final Biome biome) {
    @Nullable DoubleRange found = this.biomeChanceRanges.get(biome);
    if (found == null) {
        for (final Map.Entry<FunctionPredicate<Biome, ResourceLocation>, DoubleRange> entry : this.biomeChancePredicates.entrySet()) {
            final FunctionPredicate<Biome, ResourceLocation> predicate = entry.getKey();
            if (predicate.test(biome)) {
                final DoubleRange range = entry.getValue();
                this.biomeChanceRanges.put(biome, range);
                found = range;
                break;
            }
        }
    }
    if (found == null && this.globalChanceRange != null) {
        this.biomeChanceRanges.put(biome, this.globalChanceRange);
        found = this.globalChanceRange;
    }
    return found;
}
Also used : DoubleRange(com.almuradev.toolbox.util.math.DoubleRange) Biome(net.minecraft.world.biome.Biome) ResourceLocation(net.minecraft.util.ResourceLocation) FunctionPredicate(com.almuradev.content.component.predicate.FunctionPredicate) HashMap(java.util.HashMap) Map(java.util.Map) Nullable(javax.annotation.Nullable) Nullable(javax.annotation.Nullable)

Example 4 with FunctionPredicate

use of com.almuradev.content.component.predicate.FunctionPredicate in project Almura by AlmuraDev.

the class Grass method getOrLoadAmountRequiredRangeForBiome.

@Nullable
public IntRange getOrLoadAmountRequiredRangeForBiome(final Biome biome) {
    @Nullable IntRange found = this.biomeAmountRanges.get(biome);
    if (found == null) {
        for (final Map.Entry<FunctionPredicate<Biome, ResourceLocation>, IntRange> entry : this.biomeAmountPredicates.entrySet()) {
            final FunctionPredicate<Biome, ResourceLocation> predicate = entry.getKey();
            if (predicate.test(biome)) {
                final IntRange range = entry.getValue();
                this.biomeAmountRanges.put(biome, range);
                found = range;
                break;
            }
        }
    }
    if (found == null && this.globalAmountRange != null) {
        this.biomeAmountRanges.put(biome, this.globalAmountRange);
        found = this.globalAmountRange;
    }
    return found;
}
Also used : Biome(net.minecraft.world.biome.Biome) ResourceLocation(net.minecraft.util.ResourceLocation) IntRange(com.almuradev.toolbox.util.math.IntRange) FunctionPredicate(com.almuradev.content.component.predicate.FunctionPredicate) HashMap(java.util.HashMap) Map(java.util.Map) Nullable(javax.annotation.Nullable) Nullable(javax.annotation.Nullable)

Example 5 with FunctionPredicate

use of com.almuradev.content.component.predicate.FunctionPredicate in project Almura by AlmuraDev.

the class Growth method getOrLoadLightRangeForBiome.

@Nullable
public DoubleRange getOrLoadLightRangeForBiome(final Biome biome) {
    @Nullable DoubleRange found = this.biomeLightRanges.get(biome);
    if (found == null) {
        for (final Map.Entry<FunctionPredicate<Biome, ResourceLocation>, DoubleRange> entry : this.biomeLightPredicates.entrySet()) {
            final FunctionPredicate<Biome, ResourceLocation> predicate = entry.getKey();
            if (predicate.test(biome)) {
                final DoubleRange range = entry.getValue();
                this.biomeLightRanges.put(biome, range);
                found = range;
                break;
            }
        }
    }
    if (found == null && this.globalLightRange != null) {
        this.biomeLightRanges.put(biome, this.globalLightRange);
        found = this.globalLightRange;
    }
    return found;
}
Also used : DoubleRange(com.almuradev.toolbox.util.math.DoubleRange) Biome(net.minecraft.world.biome.Biome) ResourceLocation(net.minecraft.util.ResourceLocation) FunctionPredicate(com.almuradev.content.component.predicate.FunctionPredicate) HashMap(java.util.HashMap) Map(java.util.Map) Nullable(javax.annotation.Nullable) Nullable(javax.annotation.Nullable)

Aggregations

FunctionPredicate (com.almuradev.content.component.predicate.FunctionPredicate)5 HashMap (java.util.HashMap)5 Map (java.util.Map)5 Nullable (javax.annotation.Nullable)5 ResourceLocation (net.minecraft.util.ResourceLocation)5 Biome (net.minecraft.world.biome.Biome)5 DoubleRange (com.almuradev.toolbox.util.math.DoubleRange)4 IntRange (com.almuradev.toolbox.util.math.IntRange)1