Package forestry.api.apiculture

Examples of forestry.api.apiculture.IBee


    LinkedList<ForgeDirection> typedOrientations = new LinkedList<ForgeDirection>();
    LinkedList<ForgeDirection> defaultOrientations = new LinkedList<ForgeDirection>();

    // We need a bee!
    EnumFilterType type = EnumFilterType.getType(event.item.getItemStack());
    IBee bee = null;

    if (type != EnumFilterType.ITEM)
      bee = PluginApiculture.beeInterface.getMember(event.item.getItemStack());

    // Filtered outputs
    for (ForgeDirection dir : event.destinations) {

      // Continue if this direction is closed.
      if (pipeLogic.isClosed(dir))
        continue;

      if (pipeLogic.isIndiscriminate(dir)) {
        defaultOrientations.add(dir);
        continue;
      }

      // We need to match the type for this orientation's filter
      if (!pipeLogic.matchType(dir, type, bee))
        continue;

      // Passing the type filter is enough for non-bee items.
      if (type == EnumFilterType.ITEM) {
        filteredOrientations.add(dir);
        continue;
      }

      ArrayList<IAllele[]> filters = pipeLogic.getGenomeFilters(dir);
      // If we have no genome filters, this is only a typed route.
      if (filters.size() <= 0) {
        typedOrientations.add(dir);
        continue;
      }

      // Bees need to match one of the genome filters
      for (IAllele[] pattern : filters) {
        if (pipeLogic.matchAllele(pattern[0], bee.getIdent()) && pipeLogic.matchAllele(pattern[1], bee.getGenome().getSecondary().getUID()))
          filteredOrientations.add(dir);
      }
    }

    event.destinations.clear();
View Full Code Here


      if (template == null)
        throw new TemplateNotFoundException(species);

      IBeeGenome genome = PluginApiculture.beeInterface.templateAsGenome(template);

      IBee bee = PluginApiculture.beeInterface.getBee(player.worldObj, genome);

      if(this.type == EnumBeeType.QUEEN)
        bee.mate(bee);
     
      ItemStack beestack = PluginApiculture.beeInterface.getMemberStack(bee, type.ordinal());
      player.dropPlayerItemWithRandomChoice(beestack, true);
      func_152373_a(sender, this, "Player %s was given a %s bee.", player.getCommandSenderName(), ((IAlleleSpecies) template[0]).getName());
    } else
View Full Code Here

  @Override
  public boolean isMated(ItemStack stack) {
    if (getType(stack) != EnumBeeType.QUEEN)
      return false;

    IBee bee = getMember(stack);
    return bee.getMate() != null;
  }
