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