Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package will11690.mechanicraft.world.gen;
- import java.util.Random;
- import net.minecraft.util.math.BlockPos;
- import net.minecraft.world.World;
- import net.minecraft.world.chunk.IChunkProvider;
- import net.minecraft.world.gen.IChunkGenerator;
- import net.minecraft.world.gen.feature.WorldGenerator;
- import net.minecraftforge.fml.common.IWorldGenerator;
- public class WorldGenCustomOres implements IWorldGenerator{
- private WorldGenerator RUBY_ORE, SAPPHIRE_ORE, COPPER_ORE, LEAD_ORE, SILVER_ORE, TIN_ORE;
- RUBY_ORE = new WorldGenMineable(ModBlock.RUBY_ORE, 3, BlockMatcher.forBlock(Blocks.STONE));
- SAPPHIRE_ORE = new WorldGenMineable(ModBlock.SAPPHIRE_ORE, 3, BlockMatcher.forBlock(Blocks.STONE));
- COPPER_ORE = new WorldGenMineable(ModBlock.COPPER_ORE, 6, BlockMatcher.forBlock(Blocks.STONE));
- LEAD_ORE = new WorldGenMineable(ModBlock.LEAD_ORE, 6, BlockMatcher.forBlock(Blocks.STONE));
- SILVER_ORE = new WorldGenMineable(ModBlock.SILVER_ORE, 6, BlockMatcher.forBlock(Blocks.STONE));
- TIN_ORE = new WorldGenMineable(ModBlock.TIN_ORE, 6, BlockMatcher.forBlock(Blocks.STONE));
- @Override
- public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider){
- switch(world.provider.getDimension()){
- case 0:
- runGenerator(RUBY_ORE, world, random, chunkX, chunkZ, 20, 0, 15);
- runGenerator(SAPPHIRE_ORE, world, random, chunkX, chunkZ, 20, 0, 15);
- runGenerator(COPPER_ORE, world, random, chunkX, chunkZ, 40, 5, 67);
- runGenerator(LEAD_ORE, world, random, chunkX, chunkZ, 40, 5, 67);
- runGenerator(SILVER_ORE, world, random, chunkX, chunkZ, 30, 5, 33);
- runGenerator(TIN_ORE, world, random, chunkX, chunkZ, 40, 5, 67);
- break;
- }
- }
- private void runGenerator(WorldGenerator gen, World world, Random rand, int chunkX, int chunkY, int chunkZ, int chance, int minHeight, int maxHeight) {
- if(minHeight > maxHeight || minHeight < 0 || maxHeight > 256) throw new IllegalArgumentException("Ore generated out of bounds");
- int heightDiff = maxHeight - minHeight + 1;
- for(int i = 0; i < chance; i++){
- int x = chunkX * 16 + rand.nextInt(16);
- int y = minHeight + rand.nextInt(heightDiff);
- int z = chunkZ * 16 + rand.nextInt(16);
- gen.generate(world, rand, new BlockPos(x,y,z));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement