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!

I just wanted to ask where the World Generator/The OreGenerator is located in Minecraft Forge.

 

I need to know, how the Diamond Ore is generated. On Minecraft Wiki you only can read how much Diamonds are in a Chunk, but not how they are created. I want to know all the parameters for the woeld generation: How often are how much blocks of ore generated in one chunk?

 

(sorry for nooby question)

Here's an example pulled from my mod.

 

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

public class WorldGenHandler implements IWorldGenerator {

public WorldGenerator myCustomOre;

public WorldGenHandler() {
	GameRegistry.registerWorldGenerator(this);
	myCustomOre = new WorldGenMinable(2048, 7);
	// 2048 = Block Id, 7 = Maximum number of ores per cluster
}

@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
	generateOre(random, chunkX, chunkZ, world, 8, myCustomOre, 0, 63);
	// 8 = Number of clusters it tries to generate per chunk
}

private void generateOre(Random rand, int chunkX, int chunkZ, World world, int iterations, WorldGenerator gen, int lowestY, int highestY) {
	for (int i = 0; i < iterations; i++) {
		int x = chunkX * 16;
		int y = rand.nextInt(highestY - lowestY) + lowestY;
		int z = chunkZ * 16;
		gen.generate(world, rand, x, y, z);
	}
}
}

 

And inside your mod class, make a new WorldGenHandler object.

 

@EventHandler
public void init(FMLInitializationEvent event) {
new WorldGenHandler();
}

 

Make sure to import everything correctly. (Eclipse: CTRL+SHIFT+O (Mac: SHIFT+CMD+O))

if (user.hasKnowledgeOfJava) {

    if (user.question.hasCode) {

        return interpetHelpfulResponse(user.getQuestion());

    } else {

        return "Could you post your code please?";

    }

} else {

    return "Learn some freaking Java!";

}

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.