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