use of forestry.api.apiculture.IBee in project Binnie by ForestryMC.
the class AlvearyLogicFrameHousing method wearOutEquipment.
@Override
public void wearOutEquipment(final int amount) {
IHiveFrame hiveFrame = this.getHiveFrame();
if (hiveFrame != null) {
IBeeRoot beeRoot = Utils.getBeeRoot();
IMultiblockLogicAlveary multiblockLogic = tile.getMultiblockLogic();
IAlvearyController alvearyController = multiblockLogic.getController();
ItemStack queenStack = alvearyController.getBeeInventory().getQueen();
IBee queen = beeRoot.getMember(queenStack);
if (queen != null) {
final int wear = Math.round(amount * 5 * beeRoot.getBeekeepingMode(tile.getWorldObj()).getWearModifier());
ItemStack frame = inv.getStackInSlot(0);
ItemStack frameUsed = hiveFrame.frameUsed(alvearyController, frame, queen, wear);
inv.setStackInSlot(0, frameUsed);
}
}
}
use of forestry.api.apiculture.IBee in project Binnie by ForestryMC.
the class BlockExtraBeeHives method getDrops.
@Override
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
Random random = world instanceof World ? ((World) world).rand : RANDOM;
List<IHiveDrop> hiveDrops = getDropsForHive(getMetaFromState(state));
Collections.shuffle(hiveDrops);
// Grab a princess
int tries = 0;
boolean hasPrincess = false;
while (tries <= 10 && !hasPrincess) {
tries++;
for (IHiveDrop drop : hiveDrops) {
if (random.nextDouble() < drop.getChance(world, pos, fortune)) {
IBee bee = drop.getBeeType(world, pos);
if (random.nextFloat() < drop.getIgnobleChance(world, pos, fortune)) {
bee.setIsNatural(false);
}
ItemStack princess = BeeManager.beeRoot.getMemberStack(bee, EnumBeeType.PRINCESS);
drops.add(princess);
hasPrincess = true;
break;
}
}
}
// Grab drones
for (IHiveDrop drop : hiveDrops) {
if (random.nextDouble() < drop.getChance(world, pos, fortune)) {
IBee bee = drop.getBeeType(world, pos);
ItemStack drone = BeeManager.beeRoot.getMemberStack(bee, EnumBeeType.DRONE);
drops.add(drone);
break;
}
}
// Grab anything else on offer
for (IHiveDrop drop : hiveDrops) {
if (random.nextDouble() < drop.getChance(world, pos, fortune)) {
drops.addAll(drop.getExtraItems(world, pos, fortune));
break;
}
}
}
use of forestry.api.apiculture.IBee in project Binnie by ForestryMC.
the class LarvaeIncubatorRecipeMaker method create.
public static List<LarvaeIncubatorRecipeWrapper> create(@Nullable IncubatorRecipeLarvae recipeLarvae) {
if (recipeLarvae == null) {
return Collections.emptyList();
}
List<LarvaeIncubatorRecipeWrapper> recipes = new ArrayList<>();
ItemStack inputStack = recipeLarvae.getInputStack();
List<ItemStack> subtypes = GeneticsJeiPlugin.jeiHelpers.getStackHelper().getSubtypes(inputStack);
for (ItemStack larvae : subtypes) {
IncubatorRecipe recipe = new IncubatorRecipe(larvae, recipeLarvae.getInput(), recipeLarvae.getOutput(), recipeLarvae.getLossChance(), recipeLarvae.getChance());
final IBee bee = BeeManager.beeRoot.getMember(larvae);
if (bee != null) {
ItemStack drone = BeeManager.beeRoot.getMemberStack(bee, EnumBeeType.DRONE);
recipe.setOutputStack(drone);
recipes.add(new LarvaeIncubatorRecipeWrapper(recipe));
}
}
return recipes;
}
Aggregations