jfudson

Understanding structure generation algorithm

Jun 12th, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.34 KB | None | 0 0
  1.     @Override
  2.     protected ChunkPos getStart(ChunkGenerator<?> chunkGenerator, Random random, int chunkX, int chunkZ, int spacingMultiplier, int separationMultiplier) {
  3.         // from AbstractTempleFeature#shouldStartAt method, k = 0, l = 0
  4.         int spacing = this.getSpacing(chunkGenerator); // spacing = 32
  5.         int separation = this.getSeparation(chunkGenerator); // separation = 8
  6.         int o = chunkX + spacing * spacingMultiplier; // o == chunkX
  7.         int p = chunkZ + spacing * separationMultiplier; // p == chunkZ
  8.         int q = o < 0 ? o - spacing + 1 : o; // on the left side of the map; q == chunkX - 31, otherwise, just chunkX
  9.         int r = p < 0 ? p - spacing + 1 : p; // on the top side of the map; r = chunkZ - 31, otherwise, just chunkZ
  10.         int finalChunkX = q / spacing; // idk why do you have to divide by spacing
  11.         int finalChunkZ = r / spacing;
  12.         ((ChunkRandom)random).setStructureSeed(chunkGenerator.getSeed(), finalChunkX, finalChunkZ, this.getSeedModifier());
  13.         finalChunkX *= spacing; // finalChunkX == q; ignoring floating point
  14.         finalChunkZ *= spacing; // finalChunkZ == r; ignoring floating point
  15.         finalChunkX += random.nextInt(spacing - separation);
  16.         finalChunkZ += random.nextInt(spacing - separation);
  17.         return new ChunkPos(finalChunkX, finalChunkZ);
  18.     }
Advertisement
Add Comment
Please, Sign In to add comment