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());
}
}
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());
}
}
}
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();
}
}
Aggregations