Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package izzyaxel.core.coreMain;
- import java.util.Random;
- import cpw.mods.fml.common.IWorldGenerator;
- import net.minecraft.block.Block;
- import net.minecraft.init.Blocks;
- import net.minecraft.world.World;
- import net.minecraft.world.chunk.IChunkProvider;
- import net.minecraft.world.gen.feature.WorldGenMinable;
- public class OreGeneration implements IWorldGenerator
- {
- @Override
- public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
- {
- switch(world.provider.dimensionId)
- {
- case 0: generateSurface(random, chunkX*16, chunkZ*16, world); break;
- case 1: generateEnd(random, chunkX*16, chunkZ*16, world); break;
- case-1: generateNether(random, chunkX*16, chunkZ*16, world); break;
- default: break;
- }
- }
- //Blocks.stone is the block your ore is going to replace
- public void addOreSpawn(Block block, World world, Random random, int blockXPos, int blockZPos, int minVeinSize, int maxVeinSize, int chancesToSpawn, int minY, int maxY)
- {
- for(int i = 0; i<chancesToSpawn; i++)
- {
- int posX = blockXPos + random.nextInt(16);
- int posY = minY + random.nextInt(maxY - minY);
- int posZ = blockZPos + random.nextInt(16);
- new WorldGenMinable(block, (minVeinSize + random.nextInt(maxVeinSize - minVeinSize)), Blocks.stone).generate(world, random, posX, posY, posZ);
- new WorldGenMinable(block, (minVeinSize + random.nextInt(maxVeinSize - minVeinSize)), Blocks.end_stone).generate(world, random, posX, posY, posZ);
- new WorldGenMinable(block, (minVeinSize + random.nextInt(maxVeinSize - minVeinSize)), Blocks.netherrack).generate(world, random, posX, posY, posZ);
- }
- }
- //(ore reference, 4 passed referenced vars, min vein size, max vein size, chancesToSpawn, min y level, max y level)
- //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
- public void generateSurface(Random random, int chunkX, int chunkZ, World world)
- {
- addOreSpawn(Main.platinumOre, world, random, chunkX, chunkZ, 1, 4, 10, 12, 30);
- addOreSpawn(Main.iridiumOre, world, random, chunkX, chunkZ, 1, 2, 2, 1, 11);
- addOreSpawn(Main.cobaltOre, world, random, chunkX, chunkZ, 1, 4, 15, 25, 60);
- addOreSpawn(Main.copperOre, world, random, chunkX, chunkZ, 4, 10, 38, 1, 250);
- addOreSpawn(Main.silverOre, world, random, chunkX, chunkZ, 2, 6, 15, 20, 40);
- }
- public void generateEnd(Random random, int chunkX, int chunkZ, World world)
- {
- addOreSpawn(Main.iridiumOreE, world, random, chunkX, chunkZ, 2, 6, 40, 10, 70);
- }
- public void generateNether(Random random, int chunkX, int chunkZ, World world)
- {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment