Search in sources :

Example 1 with FlowerProvider

use of forestry.apiculture.flowers.FlowerProvider in project ForestryMC by ForestryMC.

the class AlleleHelper method createAllele.

private static <K extends IAlleleValue<V>, V> IAllele createAllele(String category, K enumValue, IChromosomeType... types) {
    V value = enumValue.getValue();
    boolean isDominant = enumValue.isDominant();
    String name = enumValue.toString().toLowerCase(Locale.ENGLISH);
    Class<?> valueClass = value.getClass();
    if (Float.class.isAssignableFrom(valueClass)) {
        return AlleleManager.alleleFactory.createFloat(modId, category, name, (Float) value, isDominant, types);
    } else if (Integer.class.isAssignableFrom(valueClass)) {
        return AlleleManager.alleleFactory.createInteger(modId, category, name, (Integer) value, isDominant, types);
    } else if (Vec3i.class.isAssignableFrom(valueClass)) {
        Vec3i area = (Vec3i) value;
        return AlleleManager.alleleFactory.createArea(modId, category, name, area, isDominant, types);
    } else if (Boolean.class.isAssignableFrom(valueClass)) {
        return AlleleManager.alleleFactory.createBoolean(modId, category, (Boolean) value, isDominant, types);
    } else if (EnumTolerance.class.isAssignableFrom(valueClass)) {
        IAlleleTolerance alleleTolerance = new AlleleTolerance(modId, category, name, (EnumTolerance) value, isDominant);
        AlleleManager.alleleRegistry.registerAllele(alleleTolerance, types);
        return alleleTolerance;
    } else if (FlowerProvider.class.isAssignableFrom(valueClass)) {
        return AlleleManager.alleleFactory.createFlowers(modId, category, name, (FlowerProvider) value, isDominant, types);
    }
    throw new RuntimeException("could not create allele for category: " + category + " and value " + valueClass);
}
Also used : IAlleleInteger(forestry.api.genetics.IAlleleInteger) Vec3i(net.minecraft.util.math.Vec3i) IAlleleTolerance(forestry.api.genetics.IAlleleTolerance) IAlleleBoolean(forestry.api.genetics.IAlleleBoolean) IAlleleTolerance(forestry.api.genetics.IAlleleTolerance) FlowerProvider(forestry.apiculture.flowers.FlowerProvider)

Aggregations

IAlleleBoolean (forestry.api.genetics.IAlleleBoolean)1 IAlleleInteger (forestry.api.genetics.IAlleleInteger)1 IAlleleTolerance (forestry.api.genetics.IAlleleTolerance)1 FlowerProvider (forestry.apiculture.flowers.FlowerProvider)1 Vec3i (net.minecraft.util.math.Vec3i)1