Search in sources :

Example 11 with IButterfly

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

the class Butterfly method copy.

@Override
public IButterfly copy() {
    NBTTagCompound nbttagcompound = new NBTTagCompound();
    this.writeToNBT(nbttagcompound);
    return new Butterfly(nbttagcompound);
}
Also used : IButterfly(forestry.api.lepidopterology.IButterfly) IEntityButterfly(forestry.api.lepidopterology.IEntityButterfly) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 12 with IButterfly

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

the class Butterfly method spawnCaterpillar.

@Override
@Nullable
public IButterfly spawnCaterpillar(World world, IButterflyNursery nursery) {
    // We need a mated queen to produce offspring.
    if (mate == null) {
        return null;
    }
    IChromosome[] chromosomes = new IChromosome[genome.getChromosomes().length];
    IChromosome[] parent1 = genome.getChromosomes();
    IChromosome[] parent2 = mate.getChromosomes();
    // Check for mutation. Replace one of the parents with the mutation
    // template if mutation occured.
    IChromosome[] mutated1 = mutateSpecies(world, nursery, genome, mate);
    if (mutated1 != null) {
        parent1 = mutated1;
    }
    IChromosome[] mutated2 = mutateSpecies(world, nursery, mate, genome);
    if (mutated2 != null) {
        parent2 = mutated2;
    }
    for (int i = 0; i < parent1.length; i++) {
        if (parent1[i] != null && parent2[i] != null) {
            chromosomes[i] = Chromosome.inheritChromosome(rand, parent1[i], parent2[i]);
        }
    }
    return new Butterfly(new ButterflyGenome(chromosomes));
}
Also used : IButterflyGenome(forestry.api.lepidopterology.IButterflyGenome) IButterfly(forestry.api.lepidopterology.IButterfly) IEntityButterfly(forestry.api.lepidopterology.IEntityButterfly) IChromosome(forestry.api.genetics.IChromosome) Nullable(javax.annotation.Nullable)

Example 13 with IButterfly

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

the class CocoonDecorator method decorateCocoons.

public static void decorateCocoons(World world, Random rand, int chunkX, int chunkZ) {
    List<IButterfly> butterflys = ButterflyManager.butterflyRoot.getIndividualTemplates();
    Collections.shuffle(butterflys, rand);
    for (IButterfly butterfly : butterflys) {
        if (genCocoon(world, rand, chunkX, chunkZ, butterfly)) {
            return;
        }
    }
}
Also used : IButterfly(forestry.api.lepidopterology.IButterfly)

Example 14 with IButterfly

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

the class EntityButterfly method readEntityFromNBT.

@Override
public void readEntityFromNBT(NBTTagCompound nbttagcompound) {
    super.readEntityFromNBT(nbttagcompound);
    IButterfly butterfly = null;
    if (nbttagcompound.hasKey("BTFLY")) {
        butterfly = new Butterfly((NBTTagCompound) nbttagcompound.getTag("BTFLY"));
    }
    setIndividual(butterfly);
    if (nbttagcompound.hasKey("PLN")) {
        NBTTagCompound pollenNBT = nbttagcompound.getCompoundTag("PLN");
        ISpeciesRoot root;
        if (pollenNBT.hasKey("Root")) {
            root = AlleleManager.alleleRegistry.getSpeciesRoot(pollenNBT.getString("Root"));
        } else {
            root = TreeManager.treeRoot;
        }
        pollen = root.getMember(pollenNBT);
    }
    EnumButterflyState state = EnumButterflyState.VALUES[nbttagcompound.getByte("STATE")];
    setState(state);
    exhaustion = nbttagcompound.getInteger("EXH");
    BlockPos home = new BlockPos(nbttagcompound.getInteger("homeX"), nbttagcompound.getInteger("homeY"), nbttagcompound.getInteger("homeZ"));
    setHomePosAndDistance(home, ModuleLepidopterology.maxDistance);
}
Also used : ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) IButterfly(forestry.api.lepidopterology.IButterfly) IEntityButterfly(forestry.api.lepidopterology.IEntityButterfly) IButterfly(forestry.api.lepidopterology.IButterfly) Butterfly(forestry.lepidopterology.genetics.Butterfly) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) BlockPos(net.minecraft.util.math.BlockPos)

Example 15 with IButterfly

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

the class ItemButterflyGE method onEntityItemUpdate.

@Override
public boolean onEntityItemUpdate(EntityItem entityItem) {
    if (type != EnumFlutterType.BUTTERFLY) {
        return false;
    }
    if (entityItem.world.isRemote || entityItem.ticksExisted < 80) {
        return false;
    }
    if (rand.nextInt(24) != 0) {
        return false;
    }
    IButterfly butterfly = ButterflyManager.butterflyRoot.getMember(entityItem.getItem());
    if (butterfly == null) {
        return false;
    }
    if (!butterfly.canTakeFlight(entityItem.world, entityItem.posX, entityItem.posY, entityItem.posZ)) {
        return false;
    }
    if (entityItem.world.countEntities(EntityButterfly.class) > ModuleLepidopterology.entityConstraint) {
        return false;
    }
    EntityUtil.spawnEntity(entityItem.world, new EntityButterfly(entityItem.world, butterfly, entityItem.getPosition()), entityItem.posX, entityItem.posY, entityItem.posZ);
    if (!entityItem.getItem().isEmpty()) {
        entityItem.getItem().shrink(1);
    } else {
        entityItem.setDead();
    }
    return true;
}
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