Search in sources :

Example 31 with IBee

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);
        }
    }
}
Also used : IHiveFrame(forestry.api.apiculture.IHiveFrame) IAlvearyController(forestry.api.multiblock.IAlvearyController) IMultiblockLogicAlveary(forestry.api.multiblock.IMultiblockLogicAlveary) IBeeRoot(forestry.api.apiculture.IBeeRoot) IBee(forestry.api.apiculture.IBee) ItemStack(net.minecraft.item.ItemStack)

Example 32 with IBee

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;
        }
    }
}
Also used : Random(java.util.Random) IHiveDrop(forestry.api.apiculture.IHiveDrop) IBee(forestry.api.apiculture.IBee) World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack)

Example 33 with IBee

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;
}
Also used : ArrayList(java.util.ArrayList) IBee(forestry.api.apiculture.IBee) ItemStack(net.minecraft.item.ItemStack) IncubatorRecipe(binnie.genetics.machine.incubator.IncubatorRecipe)

Aggregations

IBee (forestry.api.apiculture.IBee)33 ItemStack (net.minecraft.item.ItemStack)17 IBeeGenome (forestry.api.apiculture.IBeeGenome)7 EnumBeeType (forestry.api.apiculture.EnumBeeType)6 World (net.minecraft.world.World)6 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)5 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)4 IBeeHousingInventory (forestry.api.apiculture.IBeeHousingInventory)3 IBeeRoot (forestry.api.apiculture.IBeeRoot)3 IAllele (forestry.api.genetics.IAllele)3 GuiAlyzer (forestry.core.gui.GuiAlyzer)3 TextLayoutHelper (forestry.core.gui.TextLayoutHelper)3 ArrayList (java.util.ArrayList)3 IBeekeepingMode (forestry.api.apiculture.IBeekeepingMode)2 IHiveDrop (forestry.api.apiculture.IHiveDrop)2 IHiveFrame (forestry.api.apiculture.IHiveFrame)2 IChromosome (forestry.api.genetics.IChromosome)2 Random (java.util.Random)2 Item (net.minecraft.item.Item)2 IncubatorRecipe (binnie.genetics.machine.incubator.IncubatorRecipe)1