Search in sources :

Example 1 with EnumTolerance

use of forestry.api.genetics.EnumTolerance in project ForestryMC by ForestryMC.

the class Butterfly method getCanGrow.

@Override
public Set<IErrorState> getCanGrow(IButterflyNursery nursery, @Nullable IButterflyCocoon cocoon) {
    World world = nursery.getWorldObj();
    Set<IErrorState> errorStates = new HashSet<>();
    // / And finally climate check
    IAlleleButterflySpecies species = genome.getPrimary();
    EnumTemperature actualTemperature = nursery.getTemperature();
    EnumTemperature baseTemperature = species.getTemperature();
    EnumTolerance toleranceTemperature = genome.getToleranceTemp();
    EnumHumidity actualHumidity = nursery.getHumidity();
    EnumHumidity baseHumidity = species.getHumidity();
    EnumTolerance toleranceHumidity = genome.getToleranceHumid();
    ClimateUtil.addClimateErrorStates(actualTemperature, actualHumidity, baseTemperature, toleranceTemperature, baseHumidity, toleranceHumidity, errorStates);
    return errorStates;
}
Also used : IErrorState(forestry.api.core.IErrorState) EnumTolerance(forestry.api.genetics.EnumTolerance) EnumHumidity(forestry.api.core.EnumHumidity) World(net.minecraft.world.World) HashSet(java.util.HashSet) IAlleleButterflySpecies(forestry.api.lepidopterology.IAlleleButterflySpecies) EnumTemperature(forestry.api.core.EnumTemperature)

Example 2 with EnumTolerance

use of forestry.api.genetics.EnumTolerance in project ForestryMC by ForestryMC.

the class Bee method getCanWork.

@Override
public Set<IErrorState> getCanWork(IBeeHousing housing) {
    World world = housing.getWorldObj();
    Set<IErrorState> errorStates = new HashSet<>();
    IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
    // / Rain needs tolerant flyers
    if (housing.isRaining() && !canFlyInRain(beeModifier)) {
        errorStates.add(EnumErrorCode.IS_RAINING);
    }
    // / Night or darkness requires nocturnal species
    if (world.isDaytime()) {
        if (!canWorkDuringDay()) {
            errorStates.add(EnumErrorCode.NOT_NIGHT);
        }
    } else {
        if (!canWorkAtNight(beeModifier)) {
            errorStates.add(EnumErrorCode.NOT_DAY);
        }
    }
    if (housing.getBlockLightValue() > Constants.APIARY_MIN_LEVEL_LIGHT) {
        if (!canWorkDuringDay()) {
            errorStates.add(EnumErrorCode.NOT_GLOOMY);
        }
    } else {
        if (!canWorkAtNight(beeModifier)) {
            errorStates.add(EnumErrorCode.NOT_BRIGHT);
        }
    }
    // / Check for the sky, except if in hell
    if (!world.provider.isNether()) {
        if (!housing.canBlockSeeTheSky() && !canWorkUnderground(beeModifier)) {
            errorStates.add(EnumErrorCode.NO_SKY);
        }
    }
    // / And finally climate check
    IAlleleBeeSpecies species = genome.getPrimary();
    {
        EnumTemperature actualTemperature = housing.getTemperature();
        EnumTemperature beeBaseTemperature = species.getTemperature();
        EnumTolerance beeToleranceTemperature = genome.getToleranceTemp();
        if (!AlleleManager.climateHelper.isWithinLimits(actualTemperature, beeBaseTemperature, beeToleranceTemperature)) {
            if (beeBaseTemperature.ordinal() > actualTemperature.ordinal()) {
                errorStates.add(EnumErrorCode.TOO_COLD);
            } else {
                errorStates.add(EnumErrorCode.TOO_HOT);
            }
        }
    }
    {
        EnumHumidity actualHumidity = housing.getHumidity();
        EnumHumidity beeBaseHumidity = species.getHumidity();
        EnumTolerance beeToleranceHumidity = genome.getToleranceHumid();
        if (!AlleleManager.climateHelper.isWithinLimits(actualHumidity, beeBaseHumidity, beeToleranceHumidity)) {
            if (beeBaseHumidity.ordinal() > actualHumidity.ordinal()) {
                errorStates.add(EnumErrorCode.TOO_ARID);
            } else {
                errorStates.add(EnumErrorCode.TOO_HUMID);
            }
        }
    }
    return errorStates;
}
Also used : IAlleleBeeSpecies(forestry.api.apiculture.IAlleleBeeSpecies) IBeeModifier(forestry.api.apiculture.IBeeModifier) IErrorState(forestry.api.core.IErrorState) EnumTolerance(forestry.api.genetics.EnumTolerance) EnumHumidity(forestry.api.core.EnumHumidity) World(net.minecraft.world.World) HashSet(java.util.HashSet) EnumTemperature(forestry.api.core.EnumTemperature)

Example 3 with EnumTolerance

use of forestry.api.genetics.EnumTolerance in project ForestryMC by ForestryMC.

the class GuiAlyzer method drawToleranceInfo.

