izzyaxel

Minecraft/Forge 1.7.2 Ore Generation

May 23rd, 2014
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.81 KB | None | 0 0
  1. package izzyaxel.core.coreMain;
  2.  
  3. import java.util.Random;
  4.  
  5. import cpw.mods.fml.common.IWorldGenerator;
  6. import net.minecraft.block.Block;
  7. import net.minecraft.init.Blocks;
  8. import net.minecraft.world.World;
  9. import net.minecraft.world.chunk.IChunkProvider;
  10. import net.minecraft.world.gen.feature.WorldGenMinable;
  11.  
  12. public class OreGeneration implements IWorldGenerator
  13. {
  14.     @Override
  15.     public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
  16.     {
  17.         switch(world.provider.dimensionId)
  18.         {
  19.             case 0: generateSurface(random, chunkX*16, chunkZ*16, world); break;
  20.             case 1: generateEnd(random, chunkX*16, chunkZ*16, world); break;
  21.             case-1: generateNether(random, chunkX*16, chunkZ*16, world); break;
  22.             default: break;
  23.         }
  24.     }
  25.  
  26.     //Blocks.stone is the block your ore is going to replace
  27.      public void addOreSpawn(Block block, World world, Random random, int blockXPos, int blockZPos, int minVeinSize, int maxVeinSize, int chancesToSpawn, int minY, int maxY)
  28.         {
  29.             for(int i = 0; i<chancesToSpawn; i++)
  30.             {
  31.                 int posX = blockXPos + random.nextInt(16);
  32.                 int posY = minY + random.nextInt(maxY - minY);
  33.                 int posZ = blockZPos + random.nextInt(16);
  34.                 new WorldGenMinable(block, (minVeinSize + random.nextInt(maxVeinSize - minVeinSize)), Blocks.stone).generate(world, random, posX, posY, posZ);
  35.                 new WorldGenMinable(block, (minVeinSize + random.nextInt(maxVeinSize - minVeinSize)), Blocks.end_stone).generate(world, random, posX, posY, posZ);
  36.                 new WorldGenMinable(block, (minVeinSize + random.nextInt(maxVeinSize - minVeinSize)), Blocks.netherrack).generate(world, random, posX, posY, posZ);
  37.             }
  38.         }
  39.    
  40.      //(ore reference, 4 passed referenced vars, min vein size, max vein size, chancesToSpawn, min y level, max y level)
  41.      //chancesToSpawn is how many times the generator picks a random block of the selected type in each chunk to be the start of a vein of your ore
  42.      public void generateSurface(Random random, int chunkX, int chunkZ, World world)
  43.         {
  44.             addOreSpawn(Main.platinumOre, world, random, chunkX, chunkZ, 1, 4, 10, 12, 30);
  45.             addOreSpawn(Main.iridiumOre, world, random, chunkX, chunkZ, 1, 2, 2, 1, 11);
  46.             addOreSpawn(Main.cobaltOre, world, random, chunkX, chunkZ, 1, 4, 15, 25, 60);
  47.             addOreSpawn(Main.copperOre, world, random, chunkX, chunkZ, 4, 10, 38, 1, 250);
  48.             addOreSpawn(Main.silverOre, world, random, chunkX, chunkZ, 2, 6, 15, 20, 40);
  49.         }
  50.      
  51.         public void generateEnd(Random random, int chunkX, int chunkZ, World world)
  52.         {
  53.             addOreSpawn(Main.iridiumOreE, world, random, chunkX, chunkZ, 2, 6, 40, 10, 70);
  54.         }
  55.      
  56.         public void generateNether(Random random, int chunkX, int chunkZ, World world)
  57.         {
  58.            
  59.         }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment