winnetrie Posted May 5, 2016 Posted May 5, 2016 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 } } Quote Try out my new Modpack for MC 1.15.2 https://www.curseforge.com/minecraft/modpacks/terran-civilization
winnetrie Posted May 6, 2016 Author Posted May 6, 2016 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); } Quote Try out my new Modpack for MC 1.15.2 https://www.curseforge.com/minecraft/modpacks/terran-civilization
Leviathan143 Posted May 6, 2016 Posted May 6, 2016 The world generators with larger weights run before the generators with lower weights. Quote
winnetrie Posted May 6, 2016 Author Posted May 6, 2016 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? Quote Try out my new Modpack for MC 1.15.2 https://www.curseforge.com/minecraft/modpacks/terran-civilization
Recommended Posts
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.