Package cofh.lib.util

Examples of cofh.lib.util.WeightedRandomBlock


        log.error("Invalid block entry!");
        return null;
      }
      int metadata = blockElement.has("metadata") ? MathHelper.clampI(blockElement.get("metadata").getAsInt(), 0, 15) : 0;
      int weight = blockElement.has("weight") ? MathHelper.clampI(blockElement.get("weight").getAsInt(), 1, 1000000) : 100;
      return new WeightedRandomBlock(block, metadata, weight);
    } else {
      Block block = parseBlockName(genElement.getAsString());
      if (block == null) {
        log.error("Invalid block entry!");
        return null;
      }
      return new WeightedRandomBlock(block, 0);
    }
  }
View Full Code Here


    if (genElement.isJsonArray()) {
      JsonArray blockList = genElement.getAsJsonArray();

      for (int i = 0, e = blockList.size(); i < e; i++) {
        WeightedRandomBlock entry = parseBlockEntry(blockList.get(i));
        if (entry == null) {
          return false;
        }
        resList.add(entry);
      }
    } else {
      WeightedRandomBlock entry = parseBlockEntry(genElement);
      if (entry == null) {
        return false;
      }
      resList.add(entry);
    }
View Full Code Here

public class SurfaceParser extends UniformParser {

  @Override
  protected List<WeightedRandomBlock> generateDefaultMaterial() {

    return Arrays.asList(new WeightedRandomBlock(Blocks.stone, -1), new WeightedRandomBlock(Blocks.dirt, -1), new WeightedRandomBlock(Blocks.grass, -1),
        new WeightedRandomBlock(Blocks.sand, -1), new WeightedRandomBlock(Blocks.gravel, -1), new WeightedRandomBlock(Blocks.snow, -1),
        new WeightedRandomBlock(Blocks.air, -1), new WeightedRandomBlock(Blocks.water, -1));
  }
View Full Code Here

    defaultMaterial = generateDefaultMaterial();
  }

  protected List<WeightedRandomBlock> generateDefaultMaterial() {

    return Arrays.asList(new WeightedRandomBlock(new ItemStack(Blocks.stone, 1, -1)));
  }
View Full Code Here

      }
      WorldGenAdvLakes r = new WorldGenAdvLakes(resList, useMaterial ? matList : null);
      if (isObject) {
        if (genObject.has("outlineWithStone"))
          r.outlineBlock = genObject.get("outlineWithStone").getAsBoolean() ?
              new WeightedRandomBlock(Blocks.stone, 0) : null;
        if (genObject.has("outlineBlock"))
          r.outlineBlock = FeatureParser.parseBlockEntry(genObject.get("outlineBlock"));
        if (genObject.has("gapBlock"))
          r.gapBlock = FeatureParser.parseBlockEntry(genObject.get("gapBlock"));
        if (genObject.has("lineWithFiller"))
          r.lineWithFiller = genObject.get("lineWithFiller").getAsBoolean();
      }
      return r;
    } else if ("geode".equals(template)) {
      ArrayList<WeightedRandomBlock> list = new ArrayList<WeightedRandomBlock>();
      if (!entry.has("crust")) {
        log.info("Entry does not specify crust for 'geode' generator. Using stone.");
        list.add(new WeightedRandomBlock(Blocks.stone));
      } else {
        if (!FeatureParser.parseResList(entry.get("crust"), list)) {
          log.warn("Entry specifies invalid crust for 'geode' generator! Using obsidian!");
          list.clear();
          list.add(new WeightedRandomBlock(Blocks.obsidian));
        }
      }
      WorldGenGeode r = new WorldGenGeode(resList, matList, list);
      if (isObject) {
        if (genObject.has("hollow"))
          r.hollow = genObject.get("hollow").getAsBoolean();
      }
      return r;
    } else if ("decoration".equals(template)) {
      ArrayList<WeightedRandomBlock> list = new ArrayList<WeightedRandomBlock>();
      if (!entry.has("genSurface")) {
        log.info("Entry does not specify genSurface for 'decoration' generator. Using grass.");
        list.add(new WeightedRandomBlock(Blocks.grass));
      } else {
        if (!FeatureParser.parseResList(entry.get("crust"), list)) {
          log.warn("Entry specifies invalid genSurface for 'decoration' generator! Using grass!");
          list.clear();
          list.add(new WeightedRandomBlock(Blocks.grass));
        }
      }
      WorldGenDecoration r = new WorldGenDecoration(resList, clusterSize, matList, list);
      if (genObject.has("genSky"))
        r.seeSky = genObject.get("genSky").getAsBoolean();
View Full Code Here

public class UnderfluidParser extends UniformParser {

  @Override
  protected List<WeightedRandomBlock> generateDefaultMaterial() {

    return Arrays.asList(new WeightedRandomBlock(Blocks.dirt, -1), new WeightedRandomBlock(Blocks.grass, -1));
  }
View Full Code Here

public class DecorationParser extends SurfaceParser {

  @Override
  protected List<WeightedRandomBlock> generateDefaultMaterial() {

    return Arrays.asList(new WeightedRandomBlock(Blocks.air, -1));
  }
View Full Code Here

TOP

Related Classes of cofh.lib.util.WeightedRandomBlock

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.