Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

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!

  • Author

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

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.