Barteks2x

Untitled

Jun 17th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.05 KB | None | 0 0
  1.     @Override public void registerWorldGen(ICubicWorldServer world, GeneratorPipeline pipeline) {
  2.         ServerCubeCache cubeCache = world.getCubeCache();
  3.  
  4.         ChunkProviderOverworld vanillaGen = new ChunkProviderOverworld((World) world, world.getSeed(), true, "");
  5.  
  6.         // init the worldgen pipeline
  7.         GeneratorStage terrain = new VanillaStage("terrain", new Vec3i(0, 0, 0), new Vec3i(0, 15, 0), null);
  8.         GeneratorStage lighting = new VanillaStage("lighting", new Vec3i(0, 0, 0), new Vec3i(0, 15, 0),
  9.                 new RegionDependency(lighting, /*whatever*/));
  10.         GeneratorStage population = new VanillaStage("population", new Vec3i(0, 0, 0), new Vec3i(0, 15, 0), null);
  11.  
  12.         pipeline.addStage(terrain, new VanillaTerrainProcessor(lighting, world, vanillaGen, 5));
  13.         pipeline.addStage(lighting, new VanillaFirstLightProcessor(lighting, population, cubeCache, 5));
  14.         pipeline.addStage(population, new VanillaPopulationProcessor(population, world, vanillaGen, 5));
  15.  
  16.     }
  17.  
  18.     public static void create() {
  19.         new VanillaCubicChunksWorldType();
  20.     }
  21.  
  22.     private static class VanillaStage extends GeneratorStage {
  23.         private final CubeDependency[] depsForHeight = new CubeDependency[16];
  24.         private CubeDependency normal;
  25.  
  26.         private VanillaStage(String name, Vec3i depStart, Vec3i depEnd, @Nullable CubeDependency normal) {
  27.             super(name);
  28.             this.normal = normal;
  29.             for (int y = 0; y < 16; y++) {
  30.                 //each cube requires cubes from y=0 to y=15
  31.                 //but relative to them, these positions are different
  32.                 //relative coords: requiredCubePos - currentCubePos
  33.                 int startY = depStart.getY() - y;
  34.                 int endY = depEnd.getY() - y;
  35.                 Vec3i start = new Vec3i(depStart.getX(), startY, depStart.getZ());
  36.                 Vec3i end = new Vec3i(depEnd.getX(), endY, depEnd.getZ());
  37.                 CubeDependency dep = new RegionDependency(this, start, end);
  38.                 depsForHeight[y] = dep;
  39.             }
  40.         }
  41.  
  42.         @Nullable @Override public CubeDependency getCubeDependency(@Nonnull Cube cube) {
  43.             if (cube.getY() < 0 || cube.getY() >= depsForHeight.length) {
  44.                 return normal;
  45.             }
  46.             return depsForHeight[cube.getY()];
  47.         }
  48.     }
Advertisement
Add Comment
Please, Sign In to add comment