Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.henderry2019.OreGen;
- import java.util.Random;
- 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;
- import cpw.mods.fml.common.IWorldGenerator;
- public class Generation implements IWorldGenerator {
- @Override
- public void generate(Random random, int chunkX, int chunkZ, World world,
- IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
- switch (world.provider.dimensionId) {
- // Case 1 is End
- case 1:
- generateEnd(world, random, chunkX, chunkZ);
- break;
- // Case 0 is Overworld
- case 0:
- generateOverworld(world, random, chunkX, chunkZ);
- break;
- // Case -1 is Nether
- case -1:
- generateNether(world, random, chunkX, chunkZ);
- break;
- }
- }
- /**Generating ores in End | 1st # is minVienSize 2nd # is maxVienSize 3rd # is chance, 4th # is min world height, 5th is max world height.
- *Blocks.(block) is the block that it is spawned in.
- */
- public void generateEnd(World world, Random random, int x, int z) {
- generateOre(OreGen.blockRuby, world, random, x, z, 1, 10, 5, 5, 20, Blocks.end_stone);
- }
- //Generating ores in Overworld
- public void generateOverworld(World world, Random random, int x, int z) {
- generateOre(OreGen.blockRuby, world, random, x, z, 10, 20, 50, 1, 80, Blocks.stone);
- }
- //Generating ores in Nether
- public void generateNether(World world, Random random, int x, int z) {
- generateOre(OreGen.blockRuby, world, random, x, z, 1, 10, 5, 5, 20, Blocks.netherrack);
- }
- // Defining the generation
- public void generateOre(Block block, World world, Random random,
- int chunkX, int chunkZ, int minVeinSize, int maxVeinSize,
- int chance, int minY, int maxY, Block generateIn) {
- // Telling it that the vein size and height in world is random
- int vienSize = minVeinSize + random.nextInt(maxVeinSize) - minVeinSize;
- int heightRange = maxY - minY;
- WorldGenMinable gen = new WorldGenMinable(block, vienSize, generateIn);
- // Telling it that everything is random
- for (int i = 0; 1 < chance; i++) {
- int xRand = chunkX * 16 + random.nextInt(16);
- int yRand = random.nextInt(heightRange) + minY;
- int zRand = chunkZ * 16 + random.nextInt(16);
- gen.generate(world, random, xRand, yRand, zRand);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement