Jump to content

Problem With OreGen


Emerald_Galaxy

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.

 

OreGeneration

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));
		
	}
	
	@Override
	public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
		
		switch(world.provider.getDimension()) {
		
		//The Nether
		case -1:
			
		break;
		
		//The Overworld
		case 0:
			
			runGenerator(MASONITE, world, random, chunkX, chunkZ, 1, 0, 32);
			//runGenerator(MASONITE, world, random, chunkX, chunkZ, 3, 0, 64, MasoniteMountains.class);
			
		break;
		
		//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

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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • no this one https://pastebin.com/5uMxHeWf
    • I am in such a mess. I have lost over 4.7m due to a scammer... It started as bank wires and then bitcoin. it is hard to imagine but it is true and can send any proof, then I tried to use a couple of recovery companies and was as well. Graphic design has been more than just a hobby for me since high school—it has become a thriving career. Starting in my parents' garage, I eventually expanded to my office, running a successful graphic design business. However, like many, I faced the need to diversify my investments due to inflation. This led me to invest 60.16 in Bitcoin, a decision that paid off handsomely as my investment grew to 4.7m over time. This financial windfall allowed me to upgrade my equipment and take on more ambitious projects, furthering the growth of my business. Unfortunately, my excitement was abruptly cut short when I fell victim to a hacking incident. Malware infected my computer, giving hackers access to my Bitcoin wallet. The devastation of potentially losing all my hard-earned savings and plans weighed heavily on me. At this dire moment, a fellow designer suggested Linux Cyber Security Company as a potential solution. Desperate for a lifeline, I reached out to them, hoping for a miracle. The response from Linux Cyber Security Company was prompt, incredibly professional, and effective. Their team quickly traced the hacker’s activities and recovered most of my funds, alleviating a significant amount of stress and uncertainty. Beyond the recovery, they took the time to educate me on essential practices to secure my Bitcoin holdings better. They emphasized using antivirus software to prevent malware infections, avoiding suspicious downloads, and the added security provided by hardware wallets. This experience served as a critical wake-up call for me. It highlighted the vulnerabilities inherent in digital assets and underscored the importance of robust security measures. Thanks to the guidance and expertise of Linux Cyber Security Company, I now feel more equipped to protect my digital assets proactively. Their insights have empowered me to implement stronger security protocols in my business operations and personal finances alike. With my Bitcoin funds securely recovered and a newfound understanding of digital security best practices, I am more confident in navigating future challenges. This journey has reinforced my commitment to safeguarding my hard-earned assets and leveraging technology responsibly. I am optimistic about the growth opportunities ahead, creatively in graphic design and prudently in investment strategies. In conclusion, while the hacking incident was a setback, it ultimately became a catalyst for enhancing my digital security awareness and resilience. I am grateful to Linux Cyber Security Company for their expertise and support during a challenging time, enabling me to continue pursuing my passion for graphic design with renewed confidence and financial stability. Contact a professional company I am sure they can help you with your case too, Website [www.linuxcybersecurity.com Email the team; info@)(linuxcybersecurity.com
    • https://pastebin.com/B2HnBZTa
    • it was easy villager mate, thanks ill see how to do it without that mod! thanks
  • Topics

×
×
  • Create New...

Important Information

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