Guest User

Untitled

a guest
May 11th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.76 KB | None | 0 0
  1. package fr.craftesys.craftesys.generation;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5.  
  6.  
  7. import net.minecraft.util.WeightedRandom;
  8. import net.minecraft.world.WorldType;
  9. import net.minecraft.world.biome.BiomeGenBase;
  10. import net.minecraft.world.gen.layer.GenLayer;
  11. import net.minecraft.world.gen.layer.IntCache;
  12. import net.minecraftforge.common.BiomeManager;
  13. import net.minecraftforge.common.BiomeManager.BiomeEntry;
  14. import net.minecraftforge.common.BiomeDictionary;
  15.  
  16.  
  17. public class GiantGenLayerBiome extends GenLayer
  18. {
  19. private List<BiomeEntry>[] biomes = new ArrayList[BiomeManager.BiomeType.values().length];
  20.  
  21. private static final String __OBFID = "CL_00000555";
  22.  
  23. public GiantGenLayerBiome(long p_i2122_1_, GenLayer p_i2122_3_, WorldType p_i2122_4_)
  24. {
  25. super(p_i2122_1_);
  26.  
  27. this.parent = p_i2122_3_;
  28.  
  29. for (BiomeManager.BiomeType type : BiomeManager.BiomeType.values())
  30. {
  31. com.google.common.collect.ImmutableList<BiomeEntry> biomesToAdd = BiomeManager.getBiomes(type);
  32. int idx = type.ordinal();
  33.  
  34. if (biomes[idx] == null) biomes[idx] = new ArrayList<BiomeEntry>();
  35. if (biomesToAdd != null) biomes[idx].addAll(biomesToAdd);
  36. }
  37.  
  38. int desertIdx = BiomeManager.BiomeType.DESERT.ordinal();
  39.  
  40. if (p_i2122_4_ == WorldType.DEFAULT_1_1)
  41. {
  42. biomes[desertIdx].add(new BiomeEntry(BiomeGenBase.desert, 10));
  43. biomes[desertIdx].add(new BiomeEntry(BiomeGenBase.forest, 10));
  44. biomes[desertIdx].add(new BiomeEntry(BiomeGenBase.extremeHills, 10));
  45. biomes[desertIdx].add(new BiomeEntry(BiomeGenBase.swampland, 10));
  46. biomes[desertIdx].add(new BiomeEntry(BiomeGenBase.plains, 10));
  47. biomes[desertIdx].add(new BiomeEntry(BiomeGenBase.taiga, 10));
  48. biomes[desertIdx].add(new BiomeEntry(BiomeRegistry.giantbiome, 157));
  49.  
  50.  
  51. }
  52. else
  53. {
  54. biomes[desertIdx].add(new BiomeEntry(BiomeGenBase.desert, 30));
  55. biomes[desertIdx].add(new BiomeEntry(BiomeGenBase.savanna, 20));
  56. biomes[desertIdx].add(new BiomeEntry(BiomeGenBase.plains, 10));
  57. biomes[desertIdx].add(new BiomeEntry(BiomeRegistry.giantbiome, 157));
  58.  
  59. }
  60. }
  61.  
  62. /**
  63. * Returns a list of integer values generated by this layer. These may be interpreted as temperatures, rainfall
  64. * amounts, or biomeList[] indices based on the particular GenLayer subclass.
  65. */
  66. public int[] getInts(int p_75904_1_, int p_75904_2_, int p_75904_3_, int p_75904_4_)
  67. {
  68. int[] aint = this.parent.getInts(p_75904_1_, p_75904_2_, p_75904_3_, p_75904_4_);
  69. int[] aint1 = IntCache.getIntCache(p_75904_3_ * p_75904_4_);
  70.  
  71. for (int i1 = 0; i1 < p_75904_4_; ++i1)
  72. {
  73. for (int j1 = 0; j1 < p_75904_3_; ++j1)
  74. {
  75. this.initChunkSeed((long)(j1 + p_75904_1_), (long)(i1 + p_75904_2_));
  76. int k1 = aint[j1 + i1 * p_75904_3_];
  77. int l1 = (k1 & 3840) >> 8;
  78. k1 &= -3841;
  79.  
  80. if (isBiomeOceanic(k1))
  81. {
  82. aint1[j1 + i1 * p_75904_3_] = k1;
  83. }
  84. else if (k1 == BiomeGenBase.mushroomIsland.biomeID)
  85. {
  86. aint1[j1 + i1 * p_75904_3_] = k1;
  87. }
  88. else if (k1 == 1)
  89. {
  90. if (l1 > 0)
  91. {
  92. if (this.nextInt(3) == 0)
  93. {
  94. aint1[j1 + i1 * p_75904_3_] = BiomeGenBase.mesaPlateau.biomeID;
  95. }
  96. else
  97. {
  98. aint1[j1 + i1 * p_75904_3_] = BiomeGenBase.mesaPlateau_F.biomeID;
  99. }
  100. }
  101. else
  102. {
  103. aint1[j1 + i1 * p_75904_3_] = getWeightedBiomeEntry(BiomeManager.BiomeType.DESERT).biome.biomeID;
  104. }
  105. }
  106. else if (k1 == 2)
  107. {
  108. if (l1 > 0)
  109. {
  110. aint1[j1 + i1 * p_75904_3_] = BiomeGenBase.jungle.biomeID;
  111. }
  112. else
  113. {
  114. aint1[j1 + i1 * p_75904_3_] = getWeightedBiomeEntry(BiomeManager.BiomeType.WARM).biome.biomeID;
  115. }
  116. }
  117. else if (k1 == 3)
  118. {
  119. if (l1 > 0)
  120. {
  121. aint1[j1 + i1 * p_75904_3_] = BiomeGenBase.megaTaiga.biomeID;
  122. }
  123. else
  124. {
  125. aint1[j1 + i1 * p_75904_3_] = getWeightedBiomeEntry(BiomeManager.BiomeType.COOL).biome.biomeID;
  126. }
  127. }
  128. else if (k1 == 4)
  129. {
  130. aint1[j1 + i1 * p_75904_3_] = getWeightedBiomeEntry(BiomeManager.BiomeType.ICY).biome.biomeID;
  131. }
  132. else
  133. {
  134. aint1[j1 + i1 * p_75904_3_] = BiomeGenBase.mushroomIsland.biomeID;
  135. }
  136. }
  137. }
  138.  
  139. return aint1;
  140. }
  141.  
  142. protected BiomeEntry getWeightedBiomeEntry(BiomeManager.BiomeType type)
  143. {
  144. List<BiomeEntry> biomeList = biomes[type.ordinal()];
  145. int totalWeight = WeightedRandom.getTotalWeight(biomeList);
  146. int weight = BiomeManager.isTypeListModded(type)?nextInt(totalWeight):nextInt(totalWeight / 10) * 10;
  147. return (BiomeEntry)WeightedRandom.getItem(biomeList, weight);
  148. }
  149. }
Add Comment
Please, Sign In to add comment