Jump to content

How to generate multiple ores


MatazaNz

Recommended Posts

Hi guys, I'm very new to modding, both with Minecraft and Forge, and I am having difficulty working out how to get multiple ores to generate in the overworld.

Currently, I only have one class file to generate one ore in the overworld, and it works, but I don't know if I need to have multiple generation classes or if I can get all my ore to generate from one class. Could someone please point me in the right direction of what I would need to do?

This is my my working generation class:

 

 

package Syn.Tutorial;

import java.util.Random;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenMinable;
import cpw.mods.fml.common.IWorldGenerator;
import cpw.mods.fml.common.IWorldGenerator;

public class WorldGeneratorDiv 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(world, random,chunkX*16,chunkZ*16);
	}
}

private void generateSurface(World world, Random random, int BlockX, int BlockZ) {
for(int i =0; i<10;i++){
	int Xcoord = BlockX + random.nextInt(16);
	int Zcoord = BlockZ + random.nextInt(16);
	int Ycoord = random.nextInt(50);
	(new WorldGenMinable(DivineMetals.OrichOre.blockID, 4)).generate(world, random, Xcoord, Ycoord, Zcoord);
}
}
}

 

 

 

Any help is greatly appreciated :D

Link to comment
Share on other sites

You actually can generate it in your current method. I generated multiple ores in the nether like this:

 

 

package engineer.morenether.worldgen;

import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenMinable;
import cpw.mods.fml.common.IWorldGenerator;
import cpw.mods.fml.common.registry.GameRegistry;
import engineer.morenether.libs.BlockID;

public class NetherOreGen implements IWorldGenerator
{
public NetherOreGen()
{
	GameRegistry.registerWorldGenerator(this);
	// This will only work when you create this class in: @EventHandler FMLInitializationEvent
}

@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) 
{
	if(world.provider.dimensionId == -1)
	{
		int x = chunkX * 16;
		int z = chunkZ * 16;

		this.generateCoal(world, x, z, random);
		this.generateIron(world, x, z, random);
		this.generateRedstone(world, x, z, random);
		this.generateLapis(world, x, z, random);
		this.generateGold(world, x, z, random);
		this.generateDiamond(world, x, z, random);
		this.generateEmerald(world, x, z, random);
	}
}

private void generateCoal(World world, int x, int z, Random r)
{	
	for(int i = 0; i < 200; i++)
	{
		int xCoord = x + r.nextInt(16);
		int yCoord = r.nextInt(117) + 10;
		int zCoord = z + r.nextInt(16);

		WorldGenMinable gen = new WorldGenMinable(BlockID.NetherOre, 0, r.nextInt(15), Block.netherrack.blockID);
		gen.generate(world, r, xCoord, yCoord, zCoord);
	}
}

private void generateIron(World world, int x, int z, Random r)
{	
	for(int i = 0; i < 200; i++)
	{
		int xCoord = x + r.nextInt(16);
		int yCoord = r.nextInt(117) + 10;
		int zCoord = z + r.nextInt(16);

		WorldGenMinable gen = new WorldGenMinable(BlockID.NetherOre, 1, r.nextInt(15), Block.netherrack.blockID);
		gen.generate(world, r, xCoord, yCoord, zCoord);
	}
}

private void generateRedstone(World world, int x, int z, Random r)
{	
	for(int i = 0; i < 240; i++)
	{
		int xCoord = x + r.nextInt(16);
		int yCoord = r.nextInt(117) + 10;
		int zCoord = z + r.nextInt(16);

		WorldGenMinable gen = new WorldGenMinable(BlockID.NetherOre, 2, r.nextInt(, Block.netherrack.blockID);
		gen.generate(world, r, xCoord, yCoord, zCoord);
	}
}

private void generateLapis(World world, int x, int z, Random r)
{	
	for(int i = 0; i < 240; i++)
	{
		int xCoord = x + r.nextInt(16);
		int yCoord = r.nextInt(117) + 10;
		int zCoord = z + r.nextInt(16);

		WorldGenMinable gen = new WorldGenMinable(BlockID.NetherOre, 3, r.nextInt(, Block.netherrack.blockID);
		gen.generate(world, r, xCoord, yCoord, zCoord);
	}
}

private void generateGold(World world, int x, int z, Random r)
{	
	for(int i = 0; i < r.nextInt(140); i++)
	{
		int xCoord = x + r.nextInt(16);
		int yCoord = r.nextInt(117) + 10;
		int zCoord = z + r.nextInt(16);

		WorldGenMinable gen = new WorldGenMinable(BlockID.NetherOre, 4, r.nextInt(11), Block.netherrack.blockID);
		gen.generate(world, r, xCoord, yCoord, zCoord);
	}
}

private void generateDiamond(World world, int x, int z, Random r)
{
	for(int i = 0; i < r.nextInt(60); i++)
	{
		int xCoord = x + r.nextInt(16);
		int yCoord = r.nextInt(117) + 10;
		int zCoord = z + r.nextInt(16);

		WorldGenMinable gen = new WorldGenMinable(BlockID.NetherOre, 5, r.nextInt(7), Block.netherrack.blockID);
		gen.generate(world, r, xCoord, yCoord, zCoord);
	}
}

private void generateEmerald(World world, int x, int z, Random r)
{	
	for(int i = 0; i < r.nextInt(125); i++)
	{
		int xCoord = x + r.nextInt(16);
		int yCoord = r.nextInt(117) + 10;
		int zCoord = z + r.nextInt(16);

		WorldGenMinable gen = new WorldGenMinable(BlockID.NetherOre, 1, r.nextInt(5), Block.netherrack.blockID);
		gen.generate(world, r, xCoord, yCoord, zCoord);
	}
}
}

 

 

I am fairly new to Java and modding, so my answers are not always 100% correct. Sorry for that!

Link to comment
Share on other sites

You actually can generate it in your current method. I generated multiple ores in the nether like this:

 

 

package engineer.morenether.worldgen;

import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenMinable;
import cpw.mods.fml.common.IWorldGenerator;
import cpw.mods.fml.common.registry.GameRegistry;
import engineer.morenether.libs.BlockID;

public class NetherOreGen implements IWorldGenerator
{
public NetherOreGen()
{
	GameRegistry.registerWorldGenerator(this);
	// This will only work when you create this class in: @EventHandler FMLInitializationEvent
}

@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) 
{
	if(world.provider.dimensionId == -1)
	{
		int x = chunkX * 16;
		int z = chunkZ * 16;

		this.generateCoal(world, x, z, random);
		this.generateIron(world, x, z, random);
		this.generateRedstone(world, x, z, random);
		this.generateLapis(world, x, z, random);
		this.generateGold(world, x, z, random);
		this.generateDiamond(world, x, z, random);
		this.generateEmerald(world, x, z, random);
	}
}

private void generateCoal(World world, int x, int z, Random r)
{	
	for(int i = 0; i < 200; i++)
	{
		int xCoord = x + r.nextInt(16);
		int yCoord = r.nextInt(117) + 10;
		int zCoord = z + r.nextInt(16);

		WorldGenMinable gen = new WorldGenMinable(BlockID.NetherOre, 0, r.nextInt(15), Block.netherrack.blockID);
		gen.generate(world, r, xCoord, yCoord, zCoord);
	}
}

private void generateIron(World world, int x, int z, Random r)
{	
	for(int i = 0; i < 200; i++)
	{
		int xCoord = x + r.nextInt(16);
		int yCoord = r.nextInt(117) + 10;
		int zCoord = z + r.nextInt(16);

		WorldGenMinable gen = new WorldGenMinable(BlockID.NetherOre, 1, r.nextInt(15), Block.netherrack.blockID);
		gen.generate(world, r, xCoord, yCoord, zCoord);
	}
}

private void generateRedstone(World world, int x, int z, Random r)
{	
	for(int i = 0; i < 240; i++)
	{
		int xCoord = x + r.nextInt(16);
		int yCoord = r.nextInt(117) + 10;
		int zCoord = z + r.nextInt(16);

		WorldGenMinable gen = new WorldGenMinable(BlockID.NetherOre, 2, r.nextInt(, Block.netherrack.blockID);
		gen.generate(world, r, xCoord, yCoord, zCoord);
	}
}

private void generateLapis(World world, int x, int z, Random r)
{	
	for(int i = 0; i < 240; i++)
	{
		int xCoord = x + r.nextInt(16);
		int yCoord = r.nextInt(117) + 10;
		int zCoord = z + r.nextInt(16);

		WorldGenMinable gen = new WorldGenMinable(BlockID.NetherOre, 3, r.nextInt(, Block.netherrack.blockID);
		gen.generate(world, r, xCoord, yCoord, zCoord);
	}
}

private void generateGold(World world, int x, int z, Random r)
{	
	for(int i = 0; i < r.nextInt(140); i++)
	{
		int xCoord = x + r.nextInt(16);
		int yCoord = r.nextInt(117) + 10;
		int zCoord = z + r.nextInt(16);

		WorldGenMinable gen = new WorldGenMinable(BlockID.NetherOre, 4, r.nextInt(11), Block.netherrack.blockID);
		gen.generate(world, r, xCoord, yCoord, zCoord);
	}
}

private void generateDiamond(World world, int x, int z, Random r)
{
	for(int i = 0; i < r.nextInt(60); i++)
	{
		int xCoord = x + r.nextInt(16);
		int yCoord = r.nextInt(117) + 10;
		int zCoord = z + r.nextInt(16);

		WorldGenMinable gen = new WorldGenMinable(BlockID.NetherOre, 5, r.nextInt(7), Block.netherrack.blockID);
		gen.generate(world, r, xCoord, yCoord, zCoord);
	}
}

private void generateEmerald(World world, int x, int z, Random r)
{	
	for(int i = 0; i < r.nextInt(125); i++)
	{
		int xCoord = x + r.nextInt(16);
		int yCoord = r.nextInt(117) + 10;
		int zCoord = z + r.nextInt(16);

		WorldGenMinable gen = new WorldGenMinable(BlockID.NetherOre, 1, r.nextInt(5), Block.netherrack.blockID);
		gen.generate(world, r, xCoord, yCoord, zCoord);
	}
}
}

 

 

 

Thanks for the reply! :D I'll give that a try

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.