CustomObjectStructure(LocalWorld world, CustomObjectCoordinate start) { CustomObject object = start.getObject(); this.world = world; this.start = start; this.height = object.getStructurePartSpawnHeight(); this.maxBranchDepth = object.getMaxBranchDepth(); random = RandomHelper.getRandomForCoords(start.getX(), start.getY(), start.getZ(), world.getSeed()); // Calculate all branches and add them to a list objectsToSpawn = new LinkedHashMap<ChunkCoordinate, Set<CustomObjectCoordinate>>(); addToSpawnList(start); // Add the object itself addBranches(start, 1); }
private void addBranches(CustomObjectCoordinate coordObject, int depth) { for (Branch branch : getBranches(coordObject.getObject(), coordObject.getRotation())) { CustomObjectCoordinate childCoordObject = branch.toCustomObjectCoordinate( world, random, coordObject.getX(), coordObject.getY(), coordObject.getZ()); // Don't add null objects if (childCoordObject == null) { continue; } // Add this object to the chunk addToSpawnList(childCoordObject); // Also add the branches of this object if (depth < maxBranchDepth) { addBranches(childCoordObject, depth + 1); } } }