Search in sources :

Example 16 with IBee

use of forestry.api.apiculture.IBee in project ForestryMC by ForestryMC.

the class InventoryApiary method wearOutFrames.

@Override
public void wearOutFrames(IBeeHousing beeHousing, int amount) {
    IBeekeepingMode beekeepingMode = BeeManager.beeRoot.getBeekeepingMode(beeHousing.getWorldObj());
    int wear = Math.round(amount * beekeepingMode.getWearModifier());
    for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) {
        ItemStack hiveFrameStack = getStackInSlot(i);
        Item hiveFrameItem = hiveFrameStack.getItem();
        if ((hiveFrameItem instanceof IHiveFrame)) {
            IHiveFrame hiveFrame = (IHiveFrame) hiveFrameItem;
            ItemStack queenStack = getQueen();
            IBee queen = BeeManager.beeRoot.getMember(queenStack);
            if (queen != null) {
                ItemStack usedFrame = hiveFrame.frameUsed(beeHousing, hiveFrameStack, queen, wear);
                setInventorySlotContents(i, usedFrame);
            }
        }
    }
}
Also used : IHiveFrame(forestry.api.apiculture.IHiveFrame) Item(net.minecraft.item.Item) IBeekeepingMode(forestry.api.apiculture.IBeekeepingMode) IBee(forestry.api.apiculture.IBee) ItemStack(net.minecraft.item.ItemStack)

Example 17 with IBee

use of forestry.api.apiculture.IBee in project ForestryMC by ForestryMC.

the class ItemInventoryHabitatLocator method onSlotClick.

@Override
public void onSlotClick(int slotIndex, EntityPlayer player) {
    if (!getStackInSlot(SLOT_ANALYZED).isEmpty()) {
        if (locatorLogic.isBiomeFound()) {
            return;
        }
    } else if (!getStackInSlot(SLOT_SPECIMEN).isEmpty()) {
        // Requires energy
        if (!isEnergy(getStackInSlot(SLOT_ENERGY))) {
            return;
        }
        // Decrease energy
        decrStackSize(SLOT_ENERGY, 1);
        setInventorySlotContents(SLOT_ANALYZED, getStackInSlot(SLOT_SPECIMEN));
        setInventorySlotContents(SLOT_SPECIMEN, ItemStack.EMPTY);
    }
    ItemStack analyzed = getStackInSlot(SLOT_ANALYZED);
    IBee bee = BeeManager.beeRoot.getMember(analyzed);
    if (bee != null) {
        locatorLogic.startBiomeSearch(bee, player);
    }
}
Also used : IBee(forestry.api.apiculture.IBee) ItemStack(net.minecraft.item.ItemStack)

Example 18 with IBee

use of forestry.api.apiculture.IBee in project ForestryMC by ForestryMC.

the class ItemInventoryImprinter method onSlotClick.

@Override
public void onSlotClick(int slotIndex, EntityPlayer player) {
    ItemStack specimen = getStackInSlot(specimenSlot);
    if (specimen.isEmpty()) {
        return;
    }
    // Only imprint bees
    if (!BeeManager.beeRoot.isMember(specimen)) {
        return;
    }
    // Needs space
    if (!getStackInSlot(imprintedSlot).isEmpty()) {
        return;
    }
    IBee imprint = getSelectedBee();
    NBTTagCompound nbttagcompound = new NBTTagCompound();
    imprint.writeToNBT(nbttagcompound);
    specimen.setTagCompound(nbttagcompound);
    setInventorySlotContents(imprintedSlot, specimen);
    setInventorySlotContents(specimenSlot, ItemStack.EMPTY);
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IBee(forestry.api.apiculture.IBee) ItemStack(net.minecraft.item.ItemStack)

Example 19 with IBee

use of forestry.api.apiculture.IBee in project ForestryMC by ForestryMC.

the class TileAlvearySwarmer method updateServer.

/* UPDATING */
@Override
public void updateServer(int tickCount) {
    if (!pendingSpawns.isEmpty()) {
        setActive(true);
        if (tickCount % 1000 == 0) {
            trySpawnSwarm();
        }
    } else {
        setActive(false);
    }
    if (tickCount % 500 != 0) {
        return;
    }
    ItemStack princessStack = getPrincessStack();
    if (princessStack == null) {
        return;
    }
    int chance = consumeInducerAndGetChance();
    if (chance == 0) {
        return;
    }
    // Try to spawn princess
    if (world.rand.nextInt(1000) >= chance) {
        return;
    }
    // Queue swarm spawn
    IBee princess = BeeManager.beeRoot.getMember(princessStack);
    princess.setIsNatural(false);
    pendingSpawns.push(BeeManager.beeRoot.getMemberStack(princess, EnumBeeType.PRINCESS));
}
Also used : IBee(forestry.api.apiculture.IBee) ItemStack(net.minecraft.item.ItemStack)

Example 20 with IBee

use of forestry.api.apiculture.IBee in project ForestryMC by ForestryMC.

the class HiveBeeHousingInventory method getQueen.

@Override
public ItemStack getQueen() {
    if (queen == null) {
        IBee bee = hive.getContainedBee();
        queen = BeeManager.beeRoot.getMemberStack(bee, EnumBeeType.QUEEN);
    }
    return queen;
}
Also used : IBee(forestry.api.apiculture.IBee)

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