Search in sources :

Example 1 with IButterflyGenome

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

the class EntityButterfly method setIndividual.

public void setIndividual(@Nullable IButterfly butterfly) {
    if (butterfly == null) {
        butterfly = ButterflyManager.butterflyRoot.templateAsIndividual(ButterflyManager.butterflyRoot.getDefaultTemplate());
    }
    contained = butterfly;
    IButterflyGenome genome = contained.getGenome();
    isImmuneToFire = genome.getFireResist();
    size = genome.getSize();
    setSize(size, 0.4f);
    species = genome.getPrimary();
    if (!world.isRemote) {
        dataManager.set(DATAWATCHER_ID_SIZE, (int) (size * 100));
        dataManager.set(DATAWATCHER_ID_SPECIES, species.getUID());
    } else {
        textureResource = new ResourceLocation(species.getEntityTexture());
    }
}
Also used : IButterflyGenome(forestry.api.lepidopterology.IButterflyGenome) ResourceLocation(net.minecraft.util.ResourceLocation)

Example 2 with IButterflyGenome

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

the class TileCocoon method onBlockTick.

public void onBlockTick() {
    maturationTime++;
    IButterflyGenome caterpillarGenome = caterpillar.getGenome();
    int caterpillarMatureTime = Math.round((float) caterpillarGenome.getLifespan() / (caterpillarGenome.getFertility() * 2));
    if (maturationTime >= caterpillarMatureTime) {
        if (age < 2) {
            age++;
            maturationTime = 0;
            IBlockState blockState = world.getBlockState(pos);
            world.notifyBlockUpdate(pos, blockState, blockState, 0);
        } else if (caterpillar.canTakeFlight(world, getPos().getX(), getPos().getY(), getPos().getZ())) {
            NonNullList<ItemStack> cocoonDrops = caterpillar.getCocoonDrop(this);
            for (ItemStack drop : cocoonDrops) {
                ItemStackUtil.dropItemStackAsEntity(drop, world, pos);
            }
            world.setBlockToAir(getPos());
            attemptButterflySpawn(world, caterpillar, getPos());
        }
    }
}
Also used : IButterflyGenome(forestry.api.lepidopterology.IButterflyGenome) IBlockState(net.minecraft.block.state.IBlockState) NonNullList(net.minecraft.util.NonNullList) ItemStack(net.minecraft.item.ItemStack)

Example 3 with IButterflyGenome

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

the class TileLeaves method matureCaterpillar.

/* IBUTTERFLYNURSERY */
private void matureCaterpillar() {
    if (caterpillar == null) {
        return;
    }
    maturationTime++;
    ITree tree = getTree();
    boolean wasDestroyed = isDestroyed(tree, damage);
    damage += caterpillar.getGenome().getMetabolism();
    IButterflyGenome caterpillarGenome = caterpillar.getGenome();
    int caterpillarMatureTime = Math.round((float) caterpillarGenome.getLifespan() / (caterpillarGenome.getFertility() * 2));
    if (maturationTime >= caterpillarMatureTime) {
        ButterflyManager.butterflyRoot.plantCocoon(world, pos.down(), getCaterpillar(), getOwnerHandler().getOwner(), 0, false);
        setCaterpillar(null);
    } else if (!wasDestroyed && isDestroyed(tree, damage)) {
        sendNetworkUpdate();
    }
}
Also used : IButterflyGenome(forestry.api.lepidopterology.IButterflyGenome) ITree(forestry.api.arboriculture.ITree)

Aggregations

IButterflyGenome (forestry.api.lepidopterology.IButterflyGenome)3 ITree (forestry.api.arboriculture.ITree)1 IBlockState (net.minecraft.block.state.IBlockState)1 ItemStack (net.minecraft.item.ItemStack)1 NonNullList (net.minecraft.util.NonNullList)1 ResourceLocation (net.minecraft.util.ResourceLocation)1