コード例 #1
0
ファイル: NewMapChunkCache.java プロジェクト: Kademlia/dynmap
    private void biomePrep() {
      if (sameneighborbiomecnt != null) return;
      int x_size = x_dim << 4;
      int z_size = (z_max - z_min + 1) << 4;
      sameneighborbiomecnt = new byte[x_size][];
      biomemap = new BiomeMap[x_size][];
      for (int i = 0; i < x_size; i++) {
        sameneighborbiomecnt[i] = new byte[z_size];
        biomemap[i] = new BiomeMap[z_size];
      }
      Object[] biomebase = null;
      ChunkSnapshot biome_css = null;
      for (int i = 0; i < x_size; i++) {
        initialize(i + x_base, 64, z_base);
        for (int j = 0; j < z_size; j++) {
          BiomeMap bm;

          if (snap != biome_css) {
            biomebase = null;
            biome_css = snap;
            if (biome_css instanceof SpoutChunkSnapshot) {
              biome_css = ((SpoutChunkSnapshot) biome_css).chunk;
            }
            biomebase = helper.getBiomeBaseFromSnapshot(biome_css);
          }
          if (biomebase != null) {
            bm = BiomeMap.byBiomeID(helper.getBiomeBaseID(biomebase[bz << 4 | bx]));
          } else {
            Biome bb = snap.getBiome(bx, bz);
            if (bb == null) bm = BiomeMap.NULL;
            else bm = biome_to_bmap[bb.ordinal()];
          }
          biomemap[i][j] = bm;
          int cnt = 0;
          if (i > 0) {
            if (bm == biomemap[i - 1][j]) {
                /* Same as one to left */
              cnt++;
              sameneighborbiomecnt[i - 1][j]++;
            }
            if ((j > 0) && (bm == biomemap[i - 1][j - 1])) {
              cnt++;
              sameneighborbiomecnt[i - 1][j - 1]++;
            }
            if ((j < (z_size - 1)) && (bm == biomemap[i - 1][j + 1])) {
              cnt++;
              sameneighborbiomecnt[i - 1][j + 1]++;
            }
          }
          if ((j > 0) && (biomemap[i][j] == biomemap[i][j - 1])) {
              /* Same as one to above */
            cnt++;
            sameneighborbiomecnt[i][j - 1]++;
          }
          sameneighborbiomecnt[i][j] = (byte) cnt;

          stepPosition(BlockStep.Z_PLUS);
        }
      }
    }
コード例 #2
0
ファイル: TreeAction.java プロジェクト: elBukkit/MagicPlugin
 @Override
 public void initialize(Spell spell, ConfigurationSection parameters)
 {
     super.initialize(spell, parameters);
     if (parameters.contains("biomes"))
     {
         ConfigurationSection biomeConfig = ConfigurationUtils.getConfigurationSection(parameters, "biomes");
         biomeMap = new HashMap<>();
         Collection<String> biomeKeys = biomeConfig.getKeys(false);
         for (String biomeKey : biomeKeys)
         {
             try {
                 Biome biome = Biome.valueOf(biomeKey.toUpperCase());
                 List<String> treeTypes = ConfigurationUtils.getStringList(biomeConfig, biomeKey);
                 for (String typeKey : treeTypes)
                 {
                     try {
                         TreeType treeType = TreeType.valueOf(typeKey.toUpperCase());
                         List<TreeType> biomeTypes = biomeMap.get(biome);
                         if (biomeTypes == null) {
                             biomeTypes = new ArrayList<>();
                             biomeMap.put(biome, biomeTypes);
                         }
                         biomeTypes.add(treeType);
                     } catch (Exception treeEx) {
                         Bukkit.getLogger().warning("Invalid tree type: " + typeKey);
                     }
                 }
             } catch (Exception biomeEx) {
                 Bukkit.getLogger().warning("Invalid biome: " + biomeKey);
             }
         }
     }
 }
コード例 #3
0
 @Override
 public List<Region> divideToRegions(World world) {
   List<Region> result = new ArrayList<Region>();
   for (Biome biome : Biome.values()) {
     BiomeRegion region = new BiomeRegion(world.getUID(), biome);
     region.setRegionManager(regionManager);
     result.add(region);
   }
   return result;
 }
