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

So i have this in my CommonProxy.class :

public void init(FMLInitializationEvent event) {
    	TemRecipes.init();
    	
    	if(Loader.isModLoaded("BiomesOPlenty")){
		BOPAddonRecipes.init();
		}
    	
    	 MinecraftForge.EVENT_BUS.register(new TemChunkOverider());
    	 GameRegistry.registerWorldGenerator(new ChalkStoneGenerator(), 1);
    	 

    }

What i want to happen is replacing stone with my stone. This works!

Then i want to spawn in ores (with the chalkstonegenerator)

 

Both generators work, but the game spawns my ore first and after that it replaces all the stone with my stone.

It has to be the other way. Can i somehow let TemChunkOverider go before ChalkstoneGenerator ?

 

TemChunkOverider:

 

public class TemChunkOverider {

@SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true)
public void onEvent(PopulateChunkEvent.Pre event)
{

    // replace all blocks of a type with another block type
    // diesieben07 came up with this method (http://www.minecraftforge.net/forum/index.php/topic,21625.0.html)    
    Chunk chunk = event.world.getChunkFromChunkCoords(event.chunkX, event.chunkZ);
    Block fromBlock = Blocks.stone; // change this to suit your need
    Block toBlock = Blocks.diamond_block; // diamond_block is just for testing for now
    final ExtendedBlockStorage[] storageArray = chunk.getBlockStorageArray();

    
        
            for (int x = 0; x < 16; ++x) 
            {
                for (int z = 0; z < 16; ++z) 
                {
                	ExtendedBlockStorage storage =storageArray[0];
                	if (storage != null) 
        	        	{
                		for (int y = 0; y < 16; ++y) 
                		{
                			final Block block = storage.getBlockByExtId(x, y, z);
                			if (block == fromBlock) 
                			{
                				storage.func_150818_a(x, y, z, toBlock);
                			}
                		}
        	        }
                }
            }
       
      
    chunk.isModified = true; // this is important as it marks it to be saved
    
}

}

 

 

  • Author

Use an IWorldGenerator instead of the populate event for the stone-replacement as well.

You can use the 2nd parameter of the registerWorldGenerator method to define the ordering of the two.

 

Ok I did what you said( i think) and gave the chalkstone gen heavy weight ( 1000), but it still spawns before the other gen

 

public void init(FMLInitializationEvent event) {
    	TemRecipes.init();
    	
    	if(Loader.isModLoaded("BiomesOPlenty")){
		BOPAddonRecipes.init();
		}
    	
    	 //MinecraftForge.EVENT_BUS.register(new TemChunkOverider());
    	 GameRegistry.registerWorldGenerator(new TemChunkGenerator(), 1);
    	 GameRegistry.registerWorldGenerator(new ChalkStoneGenerator(), 1000);
    	 

    }

  • Author

The world generators with larger weights run before the generators with lower weights.

I tried that too (before posting), still the same

And You are wrong anyway the tooltip says this:

Parameters:

generator the generator

modGenerationWeight a weight to assign to this generator. Heavy weights tend to sink to the bottom of list of world generators (i.e. they run later)

 

 

EDIT:

It doesn't matter how many weight i give to both, ChalkStoneGenerator ALWAYS happen first.

I don't understand why.

 

EDIT2:

 

I made a check in my oregenerator in the chalkstonegenerator.class:

public void generateOre(Block block, World world, Random random, int meta, int chunkX, int chunkZ, int minVienSize, 
		int maxVienSize, int chance, int minY, int maxY, Block generateIn){
	int vienSize = minVienSize + random.nextInt(maxVienSize - minVienSize);
	int heightRange = maxY - minY + 1;
	WorldGenMinable gen = new WorldGenMinable(block, meta, vienSize, generateIn);
	for(int i =0; i < chance; i++){
		int xRand = chunkX * 16 + random.nextInt(16);
		int yRand = random.nextInt(heightRange) + minY;
		int zRand = chunkZ * 16 + random.nextInt(16);
		Block testblock = world.getBlock(xRand, yRand, zRand);
		if (testblock==Blocks.stone){
		gen.generate(world,  random , xRand, yRand, zRand);
		}
	}

}

So now i check for the targetblock (where the "ore" should spawn) if it is a stone block.

If so then generate the "ore".

So while this seems to "fix" it, i think it is still weird because it already checks for stone blocks with the var generateIn.

Why making another check makes it working?

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.