View Full Code Here

  public static float getRegularWingYaw(float flap) {
    return flap < 0.5 ? 0.75f + flap : 1.75f - flap;
  }

  private IBee initBee(ItemStack item, boolean scaled) {
    IBee bee = PluginApiculture.beeInterface.getMember(item);
    if(bee == null)
      bee = PluginApiculture.beeInterface.templateAsIndividual(PluginApiculture.beeInterface.getDefaultTemplate());

    if(entity == null) {
      entity = new EntityBee(Proxies.common.getClientInstance().theWorld);
    }
    entity.setSpecies(bee.getGenome().getPrimary());
    entity.setType(PluginApiculture.beeInterface.getType(item));
    /*
    if(scaled)
      entity.setScale(butterfly.getSize());
    else
 
View Full Code Here

      // Source slot to analyze empty
      if (getStackInSlot(specimenSlot) == null)
        return;

      IBee bee = PluginApiculture.beeInterface.getMember(getStackInSlot(specimenSlot));
      // No bee, abort
      if (bee == null)
        return;

      // Requires energy
      if (!isEnergy(getStackInSlot(energySlot)))
        return;

      biomesToSearch = bee.getSuitableBiomeIds();

      // Decrease energy
      decrStackSize(energySlot, 1);

      setInventorySlotContents(analyzeSlot, getStackInSlot(specimenSlot));
View Full Code Here

  public String getItemStackDisplayName(ItemStack itemstack) {

    if (itemstack.getTagCompound() == null)
      return super.getItemStackDisplayName(itemstack);

    IBee individual = new Bee(itemstack.getTagCompound());
    String customBeeKey = "bees.custom." + type.getName() + "." + individual.getGenome().getPrimary().getUnlocalizedName().replace("bees.species.","");
    if(StringUtil.canTranslate(customBeeKey)){
      return StringUtil.localize(customBeeKey);
    }
    String beeGrammar = StringUtil.localize("bees.grammar." + type.getName());
    String beeSpecies = individual.getDisplayName();
    String beeType = StringUtil.localize("bees.grammar." + type.getName() + ".type");
    return beeGrammar.replaceAll("%SPECIES", beeSpecies).replaceAll("%TYPE", beeType);
  }
View Full Code Here

  public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean flag) {
    if(!itemstack.hasTagCompound())
      return;

    if(type != EnumBeeType.DRONE) {
      IBee individual = new Bee(itemstack.getTagCompound());
      if (individual.isNatural())
        list.add("\u00A7e\u00A7o" + StringUtil.localize("bees.stock.pristine"));
      else
        list.add("\u00A7e" + StringUtil.localize("bees.stock.ignoble"));
    }
View Full Code Here

      // Needs space
      if (inventoryStacks[imprintedSlot] != null)
        return;

      IBee imprint = getSelectedBee();
      if (imprint == null)
        return;

      NBTTagCompound nbttagcompound = new NBTTagCompound();
      imprint.writeToNBT(nbttagcompound);
      inventoryStacks[specimenSlot].setTagCompound(nbttagcompound);

      inventoryStacks[imprintedSlot] = inventoryStacks[specimenSlot];
      inventoryStacks[specimenSlot] = null;
    }
View Full Code Here

      // Source slot to analyze empty
      if (getStackInSlot(SLOT_SPECIMEN) == null)
        return;

      IBee bee = PluginApiculture.beeInterface.getMember(getStackInSlot(SLOT_SPECIMEN));
      // No bee, abort
      if (bee == null)
        return;

      // Analyze if necessary
      if (!bee.isAnalyzed()) {

        // Requires energy
        if (!isEnergy(getStackInSlot(SLOT_ENERGY)))
          return;

        bee.analyze();
        if(player != null) {
          PluginApiculture.beeInterface.getBreedingTracker(player.worldObj, player.getGameProfile()).registerSpecies(bee.getGenome().getPrimary());
          PluginApiculture.beeInterface.getBreedingTracker(player.worldObj, player.getGameProfile()).registerSpecies(bee.getGenome().getSecondary());
        }

        NBTTagCompound nbttagcompound = new NBTTagCompound();
        bee.writeToNBT(nbttagcompound);
        getStackInSlot(SLOT_SPECIMEN).setTagCompound(nbttagcompound);

        // Decrease energy
        decrStackSize(SLOT_ENERGY, 1);
      }
View Full Code Here

    if (!ForestryItem.beeQueenGE.isItemEqual(housing.getQueen())) {
      housing.setErrorState(EnumErrorCode.NOQUEEN.ordinal());
      return;
    }

    IBee queen = PluginApiculture.beeInterface.getMember(housing.getQueen());
    // Kill dying queens
    if (!queen.isAlive()) {
      killQueen(queen);
      housing.setErrorState(EnumErrorCode.OK.ordinal());
      return;
    }

    resetQueen(queen);

    // Not while raining, at night or without light
    EnumErrorCode state = EnumErrorCode.values()[queen.isWorking(housing)];
    if (state != EnumErrorCode.OK) {
      housing.setErrorState(state.ordinal());
      return;
    } else if (housing.getErrorOrdinal() != EnumErrorCode.NOFLOWER.ordinal())
      housing.setErrorState(EnumErrorCode.OK.ordinal());

    // Effects only fire when queen can work.
    effectData = queen.doEffect(effectData, housing);

    // We have a queen, work!
    throttle++;

    if (throttle >= PluginApiculture.beeCycleTicks)
      throttle = 0;
    else
      return;

    // Need a flower
    if (!queen.hasFlower(housing)) {
      housing.setErrorState(EnumErrorCode.NOFLOWER.ordinal());
      return;
    } else
      housing.setErrorState(EnumErrorCode.OK.ordinal());

    // Produce and add stacks
    ItemStack[] products = queen.produceStacks(housing);
    housing.wearOutEquipment(1);
    for (ItemStack stack : products) {
      housing.addProduct(stack, false);
    }

    // Plant a flower
    queen.plantFlowerRandom(housing);
    // Get pollen if none available yet
    if (pollen == null) {
      pollen = queen.retrievePollen(housing);
      attemptedPollinations = 0;
      if (pollen != null) {
        if (housing.onPollenRetrieved(queen, pollen, false))
          pollen = null;
      }
    }
    if (pollen != null) {
      attemptedPollinations++;
      if (queen.pollinateRandom(housing, pollen)
          || attemptedPollinations >= MAX_POLLINATION_ATTEMPTS) {
        pollen = null;
      }
    }

    // Age the queen
    queen.age(housing.getWorld(), housing.getLifespanModifier(queen.getGenome(), queen.getMate(), 0f));

    // Write the changed queen back into the item stack.
    NBTTagCompound nbttagcompound = new NBTTagCompound();
    queen.writeToNBT(nbttagcompound);
    housing.getQueen().setTagCompound(nbttagcompound);

    return;
  }
View Full Code Here

TOP

Related Classes of forestry.api.apiculture.IBee

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.