コード例 #4
0
ファイル: NewMapChunkCache.java プロジェクト: Kademlia/dynmap
 static {
   Biome[] b = Biome.values();
   BiomeMap[] bm = BiomeMap.values();
   biome_to_bmap = new BiomeMap[256];
   for (int i = 0; i < biome_to_bmap.length; i++) {
     biome_to_bmap[i] = BiomeMap.NULL;
   }
   for (int i = 0; i < b.length; i++) {
     String bs = b[i].toString();
     for (int j = 0; j < bm.length; j++) {
       if (bm[j].toString().equals(bs)) {
         biome_to_bmap[b[i].ordinal()] = bm[j];
         break;
       }
     }
   }
 }
コード例 #5
0
  public static void setBiome(
      final World w, final String id, final AthionPlot plot, final Biome b) {
    final int bottomX = AthionCore.bottomX(plot.id, w) - 1;
    final int topX = AthionCore.topX(plot.id, w) + 1;
    final int bottomZ = AthionCore.bottomZ(plot.id, w) - 1;
    final int topZ = AthionCore.topZ(plot.id, w) + 1;

    for (int x = bottomX; x <= topX; x++) {
      for (int z = bottomZ; z <= topZ; z++) {
        w.getBlockAt(x, 0, z).setBiome(b);
      }
    }

    plot.biome = b;

    refreshPlotChunks(w, plot);

    AthionSQL.updatePlot(getIdX(id), getIdZ(id), plot.world, "biome", b.name());
  }
コード例 #6
0
ファイル: BioMedPlugin.java プロジェクト: dannytix/BioMed
  public void initWorld(World world) {
    String name = world.getName();

    if (getConfig().getConfigurationSection("worlds." + name) == null)
      getConfig().createSection("worlds." + name);
    ConfigurationSection worldConfig = getConfig().getConfigurationSection("worlds." + name);
    worldConfig.addDefault("global", "none");

    Biome globalBiome;
    try {
      String gName = worldConfig.getString("global");
      if (gName.equalsIgnoreCase("none")) globalBiome = null;
      else globalBiome = Biome.valueOf(gName.toUpperCase());
    } catch (Exception e) { // unsupported global biome in config
      log.warning("[BioMed] Unrecognized global biome for world \"" + world.getName() + "\"");
      globalBiome = null;
    }
    if (globalBiome != null) {
      GlobalBlockPopulator pop = new GlobalBlockPopulator();
      pop.setBiome(globalBiome);
      world.getPopulators().add(pop);
      globalBiomes.put(name, pop);
    }

    // load regions from config (backwards compatibility)
    List<Map<?, ?>> worldRegions = null;
    try {
      worldRegions = worldConfig.getMapList("regions");
      worldConfig.set("regions", null);
    } catch (Exception e) {
      // No regions to load
      return;
    }
    if (worldRegions == null) {
      return;
    }
    boolean found = false;
    for (Map<?, ?> worldRegion : worldRegions) {
      int x, z, lx, lz;
      Biome biome;
      try {
        x = (Integer) worldRegion.get("x");
        z = (Integer) worldRegion.get("z");
        lx = (Integer) worldRegion.get("lx");
        lz = (Integer) worldRegion.get("lz");
        biome = Biome.valueOf((String) worldRegion.get("biome"));

        BioMedUtils.setBiomes(x, z, lx, lz, world, biome);
        found = true;
      } catch (Exception e) {
        log.warning(
            "[BioMed] config for world \""
                + world.getName()
                + "\" contains an invalid region. Ignoring it.");
      }
    }
    if (found) {
      log.info("[BioMed] finished importing regions for world \"" + name + "\".");
      saveConfig();
    }
  }
コード例 #7
0
  public static boolean mP(final World w, final String idFrom, final String idTo) {
    final Location plot1Bottom = getPlotBottomLoc(w, idFrom);
    final Location plot2Bottom = getPlotBottomLoc(w, idTo);
    final Location plot1Top = getPlotTopLoc(w, idFrom);

    final int distanceX = plot1Bottom.getBlockX() - plot2Bottom.getBlockX();
    final int distanceZ = plot1Bottom.getBlockZ() - plot2Bottom.getBlockZ();

    for (int x = plot1Bottom.getBlockX(); x <= plot1Top.getBlockX(); x++) {
      for (int z = plot1Bottom.getBlockZ(); z <= plot1Top.getBlockZ(); z++) {
        Block plot1Block = w.getBlockAt(new Location(w, x, 0, z));
        Block plot2Block = w.getBlockAt(new Location(w, x - distanceX, 0, z - distanceZ));

        final String plot1Biome = plot1Block.getBiome().name();
        final String plot2Biome = plot2Block.getBiome().name();

        plot1Block.setBiome(Biome.valueOf(plot2Biome));
        plot2Block.setBiome(Biome.valueOf(plot1Biome));

        for (int y = 0; y < w.getMaxHeight(); y++) {
          plot1Block = w.getBlockAt(new Location(w, x, y, z));
          final int plot1Type = plot1Block.getTypeId();
          final byte plot1Data = plot1Block.getData();

          plot2Block = w.getBlockAt(new Location(w, x - distanceX, y, z - distanceZ));

          final int plot2Type = plot2Block.getTypeId();
          final byte plot2Data = plot2Block.getData();

          // plot1Block.setTypeId(plot2Type);
          plot1Block.setTypeIdAndData(plot2Type, plot2Data, false);
          plot1Block.setData(plot2Data);

          // net.minecraft.server.World world = ((org.bukkit.craftbukkit.CraftWorld) w).getHandle();
          // world.setRawTypeIdAndData(plot1Block.getX(), plot1Block.getY(), plot1Block.getZ(),
          // plot2Type, plot2Data);

          // plot2Block.setTypeId(plot1Type);
          plot2Block.setTypeIdAndData(plot1Type, plot1Data, false);
          plot2Block.setData(plot1Data);
          // world.setRawTypeIdAndData(plot2Block.getX(), plot2Block.getY(), plot2Block.getZ(),
          // plot1Type, plot1Data);
        }
      }
    }

    final HashMap<String, AthionPlot> plots = getPlots(w);

    if (plots.containsKey(idFrom)) {
      if (plots.containsKey(idTo)) {
        final AthionPlot plot1 = plots.get(idFrom);
        final AthionPlot plot2 = plots.get(idTo);

        int idX = getIdX(idTo);
        int idZ = getIdZ(idTo);
        AthionSQL.deletePlot(idX, idZ, plot2.world);
        plots.remove(idFrom);
        plots.remove(idTo);
        idX = getIdX(idFrom);
        idZ = getIdZ(idFrom);
        AthionSQL.deletePlot(idX, idZ, plot1.world);

        plot2.id = "" + idX + ";" + idZ;
        AthionSQL.addPlot(plot2, idX, idZ, w);
        plots.put(idFrom, plot2);

        for (int i = 0; i < plot2.comments.size(); i++) {
          String strUUID = "";
          UUID uuid = null;

          if (plot2.comments.get(i).length >= 3) {
            strUUID = plot2.comments.get(i)[2];
            try {
              uuid = UUID.fromString(strUUID);
            } catch (final Exception e) {
            }
          }
          AthionSQL.addPlotComment(plot2.comments.get(i), i, idX, idZ, plot2.world, uuid);
        }

        for (final String player : plot2.allowed()) {
          AthionSQL.addPlotAllowed(player, idX, idZ, plot2.world);
        }

        idX = getIdX(idTo);
        idZ = getIdZ(idTo);
        plot1.id = "" + idX + ";" + idZ;
        AthionSQL.addPlot(plot1, idX, idZ, w);
        plots.put(idTo, plot1);

        for (int i = 0; i < plot1.comments.size(); i++) {
          String strUUID = "";
          UUID uuid = null;

          if (plot1.comments.get(i).length >= 3) {
            strUUID = plot1.comments.get(i)[2];
            try {
              uuid = UUID.fromString(strUUID);
            } catch (final Exception e) {
            }
          }

          AthionSQL.addPlotComment(plot1.comments.get(i), i, idX, idZ, plot1.world, uuid);
        }

        for (final String player : plot1.allowed()) {
          AthionSQL.addPlotAllowed(player, idX, idZ, plot1.world);
        }

        setOwnerSign(w, plot1);
        setSellSign(w, plot1);
        setOwnerSign(w, plot2);
        setSellSign(w, plot2);

      } else {
        final AthionPlot plot = plots.get(idFrom);

        int idX = getIdX(idFrom);
        int idZ = getIdZ(idFrom);
        AthionSQL.deletePlot(idX, idZ, plot.world);
        plots.remove(idFrom);
        idX = getIdX(idTo);
        idZ = getIdZ(idTo);
        plot.id = "" + idX + ";" + idZ;
        AthionSQL.addPlot(plot, idX, idZ, w);
        plots.put(idTo, plot);

        for (int i = 0; i < plot.comments.size(); i++) {
          String strUUID = "";
          UUID uuid = null;

          if (plot.comments.get(i).length >= 3) {
            strUUID = plot.comments.get(i)[2];
            try {
              uuid = UUID.fromString(strUUID);
            } catch (final Exception e) {
            }
          }
          AthionSQL.addPlotComment(plot.comments.get(i), i, idX, idZ, plot.world, uuid);
        }

        for (final String player : plot.allowed()) {
          AthionSQL.addPlotAllowed(player, idX, idZ, plot.world);
        }

        setOwnerSign(w, plot);
        setSellSign(w, plot);
        removeOwnerSign(w, idFrom);
        removeSellSign(w, idFrom);
      }
    } else {
      if (plots.containsKey(idTo)) {
        final AthionPlot plot = plots.get(idTo);

        int idX = getIdX(idTo);
        int idZ = getIdZ(idTo);
        AthionSQL.deletePlot(idX, idZ, plot.world);
        plots.remove(idTo);

        idX = getIdX(idFrom);
        idZ = getIdZ(idFrom);
        plot.id = "" + idX + ";" + idZ;
        AthionSQL.addPlot(plot, idX, idZ, w);
        plots.put(idFrom, plot);

        for (int i = 0; i < plot.comments.size(); i++) {
          String strUUID = "";
          UUID uuid = null;

          if (plot.comments.get(i).length >= 3) {
            strUUID = plot.comments.get(i)[2];
            try {
              uuid = UUID.fromString(strUUID);
            } catch (final Exception e) {
            }
          }
          AthionSQL.addPlotComment(plot.comments.get(i), i, idX, idZ, plot.world, uuid);
        }

        for (final String player : plot.allowed()) {
          AthionSQL.addPlotAllowed(player, idX, idZ, plot.world);
        }

        setOwnerSign(w, plot);
        setSellSign(w, plot);
        removeOwnerSign(w, idTo);
        removeSellSign(w, idTo);
      }
    }

    return true;
  }
コード例 #8
0
ファイル: BiomeAdapter.java プロジェクト: jjm223/mcMMO
 static {
   List<Biome> temp = new ArrayList<Biome>();
   EnumSet<Biome> set = null;
   try {
     temp.add(Biome.valueOf("RIVER"));
     temp.add(Biome.valueOf("OCEAN"));
     temp.add(Biome.valueOf("DEEP_OCEAN"));
   } catch (Exception e) {
     temp.clear();
   } finally {
     try {
       set = EnumSet.copyOf(temp);
     } catch (IllegalArgumentException e) {
       mcMMO.p.getLogger().severe("Biome enum mismatch");
       ;
     }
     temp.clear();
   }
   WATER_BIOMES = set;
   set = null;
   try {
     temp.add(Biome.valueOf("FROZEN_OCEAN"));
     temp.add(Biome.valueOf("FROZEN_RIVER"));
     temp.add(Biome.valueOf("TAIGA"));
     temp.add(Biome.valueOf("TAIGA_HILLS"));
     temp.add(Biome.valueOf("TAIGA_COLD_HILLS"));
     temp.add(Biome.valueOf("TAIGA_COLD"));
     temp.add(Biome.valueOf("MUTATED_TAIGA_COLD"));
     temp.add(Biome.valueOf("ICE_MOUNTAINS"));
     temp.add(Biome.valueOf("ICE_FLATS"));
     temp.add(Biome.valueOf("MUTATED_ICE_FLATS"));
   } catch (Exception e) {
     temp.clear();
     try {
       temp.add(Biome.valueOf("FROZEN_OCEAN"));
       temp.add(Biome.valueOf("FROZEN_RIVER"));
       temp.add(Biome.valueOf("TAIGA"));
       temp.add(Biome.valueOf("TAIGA_HILLS"));
       temp.add(Biome.valueOf("TAIGA_MOUNTAINS"));
       temp.add(Biome.valueOf("COLD_TAIGA"));
       temp.add(Biome.valueOf("COLD_TAIGA_HILLS"));
       temp.add(Biome.valueOf("COLD_TAIGA_MOUNTAINS"));
       temp.add(Biome.valueOf("ICE_MOUNTAINS"));
       temp.add(Biome.valueOf("ICE_PLAINS"));
       temp.add(Biome.valueOf("ICE_PLAINS_SPIKES"));
     } catch (Exception e1) {
       temp.clear();
     }
   } finally {
     try {
       set = EnumSet.copyOf(temp);
     } catch (IllegalArgumentException e) {
       mcMMO.p.getLogger().severe("Biome enum mismatch");
       ;
     }
     temp.clear();
   }
   ICE_BIOMES = set;
 }
コード例 #9
0
ファイル: BiomeNMS.java プロジェクト: Xenmai/Denizen
 public BiomeNMS(Biome biome) {
   this.biomeBase = CraftBlock.biomeToBiomeBase(biome);
   this.name = CoreUtilities.toLowerCase(biome.name());
 }
コード例 #10
0
  private void placeShrubs(World world, int rx, int rz, Random random) {
    for (int i = 0; i < random.nextInt(32); i++) {
      int x = random.nextInt(15);
      int z = random.nextInt(15);

      int ran = 0;

      Biome biome = world.getBiome(rx + x, rz + z);

      if (biome.equals(Biome.EXTREME_HILLS)) {
        ran = random.nextInt(16);
      } else if (biome.equals(Biome.FOREST) || biome.equals(Biome.FOREST_HILLS)) {
        ran = random.nextInt(6);
      } else if (biome.equals(Biome.PLAINS)) {
        ran = random.nextInt(20);
      } else if (biome.equals(Biome.JUNGLE) || biome.equals(Biome.JUNGLE_HILLS)) {
        ran = random.nextInt(3);
      } else if (biome.equals(Biome.SWAMPLAND)) {
        ran = random.nextInt(14);
      } else if (biome.equals(Biome.TAIGA) || biome.equals(Biome.TAIGA_HILLS)) {
        ran = random.nextInt(12);
      } else if (biome.equals(Biome.ROOFED_FOREST) || biome.equals(Biome.MUTATED_ROOFED_FOREST)) {
        ran = random.nextInt(7);
      } else if (biome.equals(Biome.DESERT)) {
        ran = random.nextInt(3);
      } else {
        ran = random.nextInt(5);
      }

      if (ran == 1) {
        Block block = world.getHighestBlockAt(rx + x, rz + z);
        block.setType(Material.DEAD_BUSH);
      }
    }
  }
コード例 #11
0
  private void placeCactuses(World world, int rx, int rz, Random random) {
    for (int i = 0; i < random.nextInt(32); i++) {
      int x = random.nextInt(15);
      int z = random.nextInt(15);

      int ran = 0;

      Biome biome = world.getBiome(rx + x, rz + z);

      if (biome.equals(Biome.EXTREME_HILLS)) {
        ran = random.nextInt(16);
      } else if (biome.equals(Biome.FOREST) || biome.equals(Biome.FOREST_HILLS)) {
        ran = random.nextInt(3);
      } else if (biome.equals(Biome.PLAINS)) {
        ran = random.nextInt(10);
      } else if (biome.equals(Biome.JUNGLE) || biome.equals(Biome.JUNGLE_HILLS)) {
        ran = random.nextInt(2);
      } else if (biome.equals(Biome.SWAMPLAND)) {
        ran = random.nextInt(8);
      } else if (biome.equals(Biome.TAIGA) || biome.equals(Biome.TAIGA_HILLS)) {
        ran = random.nextInt(20);
      } else if (biome.equals(Biome.ROOFED_FOREST) || biome.equals(Biome.MUTATED_ROOFED_FOREST)) {
        ran = random.nextInt(6);
      } else if (biome.equals(Biome.DESERT)) {
        ran = random.nextInt(100);
      }

      if (ran == 1) {
        Block block = world.getHighestBlockAt(rx + x, rz + z);
        block = world.getBlockAt(rx + x, block.getY() - 1, rz + z);
        if (block.getType().equals(Material.SAND)) {
          int y = block.getY();
          for (int j = 1; j < 2 + random.nextInt(4); j++) {
            block = world.getBlockAt(rx + x, y + j, rz + z);
            block.setType(Material.CACTUS);
          }
        }
      }
    }
  }
コード例 #12
0
ファイル: DMGenerator.java プロジェクト: Rocologo/DungeonMaze
  // Generate a chunk
  @Override
  public byte[] generate(World world, Random rand, int chunkx, int chunkz) {
    // Create a byte variable to write the chunk inside and return this variable
    byte[] result = new byte[32768];

    // This will set the whole floor to stone (the floor of each chunk)
    for (int y = 30 + 3; y > 0; y--)
      for (int x = 0; x < 16; x++)
        for (int z = 0; z < 16; z++) result[xyzToByte(x, y, z)] = (byte) Material.STONE.getId();

    // Set the lowest layer to bedrock
    for (int x = 0; x < 16; x++)
      for (int z = 0; z < 16; z++) result[xyzToByte(x, 0, z)] = (byte) Material.BEDROCK.getId();

    // The layers for each 5 rooms in the variable y
    for (int y = 30; y < 30 + (7 * 6); y += 6) {

      // The 4 rooms on each layer saved in the variables x and z
      for (int x = 0; x < 16; x += 8) {
        for (int z = 0; z < 16; z += 8) {

          int xr = (rand.nextInt(3) - 1) * (x + 7);
          int zr = (rand.nextInt(3) - 1) * (z + 7);

          int yfloor = rand.nextInt(2);

          // All the y of the room in the variable y2
          for (int y2 = y + yfloor; y2 < y + 8; y2++) {

            // All the x of the room in the variable x2
            for (int x2 = x; x2 < x + 8; x2++) {

              // All the z of the room in the variable z2
              for (int z2 = z; z2 < z + 8; z2++) {

                // Make the bottom of the room
                if (y2 == y + yfloor)
                  for (int xb = x; xb < x + 8; xb++)
                    for (int zb = z; zb < z + 8; zb++)
                      result[xyzToByte(xb, y2, zb)] = (byte) Material.COBBLESTONE.getId();

                // Fill the walls of the place with cobblestone
                if ((x2 == x || x2 == x + 7) && (z2 == z || z2 == z + 7))
                  result[xyzToByte(x2, y2, z2)] = (byte) 98;
                else if (xr == x2) result[xyzToByte(x2, y2, z2)] = (byte) 98;
                else if (zr == z2) result[xyzToByte(x2, y2, z2)] = (byte) 98;
                else result[xyzToByte(x2, y2, z2)] = (byte) Material.AIR.getId();
              }
            }
          }
        }
      }
    }

    // Create the nose generator which generates wave formes to use for the surface.
    Random random = new Random(world.getSeed());
    SimplexOctaveGenerator octave = new SimplexOctaveGenerator(random, 8);
    octave.setScale(1 / 48.0);

    // Generate the ceiling and the grass land
    for (int x = 0; x < 16; x++) {
      for (int z = 0; z < 16; z++) {
        /*int height = getHeight(world, chunkx + x * 0.0625, chunkz + z * 0.0625, 2) + 30+(7*6) + 7;*/
        double height = octave.noise(x + chunkx * 16, z + chunkz * 16, 0.5, 0.5) * 4 + 9;

        result[xyzToByte(x, 30 + (7 * 6), z)] = (byte) Material.COBBLESTONE.getId();
        for (int y = 30 + (7 * 6) + 1; y < 30 + (7 * 6) + 4; y++)
          result[xyzToByte(x, y, z)] = (byte) Material.STONE.getId();

        // Get the current biome
        Biome biome = world.getBiome((chunkx * 16) + x, (chunkz * 16) + z);

        if (biome.equals(Biome.DESERT) || biome.equals(Biome.DESERT_HILLS)) {
          for (int y = 30 + (7 * 6) + 4; y < 30 + (7 * 6) + 2 + height; y++)
            result[xyzToByte(x, y, z)] = (byte) Material.SAND.getId();

        } else if (biome.equals(Biome.MUSHROOM_ISLAND) || biome.equals(Biome.MUSHROOM_ISLAND)) {
          for (int y = 30 + (7 * 6) + 4; y < 30 + (7 * 6) + 2 + height; y++)
            result[xyzToByte(x, y, z)] = (byte) Material.DIRT.getId();
          result[xyzToByte(x, (int) (30 + (7 * 6) + 2 + height), z)] =
              (byte) Material.MYCEL.getId();

        } else {
          for (int y = 30 + (7 * 6) + 4; y < 30 + (7 * 6) + 2 + height; y++)
            result[xyzToByte(x, y, z)] = (byte) Material.DIRT.getId();
          result[xyzToByte(x, (int) (30 + (7 * 6) + 2 + height), z)] =
              (byte) Material.GRASS.getId();
        }
      }
    }

    return result;
  }
