Package forestry.api.lepidopterology

Examples of forestry.api.lepidopterology.IButterfly


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

      IButterfly butterfly = PluginLepidopterology.butterflyInterface.getMember(getStackInSlot(SLOT_SPECIMEN));
      // No tree, abort
      if (butterfly == null) {
        return;
      }

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

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

        butterfly.analyze();
        if (player != null) {
          PluginLepidopterology.butterflyInterface.getBreedingTracker(player.worldObj, player.getGameProfile()).registerSpecies(butterfly.getGenome().getPrimary());
          PluginLepidopterology.butterflyInterface.getBreedingTracker(player.worldObj, player.getGameProfile()).registerSpecies(butterfly.getGenome().getSecondary());
        }
        NBTTagCompound nbttagcompound = new NBTTagCompound();
        butterfly.writeToNBT(nbttagcompound);
        getStackInSlot(SLOT_SPECIMEN).setTagCompound(nbttagcompound);

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


  public String getItemStackDisplayName(ItemStack itemstack) {

    if (itemstack.getTagCompound() == null)
      return "???";

    IButterfly butterfly = PluginLepidopterology.butterflyInterface.getMember(itemstack);
    if(butterfly == null)
      return "???";

    return butterfly.getDisplayName();
  }
View Full Code Here

    if(!Proxies.common.isSimulating(entityItem.worldObj) || entityItem.ticksExisted < 80)
      return false;
    if(entityItem.worldObj.getTotalWorldTime() % 24 != 0)
      return false;

    IButterfly butterfly = PluginLepidopterology.butterflyInterface.getMember(entityItem.getEntityItem());
    if(butterfly == null)
      return false;

    if(!butterfly.canTakeFlight(entityItem.worldObj, entityItem.posX, entityItem.posY, entityItem.posZ))
      return false;

    if(entityItem.worldObj.countEntities(EntityButterfly.class) > PluginLepidopterology.entityConstraint)
      return false;
View Full Code Here

  public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int par7, float facingX, float facingY, float facingZ) {

    if (!Proxies.common.isSimulating(world))
      return false;

    IButterfly flutter = PluginLepidopterology.butterflyInterface.getMember(itemstack);
    if(flutter == null)
      return false;

    if(type == EnumFlutterType.CATERPILLAR) {
View Full Code Here

  public boolean onRandomLeafTick(ITree tree, World world, int biomeId, int x, int y, int z, boolean isDestroyed) {
   
    if(world.rand.nextFloat() >= tree.getGenome().getSappiness() * tree.getGenome().getYield())
      return false;
   
    IButterfly spawn = PluginLepidopterology.butterflyInterface.getIndividualTemplates().get(world.rand.nextInt(PluginLepidopterology.butterflyInterface.getIndividualTemplates().size()));
    if(world.rand.nextFloat() >= spawn.getGenome().getPrimary().getRarity() * 0.5f)
      return false;
   
    if(world.countEntities(EntityButterfly.class) > PluginLepidopterology.spawnConstraint)
      return false;
   
    if(!spawn.canSpawn(world, x, y, z))
      return false;
   
    if(world.isAirBlock(x - 1, y, z)) {
      attemptButterflySpawn(world, spawn, x - 1, y, z);
    } else if(world.isAirBlock(x + 1, y, z)) {
View Full Code Here

      return unknown;
  }

  @Override
  public ItemStack getCraftingResult(InventoryCrafting crafting) {
    IButterfly butterfly = null;
    IButterfly serum = null;
    for(int i = 0; i < crafting.getSizeInventory(); i++) {
      if(PluginLepidopterology.butterflyInterface.isMember(crafting.getStackInSlot(i), EnumFlutterType.BUTTERFLY.ordinal())) {
        butterfly = PluginLepidopterology.butterflyInterface.getMember(crafting.getStackInSlot(i));
      } else if(PluginLepidopterology.butterflyInterface.isMember(crafting.getStackInSlot(i), EnumFlutterType.SERUM.ordinal()))
        serum = PluginLepidopterology.butterflyInterface.getMember(crafting.getStackInSlot(i))
    }
   
    IButterfly mated = butterfly.copy();
    mated.mate(serum);
    return PluginLepidopterology.butterflyInterface.getMemberStack(mated, EnumFlutterType.BUTTERFLY.ordinal());
  }
View Full Code Here

  public static float getRegularWingYaw(float flap) {
    return flap < 0.5 ? 0.75f + flap : 1.75f - flap;
  }
 
  private IButterfly initButterfly(ItemStack item, boolean scaled) {
    IButterfly butterfly = PluginLepidopterology.butterflyInterface.getMember(item);
    if(butterfly == null)
      butterfly = PluginLepidopterology.butterflyInterface.templateAsIndividual(PluginLepidopterology.butterflyInterface.getDefaultTemplate());
   
    if(entity == null) {
      entity = new EntityButterfly(Proxies.common.getClientInstance().theWorld);
    }
    entity.setSpecies(butterfly.getGenome().getPrimary());
    if(scaled)
      entity.setScale(butterfly.getSize());
    else
      entity.setScale(EntityButterfly.DEFAULT_BUTTERFLY_SCALE);
   
    return butterfly;
  }
View Full Code Here

  @Override
  protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
    super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);

    int page = 0;
    IButterfly butterfly = null;
    for (int k = 1; k < FlutterlyzerInventory.SLOT_ANALYZE_5 + 1; k++) {
      if (k == FlutterlyzerInventory.SLOT_ENERGY)
        continue;

      if (inventory.getStackInSlot(k) == null)
        continue;
      butterfly = PluginLepidopterology.butterflyInterface.getMember(inventory.getStackInSlot(k));
      if (butterfly == null || !butterfly.isAnalyzed())
        continue;

      page = k;
      break;
    }
View Full Code Here

    return (EntityButterfly)Utils.spawnEntity(world, new EntityButterfly(world, butterfly), x, y, z);
  }

  @Override
  public boolean isMated(ItemStack stack) {
    IButterfly butterfly = getMember(stack);
    if(butterfly == null)
      return false;

    return butterfly.getMate() != null;
  }
View Full Code Here

  @Override
  public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) {

    ItemStack heldItem = player.getHeldItem();
    TileEntity tile = world.getTileEntity(x, y, z);
    IButterfly caterpillar = tile instanceof TileLeaves ? ((TileLeaves) tile).getCaterpillar() : null;
    if(heldItem != null && (heldItem.getItem() instanceof IToolScoop) && caterpillar != null) {
      ItemStack butterfly = PluginLepidopterology.butterflyInterface.getMemberStack(caterpillar, EnumFlutterType.CATERPILLAR.ordinal());
      StackUtils.dropItemStackAsEntity(butterfly, world, x, y, z);
      ((TileLeaves) tile).setCaterpillar(null);
      return true;
View Full Code Here

TOP

Related Classes of forestry.api.lepidopterology.IButterfly

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.