Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.58 KB | None | 0 0
  1. //
  2. // Source code recreated from a .class file by IntelliJ IDEA
  3. // (powered by Fernflower decompiler)
  4. //
  5.  
  6. package net.minecraft.server.v1_14_R1;
  7.  
  8. import java.util.BitSet;
  9. import java.util.Iterator;
  10. import java.util.List;
  11. import java.util.ListIterator;
  12. import java.util.Locale;
  13. import java.util.Map.Entry;
  14. import javax.annotation.Nullable;
  15. import net.minecraft.server.v1_14_R1.BiomeBase.BiomeMeta;
  16. import net.minecraft.server.v1_14_R1.HeightMap.Type;
  17. import net.minecraft.server.v1_14_R1.WorldGenStage.Decoration;
  18. import net.minecraft.server.v1_14_R1.WorldGenStage.Features;
  19.  
  20. public abstract class ChunkGenerator<C extends GeneratorSettingsDefault> {
  21. protected final GeneratorAccess a;
  22. protected final long seed;
  23. protected final WorldChunkManager c;
  24. protected final C settings;
  25.  
  26. public ChunkGenerator(GeneratorAccess generatoraccess, WorldChunkManager worldchunkmanager, C c0) {
  27. this.a = generatoraccess;
  28. this.seed = generatoraccess.getSeed();
  29. this.c = worldchunkmanager;
  30. this.settings = c0;
  31. }
  32.  
  33. public void createBiomes(IChunkAccess ichunkaccess) {
  34. ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos();
  35. int i = chunkcoordintpair.x;
  36. int j = chunkcoordintpair.z;
  37. BiomeBase[] abiomebase = this.c.getBiomeBlock(i * 16, j * 16, 16, 16);
  38. ichunkaccess.a(abiomebase);
  39. }
  40.  
  41. protected BiomeBase getCarvingBiome(IChunkAccess ichunkaccess) {
  42. return ichunkaccess.getBiome(BlockPosition.ZERO);
  43. }
  44.  
  45. protected BiomeBase getDecoratingBiome(RegionLimitedWorldAccess regionlimitedworldaccess, BlockPosition blockposition) {
  46. return this.c.getBiome(blockposition);
  47. }
  48.  
  49. public void doCarving(IChunkAccess ichunkaccess, Features worldgenstage_features) {
  50. SeededRandom seededrandom = new SeededRandom();
  51. boolean flag = true;
  52. ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos();
  53. int i = chunkcoordintpair.x;
  54. int j = chunkcoordintpair.z;
  55. BitSet bitset = ichunkaccess.a(worldgenstage_features);
  56.  
  57. for(int k = i - 8; k <= i + 8; ++k) {
  58. for(int l = j - 8; l <= j + 8; ++l) {
  59. List<WorldGenCarverWrapper<?>> list = this.getCarvingBiome(ichunkaccess).a(worldgenstage_features);
  60. ListIterator listiterator = list.listIterator();
  61.  
  62. while(listiterator.hasNext()) {
  63. int i1 = listiterator.nextIndex();
  64. WorldGenCarverWrapper<?> worldgencarverwrapper = (WorldGenCarverWrapper)listiterator.next();
  65. seededrandom.c(this.seed + (long)i1, k, l);
  66. if (worldgencarverwrapper.a(seededrandom, k, l)) {
  67. worldgencarverwrapper.a(ichunkaccess, seededrandom, this.getSeaLevel(), k, l, i, j, bitset);
  68. }
  69. }
  70. }
  71. }
  72.  
  73. }
  74.  
  75. @Nullable
  76. public BlockPosition findNearestMapFeature(World world, String s, BlockPosition blockposition, int i, boolean flag) {
  77. StructureGenerator<?> structuregenerator = (StructureGenerator)WorldGenerator.aP.get(s.toLowerCase(Locale.ROOT));
  78. return structuregenerator != null ? structuregenerator.getNearestGeneratedFeature(world, this, blockposition, i, flag) : null;
  79. }
  80.  
  81. public void addDecorations(RegionLimitedWorldAccess regionlimitedworldaccess) {
  82. int i = regionlimitedworldaccess.a();
  83. int j = regionlimitedworldaccess.b();
  84. int k = i * 16;
  85. int l = j * 16;
  86. BlockPosition blockposition = new BlockPosition(k, 0, l);
  87. BiomeBase biomebase = this.getDecoratingBiome(regionlimitedworldaccess, blockposition.b(8, 8, 8));
  88. SeededRandom seededrandom = new SeededRandom();
  89. long i1 = seededrandom.a(regionlimitedworldaccess.getSeed(), k, l);
  90. Decoration[] aworldgenstage_decoration = Decoration.values();
  91. int j1 = aworldgenstage_decoration.length;
  92.  
  93. for(int k1 = 0; k1 < j1; ++k1) {
  94. Decoration worldgenstage_decoration = aworldgenstage_decoration[k1];
  95.  
  96. try {
  97. biomebase.a(worldgenstage_decoration, this, regionlimitedworldaccess, i1, seededrandom, blockposition);
  98. } catch (Exception var17) {
  99. CrashReport crashreport = CrashReport.a(var17, "Biome decoration");
  100. crashreport.a("Generation").a("CenterX", i).a("CenterZ", j).a("Step", worldgenstage_decoration).a("Seed", i1).a("Biome", IRegistry.BIOME.getKey(biomebase));
  101. throw new ReportedException(crashreport);
  102. }
  103. }
  104.  
  105. }
  106.  
  107. public abstract void buildBase(IChunkAccess var1);
  108.  
  109. public void addMobs(RegionLimitedWorldAccess regionlimitedworldaccess) {
  110. }
  111.  
  112. public C getSettings() {
  113. return this.settings;
  114. }
  115.  
  116. public abstract int getSpawnHeight();
  117.  
  118. public void doMobSpawning(WorldServer worldserver, boolean flag, boolean flag1) {
  119. }
  120.  
  121. public boolean canSpawnStructure(BiomeBase biomebase, StructureGenerator<? extends WorldGenFeatureConfiguration> structuregenerator) {
  122. return biomebase.a(structuregenerator);
  123. }
  124.  
  125. @Nullable
  126. public <C extends WorldGenFeatureConfiguration> C getFeatureConfiguration(BiomeBase biomebase, StructureGenerator<C> structuregenerator) {
  127. return biomebase.b(structuregenerator);
  128. }
  129.  
  130. public WorldChunkManager getWorldChunkManager() {
  131. return this.c;
  132. }
  133.  
  134. public long getSeed() {
  135. return this.seed;
  136. }
  137.  
  138. public int getGenerationDepth() {
  139. return 256;
  140. }
  141.  
  142. public List<BiomeMeta> getMobsFor(EnumCreatureType enumcreaturetype, BlockPosition blockposition) {
  143. return this.a.getBiome(blockposition).getMobs(enumcreaturetype);
  144. }
  145.  
  146. public void createStructures(IChunkAccess ichunkaccess, ChunkGenerator<?> chunkgenerator, DefinedStructureManager definedstructuremanager) {
  147. Iterator iterator = WorldGenerator.aP.values().iterator();
  148.  
  149. while(iterator.hasNext()) {
  150. StructureGenerator<?> structuregenerator = (StructureGenerator)iterator.next();
  151. if (chunkgenerator.getWorldChunkManager().a(structuregenerator)) {
  152. SeededRandom seededrandom = new SeededRandom();
  153. ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos();
  154. StructureStart structurestart = StructureStart.a;
  155. if (structuregenerator == WorldGenerator.STRONGHOLD) {
  156. synchronized(structuregenerator) {
  157. if (structuregenerator.a(chunkgenerator, seededrandom, chunkcoordintpair.x, chunkcoordintpair.z)) {
  158. BiomeBase biomebase = this.getWorldChunkManager().getBiome(new BlockPosition(chunkcoordintpair.d() + 9, 0, chunkcoordintpair.e() + 9));
  159. StructureStart structurestart1 = structuregenerator.a().create(structuregenerator, chunkcoordintpair.x, chunkcoordintpair.z, biomebase, StructureBoundingBox.a(), 0, chunkgenerator.getSeed());
  160. structurestart1.a(this, definedstructuremanager, chunkcoordintpair.x, chunkcoordintpair.z, biomebase);
  161. structurestart = structurestart1.e() ? structurestart1 : StructureStart.a;
  162. }
  163. }
  164. } else if (structuregenerator.a(chunkgenerator, seededrandom, chunkcoordintpair.x, chunkcoordintpair.z)) {
  165. BiomeBase biomebase = this.getWorldChunkManager().getBiome(new BlockPosition(chunkcoordintpair.d() + 9, 0, chunkcoordintpair.e() + 9));
  166. StructureStart structurestart1 = structuregenerator.a().create(structuregenerator, chunkcoordintpair.x, chunkcoordintpair.z, biomebase, StructureBoundingBox.a(), 0, chunkgenerator.getSeed());
  167. structurestart1.a(this, definedstructuremanager, chunkcoordintpair.x, chunkcoordintpair.z, biomebase);
  168. structurestart = structurestart1.e() ? structurestart1 : StructureStart.a;
  169. }
  170.  
  171. ichunkaccess.a(structuregenerator.b(), structurestart);
  172. }
  173. }
  174.  
  175. }
  176.  
  177. public void storeStructures(GeneratorAccess generatoraccess, IChunkAccess ichunkaccess) {
  178. boolean flag = true;
  179. int i = ichunkaccess.getPos().x;
  180. int j = ichunkaccess.getPos().z;
  181. int k = i << 4;
  182. int l = j << 4;
  183.  
  184. for(int i1 = i - 8; i1 <= i + 8; ++i1) {
  185. for(int j1 = j - 8; j1 <= j + 8; ++j1) {
  186. long k1 = ChunkCoordIntPair.pair(i1, j1);
  187. Iterator iterator = generatoraccess.getChunkAt(i1, j1).h().entrySet().iterator();
  188.  
  189. while(iterator.hasNext()) {
  190. Entry<String, StructureStart> entry = (Entry)iterator.next();
  191. StructureStart structurestart = (StructureStart)entry.getValue();
  192. if (structurestart != StructureStart.a && structurestart.c().a(k, l, k + 15, l + 15)) {
  193. ichunkaccess.a((String)entry.getKey(), k1);
  194. PacketDebug.a(generatoraccess, structurestart);
  195. }
  196. }
  197. }
  198. }
  199.  
  200. }
  201.  
  202. public abstract void buildNoise(GeneratorAccess var1, IChunkAccess var2);
  203.  
  204. public int getSeaLevel() {
  205. return 63;
  206. }
  207.  
  208. public abstract int getBaseHeight(int var1, int var2, Type var3);
  209.  
  210. public int b(int i, int j, Type heightmap_type) {
  211. return this.getBaseHeight(i, j, heightmap_type);
  212. }
  213.  
  214. public int c(int i, int j, Type heightmap_type) {
  215. return this.getBaseHeight(i, j, heightmap_type) - 1;
  216. }
  217. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement