Advertisement
NathanHam89

Ore Generator

Apr 19th, 2015
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.94 KB | None | 0 0
  1. package com.penumbral.steelworks.world;
  2.  
  3. import java.util.Random;
  4.  
  5. import net.minecraft.block.Block;
  6. import net.minecraft.block.BlockStone;
  7. import net.minecraft.block.state.IBlockState;
  8. import net.minecraft.block.state.pattern.BlockHelper;
  9. import net.minecraft.init.Blocks;
  10. import net.minecraft.util.BlockPos;
  11. import net.minecraft.world.World;
  12. import net.minecraft.world.chunk.IChunkProvider;
  13. import net.minecraft.world.gen.feature.WorldGenMinable;
  14. import net.minecraftforge.fml.common.IWorldGenerator;
  15.  
  16. import com.penumbral.steelworks.init.SteelworksBlocks;
  17.  
  18. public class OreGeneration implements IWorldGenerator{
  19.  
  20.     @Override
  21.     public void generate(Random random, int chunkX, int chunkZ, World world,
  22.             IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
  23.         switch(world.provider.getDimensionId())
  24.         {
  25.         case 1:
  26.             generateEnd(world, random, chunkX * 16, chunkZ * 16); break;
  27.         case 0:
  28.             generateOverworld(world, random, chunkX * 16, chunkZ * 16); break;
  29.         case -1:
  30.             generateNether(world, random, chunkX * 16, chunkZ * 16); break;
  31.         }
  32.     }
  33.    
  34.     private void generateEnd(World world, Random random, int x, int z) {
  35.        
  36.     }
  37.    
  38.     public void generateOverworld(World world, Random random, int x, int z) {
  39.  
  40.         generateOre(SteelworksBlocks.fire_clayblock, world, random, x, z, 4, 8, 100, 10, 64);
  41.     }
  42.    
  43.     private void generateNether(World world, Random random, int x, int z) {
  44.        
  45.     }
  46.  
  47.     public void generateOre(Block block, World world, Random random, int posX, int posZ, int minVein, int maxVein, int spawnChance, int minY, int maxY)
  48.     {
  49.         WorldGenMinable gen = new WorldGenMinable(block.getDefaultState(), (minVein + random.nextInt(maxVein - minVein)), BlockHelper.forBlock(Blocks.stone));
  50.         for (int i = 0; i < spawnChance; i++) {
  51.             int xPos = posX + random.nextInt(16);
  52.             int yPos = minY + random.nextInt(maxY - minY);
  53.             int zPos = posZ + random.nextInt(16);
  54.             gen.generate(world, random, new BlockPos(xPos, yPos, zPos));
  55.         }
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement