Jump to content

Problem With OreGen


Recommended Posts

So I recently made a new oreGen for my ore and when I ran it the first time, it worked. But now after I've tryed adding a biome checker so I can set its biome, it wont work anymore, and it still won't work even after I disabled the extra parts I added, can someone help me figure out whats wrong.



package emerald.masonsores.World;

import java.util.ArrayList;
import java.util.Random;

import emerald.masonsores.Init.ModBlocks;
import emerald.masonsores.World.Biomes.MasoniteMountains;
import net.minecraft.block.state.pattern.BlockMatcher;
import net.minecraft.init.Blocks;
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.WorldGenMinable;
import net.minecraft.world.gen.feature.WorldGenerator;
import net.minecraftforge.fml.common.IWorldGenerator;
import scala.actors.threadpool.Arrays;

public class CustomOreGenerator implements IWorldGenerator {
	private WorldGenerator MASONITE;
	//private WorldGenerator MASONITE_BIOME;
	public CustomOreGenerator() {
		MASONITE = new WorldGenMinable(ModBlocks.MASONITE_ORE.getDefaultState(), 1, BlockMatcher.forBlock(Blocks.STONE));
		//MASONITE_BIOME = new WorldGenMinable(ModBlocks.MASONITE_ORE.getDefaultState(), 8, BlockMatcher.forBlock(Blocks.STONE));
	public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
		switch(world.provider.getDimension()) {
		//The Nether
		case -1:
		//The Overworld
		case 0:
			runGenerator(MASONITE, world, random, chunkX, chunkZ, 1, 0, 32);
			//runGenerator(MASONITE, world, random, chunkX, chunkZ, 3, 0, 64, MasoniteMountains.class);
		//The End
		case 1:
	private void runGenerator(WorldGenerator gen, World world, Random rand, int chunkX, int chunkZ, int chance, int minHeight, int maxHeight) {
		if(minHeight > maxHeight || minHeight < 0 || maxHeight > 256) throw new IllegalArgumentException("An Error Occurred While Generating Ores: Ore Spawned Out Of Bounds!");
		int heightDiff = maxHeight - minHeight + 1;
		//ArrayList<Class<?>> classesList = new ArrayList<Class<?>>(Arrays.asList(classes));
		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);
			BlockPos pos = new BlockPos(x, y, z);
			/*Class<?> biome = world.provider.getBiomeForCoords(pos).getClass();
			if(classesList.contains(biome) || classes.length == 0) {*/
				gen.generate(world, rand, new BlockPos(x, y, z));
				System.out.println("Ore Generated At " + x + " " + y + " " + z);



Just a side note. I made a generation checker to tell me where and if an ore generates. And the weird thing is they do, but when I teleport to the location, its just stone. 

Link to comment
Share on other sites

The problem is that your console statement doesn't prove that it generated. The WorldGenMineable still needs to decide if it should actually place the block. You might want to use debug mode in Eclipse with a breakpoint at the point where the block is actually placed to see what is going on. Alternatively, you can create your own copy of WorldGenMineable and add console statements throughout to get better sense of how it is executing.


Also, the WorldGenMineable actually has a built in Predicate for stone where it also checks the variants to ensure it was natural stone -- I guess this prevents issues with ore generating into structures.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

Where are you registering this generator? I suspect you don't and that's why it doesn't "work".

You are also doing this completely wrong. It looks like you created a sort of infinite loop in your code.


You have 2 methods here "generate" and "runGenerator".

Each of them executes the other. What's the point of it?

Like this: generate executes runGenerator wich executes generate wich executes runGenerator wich....... and so on.

Edited by winnetrie
Link to comment
Share on other sites

I feel so stupid right now. Turns out I just couldn't find my ore even though it actually was spawning, just not in every chunk like I foolishly assumed. Well, sorry for wasting everyone's time :P


But tbh, I probably would've never thought to check whether or not my genchecker was right or not if it wasn't for the first reply I got. Thank you

Edited by Emerald_Galaxy
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in

Sign In Now

  • Create New...

Important Information

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