コード例 #13
0
  private void loadGrowthConfigs(ConfigurationSection config) {

    // load names that map to lists of biomes to be used as shorthand for those biomes
    ConfigurationSection biomeAliasSection = config.getConfigurationSection("biome_aliases");
    HashMap<String, List<Biome>> biomeAliases = new HashMap<String, List<Biome>>();
    for (String alias : biomeAliasSection.getKeys(false)) {
      // convert list of strings into list of biomes
      List<String> biomeStrs = biomeAliasSection.getStringList(alias);
      List<Biome> biomes = new ArrayList<Biome>();
      for (String biomeStr : biomeStrs) {
        try {
          Biome biome = Biome.valueOf(biomeStr);
          biomes.add(biome);
        } catch (IllegalArgumentException e) {
          LOG.warning(
              "loading configs: in biome_aliases: \"" + biomeStr + "\" is not a valid biome name.");
        }
      }

      // map those biomes to an alias
      biomeAliases.put(alias, biomes);
    }

    GrowthConfig defaultConfig = new GrowthConfig();

    materialGrowth = new HashMap<Object, GrowthConfig>();
    HashMap<String, GrowthConfig> growthConfigNodes = new HashMap<String, GrowthConfig>();

    ConfigurationSection growthConfigSection = config.getConfigurationSection("growth");
    for (String materialName : growthConfigSection.getKeys(false)) {
      ConfigurationSection configSection =
          growthConfigSection.getConfigurationSection(materialName);

      GrowthConfig inheritConfig = defaultConfig;

      if (configSection.isSet("inherit")) {
        String inheritStr = configSection.getString("inherit");

        if (growthConfigNodes.containsKey(inheritStr)) {
          inheritConfig = growthConfigNodes.get(inheritStr);
        } else {
          Object inheritKey = getMaterialKey(inheritStr);
          if (materialGrowth.containsKey(inheritKey)) {
            inheritConfig = materialGrowth.get(inheritKey);
          }
        }
      }

      GrowthConfig newGrowthConfig = new GrowthConfig(inheritConfig, configSection, biomeAliases);

      Object key = getMaterialKey(materialName);
      if (key == null) {
        // if the name is partially capitalized, then warning the player that
        // the name might be a misspelling
        if (materialName.length() > 0 && materialName.matches(".*[A-Z].*"))
          LOG.warning("config material name: is \"" + materialName + "\" misspelled?");
        growthConfigNodes.put(materialName, newGrowthConfig);
      } else {
        materialGrowth.put(key, newGrowthConfig);
      }
    }
  }