Advertisement
Guest User

Generation Code

a guest
Feb 8th, 2015
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.35 KB | None | 0 0
  1. package me.henderry2019.OreGen;
  2.  
  3. import java.util.Random;
  4.  
  5. import net.minecraft.block.Block;
  6. import net.minecraft.init.Blocks;
  7. import net.minecraft.world.World;
  8. import net.minecraft.world.chunk.IChunkProvider;
  9. import net.minecraft.world.gen.feature.WorldGenMinable;
  10. import cpw.mods.fml.common.IWorldGenerator;
  11.  
  12. public class Generation implements IWorldGenerator {
  13.  
  14.     @Override
  15.     public void generate(Random random, int chunkX, int chunkZ, World world,
  16.             IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
  17.         switch (world.provider.dimensionId) {
  18.         // Case 1 is End
  19.         case 1:
  20.             generateEnd(world, random, chunkX, chunkZ);
  21.             break;
  22.         // Case 0 is Overworld
  23.         case 0:
  24.             generateOverworld(world, random, chunkX, chunkZ);
  25.             break;
  26.         // Case -1 is Nether
  27.         case -1:
  28.             generateNether(world, random, chunkX, chunkZ);
  29.             break;
  30.         }
  31.     }
  32.     /**Generating ores in End | 1st # is minVienSize 2nd # is maxVienSize 3rd # is chance, 4th # is min world height, 5th is max world height.
  33.      *Blocks.(block) is the block that it is spawned in.
  34.     */
  35.     public void generateEnd(World world, Random random, int x, int z) {
  36.         generateOre(OreGen.blockRuby, world, random, x, z, 1, 10, 5, 5, 20, Blocks.end_stone);
  37.     }
  38.     //Generating ores in Overworld
  39.     public void generateOverworld(World world, Random random, int x, int z) {
  40.         generateOre(OreGen.blockRuby, world, random, x, z, 10, 20, 50, 1, 80, Blocks.stone);
  41.     }
  42.     //Generating ores in Nether
  43.     public void generateNether(World world, Random random, int x, int z) {
  44.         generateOre(OreGen.blockRuby, world, random, x, z, 1, 10, 5, 5, 20, Blocks.netherrack);
  45.     }
  46.  
  47.     // Defining the generation
  48.     public void generateOre(Block block, World world, Random random,
  49.             int chunkX, int chunkZ, int minVeinSize, int maxVeinSize,
  50.             int chance, int minY, int maxY, Block generateIn) {
  51.         // Telling it that the vein size and height in world is random
  52.         int vienSize = minVeinSize + random.nextInt(maxVeinSize) - minVeinSize;
  53.         int heightRange = maxY - minY;
  54.         WorldGenMinable gen = new WorldGenMinable(block, vienSize, generateIn);
  55.         // Telling it that everything is random
  56.         for (int i = 0; 1 < chance; i++) {
  57.             int xRand = chunkX * 16 + random.nextInt(16);
  58.             int yRand = random.nextInt(heightRange) + minY;
  59.             int zRand = chunkZ * 16 + random.nextInt(16);
  60.             gen.generate(world, random, xRand, yRand, zRand);
  61.         }
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement