public CarpetSpell(MagicConfig config, String spellName) {
    super(config, spellName);

    MagicMaterial m =
        MagicSpells.getItemNameResolver().resolveBlock(getConfigString("platform-block", "glass"));
    if (m != null) {
      platformBlock = m.getMaterial();
    } else {
      platformBlock = Material.GLASS;
    }
    size = getConfigInt("size", 2);
    cancelOnTeleport = getConfigBoolean("cancel-on-teleport", true);

    windwalkers = new HashMap<String, BlockPlatform>();
    falling = new HashSet<Player>();
  }
Ejemplo n.º 2
0
  private boolean farm(Block center, int radius) {
    int cx = center.getX();
    int y = center.getY();
    int cz = center.getZ();

    int count = 0;
    for (int x = cx - radius; x <= cx + radius; x++) {
      for (int z = cz - radius; z <= cz + radius; z++) {
        Block b = center.getWorld().getBlockAt(x, y, z);
        if (b.getType() != Material.SOIL) {
          b = b.getRelative(BlockFace.DOWN);
          if (b.getType() != Material.SOIL) {
            continue;
          }
        }
        b = b.getRelative(BlockFace.UP);
        if (b.getType() == Material.AIR) {
          if (newCropType != null) {
            newCropType.setBlock(b);
            if (growth > 1) {
              BlockUtils.setGrowthLevel(b, growth - 1);
            }
            count++;
          }
        } else if ((b.getType() == Material.CROPS
                || b.getType() == Material.CARROT
                || b.getType() == Material.POTATO)
            && BlockUtils.getGrowthLevel(b) < 7) {
          int newGrowth = BlockUtils.getGrowthLevel(b) + growth;
          if (newGrowth > 7) newGrowth = 7;
          BlockUtils.setGrowthLevel(b, newGrowth);
          count++;
        }
      }
    }

    return count > 0;
  }