Guest User

Untitled

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