Search in sources :

Example 6 with EnumMoisture

use of binnie.botany.api.gardening.EnumMoisture in project Binnie by ForestryMC.

the class GardeningManager method canTolerate.

@Override
public boolean canTolerate(@Nullable IFlower flower, World world, BlockPos pos) {
    if (flower == null) {
        return false;
    }
    IBlockState soil = world.getBlockState(pos.down());
    Biome biome = world.getBiome(pos);
    EnumAcidity acidity = soil.getValue(BlockSoil.ACIDITY);
    EnumMoisture moisture = soil.getValue(BlockSoil.MOISTURE);
    EnumTemperature temperature = EnumTemperature.getFromValue(biome.getTemperature());
    return canTolerate(flower, acidity, moisture, temperature);
}
Also used : EnumMoisture(binnie.botany.api.gardening.EnumMoisture) IBlockState(net.minecraft.block.state.IBlockState) Biome(net.minecraft.world.biome.Biome) EnumAcidity(binnie.botany.api.gardening.EnumAcidity) EnumTemperature(forestry.api.core.EnumTemperature)

Example 7 with EnumMoisture

use of binnie.botany.api.gardening.EnumMoisture in project Binnie by ForestryMC.

the class BlockSoil method updateTick.

@Override
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
    EnumMoisture moisture = state.getValue(MOISTURE);
    EnumMoisture desiredMoisture = BotanyCore.getGardening().getNaturalMoisture(world, pos);
    if (desiredMoisture.ordinal() > moisture.ordinal()) {
        moisture = ((moisture == EnumMoisture.DRY) ? EnumMoisture.NORMAL : EnumMoisture.DAMP);
    } else if (desiredMoisture.ordinal() < moisture.ordinal()) {
        moisture = ((moisture == EnumMoisture.DAMP) ? EnumMoisture.NORMAL : EnumMoisture.DRY);
    }
    IBlockState blockState = state.withProperty(MOISTURE, moisture);
    if (state != blockState) {
        world.setBlockState(pos, blockState, 2);
    }
    if (!weedKilled) {
        if (rand.nextInt(5 - getType(world, pos).ordinal()) != 0) {
            return;
        }
        pos = pos.up();
        if (!world.isAirBlock(pos)) {
            return;
        }
        world.setBlockState(pos, ModuleGardening.plant.getStateFromMeta(PlantType.WEEDS.ordinal()), 2);
    }
}
Also used : EnumMoisture(binnie.botany.api.gardening.EnumMoisture) IBlockState(net.minecraft.block.state.IBlockState)

Example 8 with EnumMoisture

use of binnie.botany.api.gardening.EnumMoisture in project Binnie by ForestryMC.

the class BlockSoil method registerModel.

@Override
@SideOnly(Side.CLIENT)
public void registerModel(Item item, IModelManager manager) {
    for (EnumAcidity acidity : EnumAcidity.values()) {
        for (EnumMoisture moisture : EnumMoisture.values()) {
            String modelName = "";
            if (acidity != EnumAcidity.NEUTRAL) {
                modelName += acidity.getName();
            }
            if (moisture != EnumMoisture.NORMAL) {
                if (!modelName.isEmpty()) {
                    modelName += "_";
                }
                modelName += moisture.getName();
            }
            if (modelName.isEmpty()) {
                modelName = "normal";
            }
            String identifier;
            if (weedKilled) {
                identifier = type.getName() + "_no_weed/" + modelName;
            } else {
                identifier = type.getName() + '/' + modelName;
            }
            manager.registerItemModel(item, moisture.ordinal() + acidity.ordinal() * 3, identifier);
        }
    }
}
Also used : EnumMoisture(binnie.botany.api.gardening.EnumMoisture) EnumAcidity(binnie.botany.api.gardening.EnumAcidity) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

EnumMoisture (binnie.botany.api.gardening.EnumMoisture)8 EnumAcidity (binnie.botany.api.gardening.EnumAcidity)6 ItemStack (net.minecraft.item.ItemStack)4 IGardeningManager (binnie.botany.api.gardening.IGardeningManager)2 Block (net.minecraft.block.Block)2 IBlockState (net.minecraft.block.state.IBlockState)2 EnumFertiliserType (binnie.botany.api.gardening.EnumFertiliserType)1 EnumSoilType (binnie.botany.api.gardening.EnumSoilType)1 CircuitGarden (binnie.botany.farming.CircuitGarden)1 EnumTubeInsulate (binnie.botany.items.EnumTubeInsulate)1 EnumTubeMaterial (binnie.botany.items.EnumTubeMaterial)1 RecipeUtil (binnie.core.util.RecipeUtil)1 EnumTemperature (forestry.api.core.EnumTemperature)1 Map (java.util.Map)1 ItemBlock (net.minecraft.item.ItemBlock)1 Biome (net.minecraft.world.biome.Biome)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1