Search in sources :

Example 6 with IBeeHousingInventory

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

the class BeekeepingLogic method tickBreed.

// / BREEDING
private void tickBreed() {
    beeProgressMax = totalBreedingTime;
    IBeeHousingInventory beeInventory = housing.getBeeInventory();
    ItemStack droneStack = beeInventory.getDrone();
    ItemStack princessStack = beeInventory.getQueen();
    EnumBeeType droneType = BeeManager.beeRoot.getType(droneStack);
    EnumBeeType princessType = BeeManager.beeRoot.getType(princessStack);
    if (droneType != EnumBeeType.DRONE || princessType != EnumBeeType.PRINCESS) {
        beeProgress = 0;
        return;
    }
    if (beeProgress < totalBreedingTime) {
        beeProgress++;
    }
    if (beeProgress < totalBreedingTime) {
        return;
    }
    // Mate and replace princess with queen
    IBee princess = BeeManager.beeRoot.getMember(princessStack);
    IBee drone = BeeManager.beeRoot.getMember(droneStack);
    princess.mate(drone);
    NBTTagCompound nbttagcompound = new NBTTagCompound();
    princess.writeToNBT(nbttagcompound);
    queenStack = new ItemStack(ModuleApiculture.getItems().beeQueenGE);
    queenStack.setTagCompound(nbttagcompound);
    beeInventory.setQueen(queenStack);
    // Register the new queen with the breeding tracker
    BeeManager.beeRoot.getBreedingTracker(housing.getWorldObj(), housing.getOwner()).registerQueen(princess);
    // Remove drone
    beeInventory.getDrone().shrink(1);
    // Reset breeding time
    queen = princess;
    beeProgress = princess.getHealth();
    beeProgressMax = princess.getMaxHealth();
}
Also used : IBeeHousingInventory(forestry.api.apiculture.IBeeHousingInventory) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IBee(forestry.api.apiculture.IBee) ItemStack(net.minecraft.item.ItemStack) EnumBeeType(forestry.api.apiculture.EnumBeeType)

Aggregations

IBeeHousingInventory (forestry.api.apiculture.IBeeHousingInventory)6 ItemStack (net.minecraft.item.ItemStack)6 EnumBeeType (forestry.api.apiculture.EnumBeeType)3 IBee (forestry.api.apiculture.IBee)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 IApiaristTracker (forestry.api.apiculture.IApiaristTracker)1 IErrorLogic (forestry.api.core.IErrorLogic)1 IErrorState (forestry.api.core.IErrorState)1 ArrayList (java.util.ArrayList)1 Stack (java.util.Stack)1 World (net.minecraft.world.World)1