Search in sources :

Example 16 with IButterfly

use of forestry.api.lepidopterology.IButterfly in project ForestryMC by ForestryMC.

the class MatingRecipe method getCraftingResult.

@Override
public ItemStack getCraftingResult(InventoryCrafting crafting) {
    IButterfly butterfly = null;
    IButterfly serum = null;
    for (int i = 0; i < crafting.getSizeInventory(); i++) {
        if (ButterflyManager.butterflyRoot.isMember(crafting.getStackInSlot(i), EnumFlutterType.BUTTERFLY)) {
            butterfly = ButterflyManager.butterflyRoot.getMember(crafting.getStackInSlot(i));
        } else if (ButterflyManager.butterflyRoot.isMember(crafting.getStackInSlot(i), EnumFlutterType.SERUM)) {
            serum = ButterflyManager.butterflyRoot.getMember(crafting.getStackInSlot(i));
        }
    }
    if (butterfly == null || serum == null) {
        return ItemStack.EMPTY;
    }
    IButterfly mated = butterfly.copy();
    mated.mate(serum);
    return ButterflyManager.butterflyRoot.getMemberStack(mated, EnumFlutterType.BUTTERFLY);
}
Also used : IButterfly(forestry.api.lepidopterology.IButterfly)

Example 17 with IButterfly

use of forestry.api.lepidopterology.IButterfly in project ForestryMC by ForestryMC.

the class ButterflySpawner method onRandomLeafTick.

@Override
public boolean onRandomLeafTick(ITree tree, World world, Random rand, BlockPos pos, boolean isDestroyed) {
    if (!world.getGameRules().getBoolean("doMobSpawning")) {
        return false;
    }
    if (rand.nextFloat() >= tree.getGenome().getSappiness() * tree.getGenome().getYield()) {
        return false;
    }
    IButterfly spawn = ButterflyManager.butterflyRoot.getIndividualTemplates().get(rand.nextInt(ButterflyManager.butterflyRoot.getIndividualTemplates().size()));
    float rarity;
    if (!ModuleLepidopterology.spawnRaritys.containsKey(spawn.getGenome().getPrimary().getUID())) {
        rarity = spawn.getGenome().getPrimary().getRarity();
    } else {
        rarity = ModuleLepidopterology.spawnRaritys.get(spawn.getGenome().getPrimary().getUID());
    }
    if (rand.nextFloat() >= rarity * 0.5f) {
        return false;
    }
    if (world.countEntities(EntityButterfly.class) > ModuleLepidopterology.spawnConstraint) {
        return false;
    }
    if (!spawn.canSpawn(world, pos.getX(), pos.getY(), pos.getZ())) {
        return false;
    }
    if (world.isAirBlock(pos.north())) {
        ButterflyUtils.attemptButterflySpawn(world, spawn, pos.north());
    } else if (world.isAirBlock(pos.south())) {
        ButterflyUtils.attemptButterflySpawn(world, spawn, pos.south());
    } else if (world.isAirBlock(pos.west())) {
        ButterflyUtils.attemptButterflySpawn(world, spawn, pos.west());
    } else if (world.isAirBlock(pos.east())) {
        ButterflyUtils.attemptButterflySpawn(world, spawn, pos.east());
    }
    return false;
}
Also used : IButterfly(forestry.api.lepidopterology.IButterfly) EntityButterfly(forestry.lepidopterology.entities.EntityButterfly)

Aggregations

IButterfly (forestry.api.lepidopterology.IButterfly)17 ItemStack (net.minecraft.item.ItemStack)4 IEntityButterfly (forestry.api.lepidopterology.IEntityButterfly)3 GuiAlyzer (forestry.core.gui.GuiAlyzer)3 TextLayoutHelper (forestry.core.gui.TextLayoutHelper)3 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)3 EntityButterfly (forestry.lepidopterology.entities.EntityButterfly)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 IToolScoop (forestry.api.core.IToolScoop)1 IAllele (forestry.api.genetics.IAllele)1 IAlleleFlowers (forestry.api.genetics.IAlleleFlowers)1 IAlleleInteger (forestry.api.genetics.IAlleleInteger)1 IAlleleTolerance (forestry.api.genetics.IAlleleTolerance)1 IChromosome (forestry.api.genetics.IChromosome)1 ISpeciesRoot (forestry.api.genetics.ISpeciesRoot)1 IButterflyGenome (forestry.api.lepidopterology.IButterflyGenome)1 IButterflyNursery (forestry.api.lepidopterology.IButterflyNursery)1 IButterflyRoot (forestry.api.lepidopterology.IButterflyRoot)1 TileLeaves (forestry.arboriculture.tiles.TileLeaves)1 AlleleBoolean (forestry.core.genetics.alleles.AlleleBoolean)1