public void drawToleranceInfo(IAlleleTolerance toleranceAllele, int x) {
    int textColor = getColorCoding(toleranceAllele.isDominant());
    EnumTolerance tolerance = toleranceAllele.getValue();
    String text = "(" + toleranceAllele.getAlleleName() + ")";
    // Enable correct lighting.
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    switch(tolerance) {
        case BOTH_1:
        case BOTH_2:
        case BOTH_3:
        case BOTH_4:
        case BOTH_5:
            drawBothSymbol(x - 2, textLayout.getLineY() - 1);
            textLayout.drawLine(text, x + 14, textColor);
            break;
        case DOWN_1:
        case DOWN_2:
        case DOWN_3:
        case DOWN_4:
        case DOWN_5:
            drawDownSymbol(x - 2, textLayout.getLineY() - 1);
            textLayout.drawLine(text, x + 14, textColor);
            break;
        case UP_1:
        case UP_2:
        case UP_3:
        case UP_4:
        case UP_5:
            drawUpSymbol(x - 2, textLayout.getLineY() - 1);
            textLayout.drawLine(text, x + 14, textColor);
            break;
        default:
            drawNoneSymbol(x - 2, textLayout.getLineY() - 1);
            textLayout.drawLine("(0)", x + 14, textColor);
            break;
    }
}
Also used : EnumTolerance(forestry.api.genetics.EnumTolerance)

Example 4 with EnumTolerance

use of forestry.api.genetics.EnumTolerance in project ForestryMC by ForestryMC.

the class GuiElementFactory method createToleranceInfo.

private IGuiElementLayout createToleranceInfo(IAlleleTolerance toleranceAllele, int x) {
    int textColor = getColorCoding(toleranceAllele.isDominant());
    EnumTolerance tolerance = toleranceAllele.getValue();
    String text = "(" + toleranceAllele.getAlleleName() + ")";
    IGuiElementLayout layout = createHorizontal(x, 0, 0).setDistance(2);
    switch(tolerance) {
        case BOTH_1:
        case BOTH_2:
        case BOTH_3:
        case BOTH_4:
        case BOTH_5:
            layout.addElement(createBothSymbol(0, -1));
            layout.addElement(new GuiElementText(0, 0, 12, text, textColor));
            break;
        case DOWN_1:
        case DOWN_2:
        case DOWN_3:
        case DOWN_4:
        case DOWN_5:
            layout.addElement(createDownSymbol(0, -1));
            layout.addElement(new GuiElementText(0, 0, 12, text, textColor));
            break;
        case UP_1:
        case UP_2:
        case UP_3:
        case UP_4:
        case UP_5:
            layout.addElement(createUpSymbol(0, -1));
            layout.addElement(new GuiElementText(0, 0, 12, text, textColor));
            break;
        default:
            layout.addElement(createNoneSymbol(0, -1));
            layout.addElement(new GuiElementText(0, 0, 12, "(0)", textColor));
            break;
    }
    return layout;
}
Also used : EnumTolerance(forestry.api.genetics.EnumTolerance) IGuiElementLayout(forestry.api.core.IGuiElementLayout)

Example 5 with EnumTolerance

use of forestry.api.genetics.EnumTolerance in project ForestryMC by ForestryMC.

the class Butterfly method getCanSpawn.

@Override
public Set<IErrorState> getCanSpawn(IButterflyNursery nursery, @Nullable IButterflyCocoon cocoon) {
    World world = nursery.getWorldObj();
    Set<IErrorState> errorStates = new HashSet<>();
    // / Night or darkness requires nocturnal species
    boolean isDaytime = world.isDaytime();
    if (!isActiveThisTime(isDaytime)) {
        if (isDaytime) {
            errorStates.add(EnumErrorCode.NOT_NIGHT);
        } else {
            errorStates.add(EnumErrorCode.NOT_DAY);
        }
    }
    // / And finally climate check
    IAlleleButterflySpecies species = genome.getPrimary();
    EnumTemperature actualTemperature = nursery.getTemperature();
    EnumTemperature baseTemperature = species.getTemperature();
    EnumTolerance toleranceTemperature = genome.getToleranceTemp();
    EnumHumidity actualHumidity = nursery.getHumidity();
    EnumHumidity baseHumidity = species.getHumidity();
    EnumTolerance toleranceHumidity = genome.getToleranceHumid();
    ClimateUtil.addClimateErrorStates(actualTemperature, actualHumidity, baseTemperature, toleranceTemperature, baseHumidity, toleranceHumidity, errorStates);
    return errorStates;
}
Also used : IErrorState(forestry.api.core.IErrorState) EnumTolerance(forestry.api.genetics.EnumTolerance) EnumHumidity(forestry.api.core.EnumHumidity) World(net.minecraft.world.World) HashSet(java.util.HashSet) IAlleleButterflySpecies(forestry.api.lepidopterology.IAlleleButterflySpecies) EnumTemperature(forestry.api.core.EnumTemperature)

Aggregations

EnumTolerance (forestry.api.genetics.EnumTolerance)6 EnumHumidity (forestry.api.core.EnumHumidity)3 EnumTemperature (forestry.api.core.EnumTemperature)3 IErrorState (forestry.api.core.IErrorState)3 HashSet (java.util.HashSet)3 World (net.minecraft.world.World)3 IAlleleButterflySpecies (forestry.api.lepidopterology.IAlleleButterflySpecies)2 IAlleleBeeSpecies (forestry.api.apiculture.IAlleleBeeSpecies)1 IBeeGenome (forestry.api.apiculture.IBeeGenome)1 IBeeModifier (forestry.api.apiculture.IBeeModifier)1 IGuiElementLayout (forestry.api.core.IGuiElementLayout)1 IAllele (forestry.api.genetics.IAllele)1