Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.chef.mod.generate;
- import java.util.Random;
- import com.chef.mod.Chef;
- import net.minecraft.block.Block;
- import net.minecraft.init.Blocks;
- import net.minecraft.world.World;
- import net.minecraft.world.biome.BiomeGenBase;
- import net.minecraft.world.biome.BiomeGenBeach;
- import net.minecraft.world.biome.BiomeGenMesa;
- import net.minecraft.world.biome.BiomeGenOcean;
- import net.minecraft.world.biome.BiomeGenRiver;
- import net.minecraft.world.chunk.IChunkProvider;
- import net.minecraft.world.gen.feature.WorldGenMinable;
- import cpw.mods.fml.common.IWorldGenerator;
- 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 1:
- generateEnd(world, random, chunkX, chunkZ);
- break;
- case 0:
- generateOverworld(world, random, chunkX, chunkZ);
- break;
- case -1:
- generateNether(world, random, chunkX, chunkZ);
- break;
- }
- }
- public void generateEnd(World world, Random rand, int x, int z) {
- }
- public void generateOverworld(World world, Random rand, int x, int z) {
- //world, rand, x, z, Minimal blocks to spawn, Maximal blocks to spawn, Chance to spawn, Minimal height to spawn, Maximal height to spawn, Block to spawn in
- generateOre(Chef.oreRockSaltOre, world, rand, x, z, 3, 7, 40, 80, 100, Blocks.stone);
- generateOreSand(Chef.oreSeaSaltOre, world, rand, x, z, 4, 8, 80, 50, 100, Blocks.sand);
- }
- public void generateNether(World world, Random rand, int x, int z) {
- }
- public void generateOre(Block block, World world, Random random, int chunkX, int chunkZ, int minVienSize, int maxVienSize, int chance, int minY, int maxY, Block generateIn) {
- int vienSize = minVienSize + random.nextInt(maxVienSize - minVienSize);
- int heightRange = maxY - minY;
- WorldGenMinable gen = new WorldGenMinable(block, vienSize, generateIn);
- for (int i = 0; i < 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);
- }
- }
- public void generateOreSand(Block block, World world, Random random, int chunkX, int chunkZ, int minVienSize, int maxVienSize, int chance, int minY, int maxY, Block generateIn) {
- int vienSize = minVienSize + random.nextInt(maxVienSize - minVienSize);
- int heightRange = maxY - minY;
- WorldGenMinableSand gen = new WorldGenMinableSand(block, vienSize, generateIn);
- BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenAt(chunkX, chunkZ);
- if(biome instanceof BiomeGenOcean || biome instanceof BiomeGenRiver || biome instanceof BiomeGenBeach) {
- for (int i = 0; i < 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