Advertisement
Camellias_

Untitled

Jun 14th, 2019
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.19 KB | None | 0 0
  1. package com.camellias.voidaicarcania.common.world.dimensions;
  2.  
  3. import java.util.List;
  4. import java.util.Random;
  5.  
  6. import com.camellias.voidaicarcania.core.init.ModBiomes;
  7.  
  8. import net.minecraft.block.BlockFalling;
  9. import net.minecraft.block.state.IBlockState;
  10. import net.minecraft.entity.EnumCreatureType;
  11. import net.minecraft.init.Blocks;
  12. import net.minecraft.util.math.BlockPos;
  13. import net.minecraft.world.EnumSkyBlock;
  14. import net.minecraft.world.World;
  15. import net.minecraft.world.biome.Biome;
  16. import net.minecraft.world.biome.Biome.SpawnListEntry;
  17. import net.minecraft.world.chunk.Chunk;
  18. import net.minecraft.world.chunk.ChunkPrimer;
  19. import net.minecraft.world.gen.IChunkGenerator;
  20. import net.minecraftforge.event.ForgeEventFactory;
  21.  
  22. public class ChunkGeneratorVoid implements IChunkGenerator
  23. {
  24.     protected static final IBlockState BEDROCK = Blocks.BEDROCK.getDefaultState();
  25.    
  26.     private final Random rand;
  27.     private final World world;
  28.     private double[] buffer;
  29.     private int chunkX = 0;
  30.     private int chunkZ = 0;
  31.    
  32.     public ChunkGeneratorVoid(World world, boolean useless, long rand, BlockPos pos)
  33.     {
  34.         this.world = world;
  35.         this.rand = new Random(rand);
  36.     }
  37.    
  38.     public void setBlocksInChunk(int i, int j, ChunkPrimer primer)
  39.     {
  40.         for(int x = 0; x < 16; ++x)
  41.         {
  42.             for(int z = 0; z < 16; ++z)
  43.             {
  44.                 IBlockState iblockstate;
  45.                
  46.                 for(int y = 255; y >= 248; y--)
  47.                 {
  48.                     if(y > 255 - this.rand.nextInt(5) || y == 255)
  49.                     {
  50.                         primer.setBlockState(x, y, z, BEDROCK);
  51.                     }
  52.                 }
  53.             }
  54.         }
  55.     }
  56.    
  57.     @Override
  58.     public Chunk generateChunk(int x, int z)
  59.     {
  60.         this.chunkX = x;
  61.         this.chunkZ = z;
  62.         this.rand.setSeed((long)x * 341873128712L + (long)z * 132897987541L);
  63.         ChunkPrimer chunkprimer = new ChunkPrimer();
  64.         this.setBlocksInChunk(x, z, chunkprimer);
  65.         Chunk chunk = new Chunk(this.world, chunkprimer, x, z);
  66.         byte[] abyte = chunk.getBiomeArray();
  67.        
  68.         for(int i = 0; i < abyte.length; ++i)
  69.         {
  70.             abyte[i] = (byte)Biome.getIdForBiome(ModBiomes.VOID);
  71.         }
  72.        
  73.         chunk.generateSkylightMap();
  74.         return chunk;
  75.     }
  76.    
  77.     @Override
  78.     public void populate(int x, int z)
  79.     {
  80.         BlockFalling.fallInstantly = true;
  81.         ForgeEventFactory.onChunkPopulate(true, this, this.world, this.rand, x, z, false);
  82.         BlockPos blockpos = new BlockPos(x * 16, 0, z * 16);
  83.        
  84.         this.world.getBiome(blockpos.add(16, 0, 16)).decorate(this.world, this.world.rand, blockpos);
  85.        
  86.         ForgeEventFactory.onChunkPopulate(false, this, this.world, this.rand, x, z, false);
  87.         BlockFalling.fallInstantly = false;
  88.     }
  89.    
  90.     @Override
  91.     public boolean generateStructures(Chunk chunk, int x, int z)
  92.     {
  93.         return false;
  94.     }
  95.    
  96.     @Override
  97.     public List<SpawnListEntry> getPossibleCreatures(EnumCreatureType creatureType, BlockPos pos)
  98.     {
  99.         return this.world.getBiome(pos).getSpawnableList(creatureType);
  100.     }
  101.    
  102.     @Override
  103.     public BlockPos getNearestStructurePos(World world, String structureName, BlockPos position, boolean findUnexplored)
  104.     {
  105.         return null;
  106.     }
  107.    
  108.     @Override
  109.     public void recreateStructures(Chunk chunkIn, int x, int z)
  110.     {
  111.        
  112.     }
  113.    
  114.     @Override
  115.     public boolean isInsideStructure(World world, String structureName, BlockPos pos)
  116.     {
  117.         return false;
  118.     }
  119. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement