Package forestry.api.lepidopterology

Examples of forestry.api.lepidopterology.IButterflyNursery


      TileEntity target = world.getTileEntity(x, y, z);
      if(!(target instanceof IButterflyNursery))
        return false;

      IButterflyNursery pollinatable = (IButterflyNursery)target;
      if(!pollinatable.canNurse(flutter))
        return false;

      pollinatable.setCaterpillar(flutter);
      Proxies.common.sendFXSignal(PacketFXSignal.VisualFXType.BLOCK_DESTROY, PacketFXSignal.SoundFXType.LEAF, world, x, y, z,
          world.getBlock(x, y, z), 0);
      if (!player.capabilities.isCreativeMode)
        itemstack.stackSize--;
      return true;
View Full Code Here


    if(entity.getButterfly().getMate() == null)
      return false;

    TileEntity tile = entity.worldObj.getTileEntity(rest.posX, rest.posY, rest.posZ);
    IButterflyNursery nursery = null;

    if(tile instanceof IButterflyNursery)
      nursery = (IButterflyNursery)tile;
    else {
      for (Map.Entry<ItemStack, IIndividual> entry : AlleleManager.ersatzSpecimen.entrySet()) {

        if (!StackUtils.equals(entity.worldObj.getBlock(rest.posX, rest.posY, rest.posZ), entry.getKey()))
          continue;

        int meta = entity.worldObj.getBlockMetadata(rest.posX, rest.posY, rest.posZ);
        if (StackUtils.equals(Blocks.leaves, entry.getKey()))
          meta = meta & 3;
        if (entry.getKey().getItemDamage() != meta)
          continue;

        // We matched, replace the leaf block with ours and set the ersatz genome
        ((ITreeRoot)AlleleManager.alleleRegistry.getSpeciesRoot("rootTrees")).setLeaves(entity.worldObj, entry.getValue(), null, rest.posX, rest.posY, rest.posZ);
        // Now let's pollinate
        nursery = (IButterflyNursery)entity.worldObj.getTileEntity(rest.posX, rest.posY, rest.posZ);
      }
    }
    if(nursery == null)
      return false;

    return nursery.canNurse(entity.getButterfly());
  }
View Full Code Here

  }

  @Override
  public void updateTask() {
    if(canLayEgg && !hasLayedEgg) {
      IButterflyNursery tile = (IButterflyNursery)entity.worldObj.getTileEntity(rest.posX, rest.posY, rest.posZ);
      if(tile.canNurse(entity.getButterfly())) {
        tile.setCaterpillar(entity.getButterfly().spawnCaterpillar(tile));
        Proxies.log.finest("A butterfly '%s' laid an egg at %s/%s/%s.", entity.getButterfly().getIdent(), rest.posX, rest.posY, rest.posZ);
        if(entity.getRNG().nextFloat() < 1.0f / entity.getButterfly().getGenome().getFertility())
          entity.setHealth(0);
      }
      hasLayedEgg = true;
View Full Code Here

TOP

Related Classes of forestry.api.lepidopterology.IButterflyNursery

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.