public CustomStructureGen(BiomeConfig biomeConfig, List<String> args)
      throws InvalidConfigException {
    super(biomeConfig);
    objects = new ArrayList<CustomObject>();
    objectNames = new ArrayList<String>();
    objectChances = new ArrayList<Double>();
    for (int i = 0; i < args.size() - 1; i += 2) {
      CustomObject object = getHolder().worldConfig.worldObjects.parseCustomObject(args.get(i));
      if (object == null || !object.canSpawnAsObject()) {
        throw new InvalidConfigException("No custom object found with the name " + args.get(i));
      }
      if (object.getBranches(Rotation.NORTH).length == 0) {
        throw new InvalidConfigException(
            "The object " + args.get(i) + " isn't a structure: it has no branches");
      }
      objects.add(object);
      objectNames.add(args.get(i));
      objectChances.add(readRarity(args.get(i + 1)));
    }

    // Inject ourselves in the BiomeConfig
    if (getHolder().structureGen != null) {
      throw new InvalidConfigException(
          "There can only be one CustomStructure resource in each BiomeConfig");
    }
    getHolder().structureGen = this;
  }
Esempio n. 2
0
  private void ReadWorldCustomObjects() {
    File directory = new File(SettingsDir, "BOBPlugins");
    if (directory.exists())
      if (!directory.renameTo(
          new File(SettingsDir, TCDefaultValues.BO_WorldDirectoryName.stringValue()))) {
        System.out.println("TerrainControl: Can`t rename old custom objects folder");
      }

    directory = new File(this.SettingsDir, TCDefaultValues.BO_WorldDirectoryName.stringValue());

    if (!directory.exists()) {
      if (!directory.mkdirs()) {
        System.out.println("TerrainControl: can`t create WorldObjects directory");
        return;
      }
    }

    ArrayList<CustomObject> rawObjects = ObjectsStore.LoadObjectsFromDirectory(directory);

    CustomObjectsCompiled = new ArrayList<CustomObjectCompiled>();

    for (CustomObject object : rawObjects) CustomObjectsCompiled.add(object.Compile(""));
    System.out.println(
        "TerrainControl:" + CustomObjectsCompiled.size() + " world custom objects loaded");
  }