Jump to content

[1.12.2]What is wrong with my worldgen?


_Cruelar_

Recommended Posts

Could some body tell me why this

Quote

[11:51:38] [Server thread/WARN] [FML]: Cruelars Triforcemod loaded a new chunk [-40, -49] in dimension 0 (overworld) while populating chunk [-39, -48], causing cascading worldgen lag.
[11:51:38] [Server thread/WARN] [FML]: Please report this to the mod's issue tracker. This log can be disabled in the Forge config.

happens and how to fix it.

My generation code

public class WorldGen implements IWorldGenerator {
    @Override
    public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
        if (world.provider.getDimension()==0){
            generateOverworld(random, chunkX, chunkZ, world, chunkGenerator, chunkProvider);
        }
    }

    private void generateOverworld(Random random, int chunkX,int chunkZ, World world,IChunkGenerator chunkGenerator,IChunkProvider chunkProvider){
        generateHyruleHerb(world, random, new BlockPos(chunkX * 16 - 8, 128, chunkZ * 16 - 8));
        generateOreDepositOverGround(world,random,new BlockPos(chunkX * 16 - 8, 128, chunkZ * 16 - 8));
        for (int i=1 ;i*16<=64;i++){
            generateOreDepositUnderGround( world,random,new BlockPos(chunkX * 16-8, i*16-8, chunkZ * 16-8));
        }
    }

    public boolean generateHyruleHerb(World worldIn, Random rand, BlockPos position) {
        for (IBlockState iblockstate = worldIn.getBlockState(position); (iblockstate.getBlock().isAir(iblockstate, worldIn, position) || iblockstate.getBlock().isLeaves(iblockstate, worldIn, position)) && position.getY() > 0; iblockstate = worldIn.getBlockState(position))
        {
            position = position.down();
        }
        for (int i = 0; i < 4; ++i)
        {
            BlockPos blockpos = position.add(rand.nextInt(8) - rand.nextInt(8), rand.nextInt(4) - rand.nextInt(4), rand.nextInt(8) - rand.nextInt(8));

            if (worldIn.isAirBlock(blockpos) && Blocks.TALLGRASS.canBlockStay(worldIn, blockpos, ModBlocks.hyrule_herb_block.getDefaultState()))
            {
                worldIn.setBlockState(blockpos, ModBlocks.hyrule_herb_block.getDefaultState(), 2);
            }
        }
        return true;
    }

    public boolean generateOreDepositOverGround(World worldIn, Random rand, BlockPos position) {
        for (IBlockState iblockstate = worldIn.getBlockState(position); (iblockstate.getBlock().isAir(iblockstate, worldIn, position) || iblockstate.getBlock().isLeaves(iblockstate, worldIn, position)) && position.getY() > 0; iblockstate = worldIn.getBlockState(position))
        {
            position = position.down();
        }
        if (worldIn.getBiome(position)== Biomes.EXTREME_HILLS||worldIn.getBiome(position)== Biomes.EXTREME_HILLS_EDGE||worldIn.getBiome(position)== Biomes.EXTREME_HILLS_WITH_TREES||worldIn.getBiome(position)== Biomes.MESA||worldIn.getBiome(position)== Biomes.MESA_CLEAR_ROCK){
            for (int i = 0; i < 4; ++i)
            {
                BlockPos blockpos = position.add(rand.nextInt(8) - rand.nextInt(8), rand.nextInt(4) - rand.nextInt(4), rand.nextInt(8) - rand.nextInt(8));

                if (worldIn.isAirBlock(blockpos) && (Blocks.TALLGRASS.canBlockStay(worldIn, blockpos, ModBlocks.hyrule_herb_block.getDefaultState())||Blocks.DEADBUSH.canBlockStay(worldIn, blockpos, Blocks.DEADBUSH.getDefaultState() )))
                {
                    worldIn.setBlockState(blockpos.down(), ModBlocks.ore_deposit.getDefaultState(), 2);
                    if (rand.nextFloat()>0.8){
                        worldIn.setBlockState(blockpos,ModBlocks.rare_ore_deposit.getDefaultState(),2);
                    }else{
                        worldIn.setBlockState(blockpos,ModBlocks.ore_deposit.getDefaultState(),2);
                    }
                }
            }
        }else
        for (int i = 0; i < 1; ++i)
        {
            BlockPos blockpos = position.add(rand.nextInt(8) - rand.nextInt(8), rand.nextInt(4) - rand.nextInt(4), rand.nextInt(8) - rand.nextInt(8));

            if (worldIn.isAirBlock(blockpos)&&(Blocks.TALLGRASS.canBlockStay(worldIn, blockpos, ModBlocks.hyrule_herb_block.getDefaultState())||Blocks.DEADBUSH.canBlockStay(worldIn, blockpos, Blocks.DEADBUSH.getDefaultState() )))
            {
                if (rand.nextFloat()>0.75) {
                    worldIn.setBlockState(blockpos, ModBlocks.ore_deposit.getDefaultState(), 2);
                    if (rand.nextFloat() > 0.9) {
                        worldIn.setBlockState(blockpos.up(), ModBlocks.rare_ore_deposit.getDefaultState(), 2);
                    } else {
                        worldIn.setBlockState(blockpos.up(), ModBlocks.ore_deposit.getDefaultState(), 2);
                    }
                }
            }
        }
        return true;
    }

    public boolean generateOreDepositUnderGround(World worldIn, Random rand, BlockPos position) {
        for (IBlockState iblockstate = worldIn.getBlockState(position); (iblockstate.getBlock().isAir(iblockstate, worldIn, position)  && position.getY() > 0); iblockstate = worldIn.getBlockState(position))
        {
            position = position.down();
        }
        double deepmultiplicator=1;
        if (position.getY()<=48) {
            deepmultiplicator = 1.5;
        }
        if (position.getY()<=32) {
            deepmultiplicator = 2;
        }
        if (position.getY()<=16) {
            deepmultiplicator = 3;
        }
        if (worldIn.getBiome(position)== Biomes.EXTREME_HILLS||worldIn.getBiome(position)== Biomes.EXTREME_HILLS_EDGE||worldIn.getBiome(position)== Biomes.EXTREME_HILLS_WITH_TREES||worldIn.getBiome(position)== Biomes.MESA||worldIn.getBiome(position)== Biomes.MESA_CLEAR_ROCK){
            for (double i = 0; i < 8*deepmultiplicator; ++i)
            {
                BlockPos blockpos = position.add(rand.nextInt(8) - rand.nextInt(8), rand.nextInt(4) - rand.nextInt(4), rand.nextInt(8) - rand.nextInt(8));

                if (worldIn.getBlockState(blockpos).getBlock()==Block.getBlockFromName("minecraft:stone"))
                {
                    if (rand.nextFloat()>0.8){
                        worldIn.setBlockState(blockpos,ModBlocks.rare_ore_deposit.getDefaultState(),2);
                    }else{
                        worldIn.setBlockState(blockpos,ModBlocks.ore_deposit.getDefaultState(),2);
                    }
                }
            }
        }else
            for (double i = 0; i < 2*deepmultiplicator; ++i)
            {
                BlockPos blockpos = position.add(rand.nextInt(8) - rand.nextInt(8), rand.nextInt(4) - rand.nextInt(4), rand.nextInt(8) - rand.nextInt(8));

                if (worldIn.getBlockState(blockpos).getBlock()==Block.getBlockFromName("minecraft:stone"))
                {
                    if (rand.nextFloat()>0.9){
                        worldIn.setBlockState(blockpos,ModBlocks.rare_ore_deposit.getDefaultState(),2);
                    }else{
                        worldIn.setBlockState(blockpos,ModBlocks.ore_deposit.getDefaultState(),2);
                    }
                }
            }
        return true;
    }

They are all causing this and make creating a new World lasting an extreme long time. What I found out so far is that the Underground Oredeposit generation causes less Worldgen lags than the others.

Using them all brings me over 500 cacading world gen lags during world creation, not counted what he loads after spawn.

Any help would be appreciated.

My Projects:

Cruelars Triforcemod (1.12 release; 1.14 alpha soon coming)

 

Important:

As my mod is on at least 10 different third party sites without my permission, I want to warn you about that with a link to StopModReposts

Link to comment
Share on other sites

short version - act as if the coordinates (where you are deciding whether to generate things and where you will generate things) are offset by +8, +8. i.e. do offset them by +8,+8 both when checking the terrain and when generating your stuff.

 

the thing is - if you overflow to the east or south, you're okay. no problem. but if you overflow towards north or west, more chunks need to be created (which will among others call your terrain generators again, likely causing more chunks to be generated...).

 

 

  • Thanks 1
Link to comment
Share on other sites

Heres an in-depth explanation from Mezz

  • Thanks 1

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

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
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.



×
×
  • Create New...

Important Information

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