Jump to content

[1.8.9] [UNSOLVED] World generation


Bektor

Recommended Posts

UPDATE:

Ok, I got it nearly working. For testing purpose I decided to use lava. xD

 

aHKdBnx.png

 

Thats how it looks so far, but there is one problem.

Is there a way to remove the lava which is over the one block air level?

 

My current code:

    for(int x = 0; x < 16; ++x) {
        for(int z = 0; z < 16; ++z) {
            BiomeBase biomeBase = (BiomeBase)baseBiome[x * 16 + z];
            biomeBase.replaceBlocksForBiome(chunkX * 16 + x, chunkZ * 16 + z, blocks, state, baseBiome, noise);
            
            for(int y = 255; y >= 0; --y) {
                if(y <= this.random.nextInt(4)) {
                    primer.setBlockState((chunkX * 16 + x) & 15, y, (chunkZ * 16 + z) & 15, Blocks.bedrock.getDefaultState());
                    primer.setBlockState((chunkX * 16 + x) & 15, y + 1, (chunkZ * 16 + z) & 15, Blocks.lava.getDefaultState());
                    primer.setBlockState((chunkX * 16 + x) & 15, y + 2, (chunkZ * 16 + z) & 15, Blocks.lava.getDefaultState());
                    primer.setBlockState((chunkX * 16 + x) & 15, y + 3, (chunkZ * 16 + z) & 15, Blocks.lava.getDefaultState());
                    primer.setBlockState((chunkX * 16 + x) & 15, y + 4, (chunkZ * 16 + z) & 15, Blocks.lava.getDefaultState());
                    primer.setBlockState((chunkX * 16 + x) & 15, y + 5, (chunkZ * 16 + z) & 15, Blocks.lava.getDefaultState());
                    primer.setBlockState((chunkX * 16 + x) & 15, y + 6, (chunkZ * 16 + z) & 15, Blocks.air.getDefaultState());
                    
// doesn't remove all lava... not working 
                    if(primer.getBlockState((chunkX * 16 + x) & 15, y + 7, (chunkZ * 16 + z) & 15) == Blocks.lava.getDefaultState())
                        primer.setBlockState((chunkX * 16 + x) & 15, y + 7, (chunkZ * 16 + z) & 15, Blocks.air.getDefaultState());
                    else if(primer.getBlockState((chunkX * 16 + x) & 15, y + 8, (chunkZ * 16 + z) & 15) == Blocks.lava.getDefaultState())
                        primer.setBlockState((chunkX * 16 + x) & 15, y + 8, (chunkZ * 16 + z) & 15, Blocks.air.getDefaultState());
                    else if(primer.getBlockState((chunkX * 16 + x) & 15, y + 9, (chunkZ * 16 + z) & 15) == Blocks.lava.getDefaultState())
                            primer.setBlockState((chunkX * 16 + x) & 15, y + 9, (chunkZ * 16 + z) & 15, Blocks.air.getDefaultState());
                    else if(primer.getBlockState((chunkX * 16 + x) & 15, y + 10, (chunkZ * 16 + z) & 15) == Blocks.lava.getDefaultState())
                            primer.setBlockState((chunkX * 16 + x) & 15, y + 10, (chunkZ * 16 + z) & 15, Blocks.air.getDefaultState());
                    else if(primer.getBlockState((chunkX * 16 + x) & 15, y + 11, (chunkZ * 16 + z) & 15) == Blocks.lava.getDefaultState())
                            primer.setBlockState((chunkX * 16 + x) & 15, y + 11, (chunkZ * 16 + z) & 15, Blocks.air.getDefaultState());
                    else if(primer.getBlockState((chunkX * 16 + x) & 15, y + 12, (chunkZ * 16 + z) & 15) == Blocks.lava.getDefaultState())
                            primer.setBlockState((chunkX * 16 + x) & 15, y + 12, (chunkZ * 16 + z) & 15, Blocks.air.getDefaultState());
                    else if(primer.getBlockState((chunkX * 16 + x) & 15, y + 13, (chunkZ * 16 + z) & 15) == Blocks.lava.getDefaultState())
                            primer.setBlockState((chunkX * 16 + x) & 15, y + 13, (chunkZ * 16 + z) & 15, Blocks.air.getDefaultState());
                    else if(primer.getBlockState((chunkX * 16 + x) & 15, y + 14, (chunkZ * 16 + z) & 15) == Blocks.lava.getDefaultState())
                            primer.setBlockState((chunkX * 16 + x) & 15, y + 14, (chunkZ * 16 + z) & 15, Blocks.air.getDefaultState());
                }
            }
        }
    }

So everything above y + 6 should not generate the lava spots. (lava lakes are ok, but thats a future task for me)

 

Thx in advance.

Bektor

 

 

 

Hi,

 

I've got a question (which is a problem, too). So, I'm currently working on my own world generator for my

own dimension, but now I'm wondering how to generate bedrock at the bottom of the world.

 

Currently it's not generating in my world and when you dig down you just fell out of the world.

So does anyone got an idea how to genereate bedrock in a world generator cause I'm unable to find

out how Mojang does it and my own code isn't working (replaceBlockBiomes code...)

 

Thats my code which I tried:

private void replaceBlocksForBiome(int chunkX, int chunkZ, Block[] blocks, IBlockState[] state, BiomeGenBase[] baseBiome, float[] noise, ChunkPrimer primer) {
    ChunkProviderEvent.ReplaceBiomeBlocks event = new ChunkProviderEvent.ReplaceBiomeBlocks(this, chunkX, chunkZ, primer, world);
    MinecraftForge.EVENT_BUS.post(event);
    
    if(event.getResult() == Result.DENY) return;
    
    for(int x = 0; x < 16; ++x) {
        for(int z = 0; z < 16; ++z) {
            BiomeBase biomeBase = (BiomeBase)baseBiome[x * 16 + z];
            biomeBase.replaceBlocksForBiome(chunkX * 16, chunkZ * 16, blocks, state, baseBiome, noise);

            blocks[(z * 16 + x) * 256] = Blocks.bedrock;
            state[(z * 16 + x) * 256] = Blocks.bedrock.getDefaultState();
        }
    }
}

[i don't even know if that code is correct, I just now it gives me no errors]

 

For generating stuff I'm using OpenSimplexNoise and currently just generating a few layers of stone... no grass, no dirt, no hills, no caves etc.

 

Thx in advance.

Bektor

 

Developer of Primeval Forest.

Link to comment
Share on other sites

replaceBlocksForBiome is intended for replacing the top 4 blocks of stone with grass or sand (or at least, that's what Minecraft uses it for).  The bottom bedrock is handled by the chunk provider the last time I looked at it.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

replaceBlocksForBiome is intended for replacing the top 4 blocks of stone with grass or sand (or at least, that's what Minecraft uses it for).  The bottom bedrock is handled by the chunk provider the last time I looked at it.

Ah, ok. Just thought I can use it for that purpose, too, because some mods do it [MC 1.7.10]. xD

So how is the chunk provider doing this? Everytime when I search for "bedrock" in the "ChunkProviderGenerate" from Mojang I can't find it. And "replaceBlocksForBiome" is a method inside of the chunk provider. ;)

 

Developer of Primeval Forest.

Link to comment
Share on other sites

Been a while since I looked at it, TBH.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

If you look for usages of the

Blocks.bedrock

field, you'll see that it's used in

BiomeGenBase#generateBiomeTerrain

. This is called from

BiomeGenBase#genTerrainBlocks

, which is called from

ChunkProviderGenerate#replaceBlocksForBiome

.

 

Each biome generates its own terrain (including bedrock) from this method.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

If you look for usages of the

Blocks.bedrock

field, you'll see that it's used in

BiomeGenBase#generateBiomeTerrain

. This is called from

BiomeGenBase#genTerrainBlocks

, which is called from

ChunkProviderGenerate#replaceBlocksForBiome

.

 

Each biome generates its own terrain (including bedrock) from this method.

Ok, thx. Now its mostly working..... I just broke MC down to 2FPS because I wanted to generate over the bedrock something else like which is generated like the bedrock.....

 

Any idea how my code must look to generate in (java) level 256 bedrock and in (java) 255 for example dirt?

Developer of Primeval Forest.

Link to comment
Share on other sites

Ok, I got it nearly working. For testing purpose I decided to use lava. xD

 

aHKdBnx.png

 

Thats how it looks so far, but there is one problem.

Is there a way to remove the lava which is over the one block air level?

 

My current code:

    for(int x = 0; x < 16; ++x) {
        for(int z = 0; z < 16; ++z) {
            BiomeBase biomeBase = (BiomeBase)baseBiome[x * 16 + z];
            biomeBase.replaceBlocksForBiome(chunkX * 16 + x, chunkZ * 16 + z, blocks, state, baseBiome, noise);
            
            for(int y = 255; y >= 0; --y) {
                if(y <= this.random.nextInt(4)) {
                    primer.setBlockState((chunkX * 16 + x) & 15, y, (chunkZ * 16 + z) & 15, Blocks.bedrock.getDefaultState());
                    primer.setBlockState((chunkX * 16 + x) & 15, y + 1, (chunkZ * 16 + z) & 15, Blocks.lava.getDefaultState());
                    primer.setBlockState((chunkX * 16 + x) & 15, y + 2, (chunkZ * 16 + z) & 15, Blocks.lava.getDefaultState());
                    primer.setBlockState((chunkX * 16 + x) & 15, y + 3, (chunkZ * 16 + z) & 15, Blocks.lava.getDefaultState());
                    primer.setBlockState((chunkX * 16 + x) & 15, y + 4, (chunkZ * 16 + z) & 15, Blocks.lava.getDefaultState());
                    primer.setBlockState((chunkX * 16 + x) & 15, y + 5, (chunkZ * 16 + z) & 15, Blocks.lava.getDefaultState());
                    primer.setBlockState((chunkX * 16 + x) & 15, y + 6, (chunkZ * 16 + z) & 15, Blocks.air.getDefaultState());
                    
// doesn't remove all lava... not working 
                    if(primer.getBlockState((chunkX * 16 + x) & 15, y + 7, (chunkZ * 16 + z) & 15) == Blocks.lava.getDefaultState())
                        primer.setBlockState((chunkX * 16 + x) & 15, y + 7, (chunkZ * 16 + z) & 15, Blocks.air.getDefaultState());
                    else if(primer.getBlockState((chunkX * 16 + x) & 15, y + 8, (chunkZ * 16 + z) & 15) == Blocks.lava.getDefaultState())
                        primer.setBlockState((chunkX * 16 + x) & 15, y + 8, (chunkZ * 16 + z) & 15, Blocks.air.getDefaultState());
                    else if(primer.getBlockState((chunkX * 16 + x) & 15, y + 9, (chunkZ * 16 + z) & 15) == Blocks.lava.getDefaultState())
                            primer.setBlockState((chunkX * 16 + x) & 15, y + 9, (chunkZ * 16 + z) & 15, Blocks.air.getDefaultState());
                    else if(primer.getBlockState((chunkX * 16 + x) & 15, y + 10, (chunkZ * 16 + z) & 15) == Blocks.lava.getDefaultState())
                            primer.setBlockState((chunkX * 16 + x) & 15, y + 10, (chunkZ * 16 + z) & 15, Blocks.air.getDefaultState());
                    else if(primer.getBlockState((chunkX * 16 + x) & 15, y + 11, (chunkZ * 16 + z) & 15) == Blocks.lava.getDefaultState())
                            primer.setBlockState((chunkX * 16 + x) & 15, y + 11, (chunkZ * 16 + z) & 15, Blocks.air.getDefaultState());
                    else if(primer.getBlockState((chunkX * 16 + x) & 15, y + 12, (chunkZ * 16 + z) & 15) == Blocks.lava.getDefaultState())
                            primer.setBlockState((chunkX * 16 + x) & 15, y + 12, (chunkZ * 16 + z) & 15, Blocks.air.getDefaultState());
                    else if(primer.getBlockState((chunkX * 16 + x) & 15, y + 13, (chunkZ * 16 + z) & 15) == Blocks.lava.getDefaultState())
                            primer.setBlockState((chunkX * 16 + x) & 15, y + 13, (chunkZ * 16 + z) & 15, Blocks.air.getDefaultState());
                    else if(primer.getBlockState((chunkX * 16 + x) & 15, y + 14, (chunkZ * 16 + z) & 15) == Blocks.lava.getDefaultState())
                            primer.setBlockState((chunkX * 16 + x) & 15, y + 14, (chunkZ * 16 + z) & 15, Blocks.air.getDefaultState());
                }
            }
        }
    }

So everything above y + 6 should not generate the lava spots. (lava lakes are ok, but thats a future task for me)

 

Bektor

Developer of Primeval Forest.

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

    • Please share a link to your crash report on https://paste.ee, as explained in the FAQ. Dumping it directly into the thread often triggers the anti-spam and makes it hard to read due to word wrapping
    • Hi all, I'm running a 1.20.1 Minecraft Forge server with a hosting website and something seems to have gone wrong. It started as an occasional crash that has now become extremely frequent and I don't know what exactly is causing it. I already tried disabling watchdog but the server crashes anyway. Oddly it only occasionally generates a crash report after a crash occurs. Based on viewing the server console's research usage it seems that the CPU spikes astronomically high (100% usage), especially when chunks are being loaded or when a new person joins the server. I downloaded Spark to create a profile (https://spark.lucko.me/bBlWe7ou29) but I lack experience with this mod and don't understand what I'm looking at/how this should help me diagnose the issue. I am using a lot of mods so I'm guessing there is some sort of issue there or a corrupted chunk (although MCRF found no chunk errors). We actually don't experience any lag until the crash occurs, so it's some sort of sudden spike in resource usage. Based on the crash report I've already tried removing Canary and Modernfix but there was no change. Thanks for any help you can provide. Specs:  4 cores x 4200MHz AMD Ryzen 9 5950X 4GB RAM Crash report:  
    • will test that once i get home, thanks
    • I am getting this exception (I am new and just trying to create an item) Caused by: java.io.FileNotFoundException: abrasmagics:models/item/ingot_test.json at net.minecraft.client.resources.SimpleReloadableResourceManager.getResource(SimpleReloadableResourceManager.java:69) ~[SimpleReloadableResourceManager.class:?] at net.minecraft.client.renderer.block.model.ModelBakery.loadModel(ModelBakery.java:334) ~[ModelBakery.class:?] at net.minecraftforge.client.model.ModelLoader.access$1400(ModelLoader.java:115) ~[ModelLoader.class:?] at net.minecraftforge.client.model.ModelLoader$VanillaLoader.loadModel(ModelLoader.java:861) ~[ModelLoader$VanillaLoader.class:?] at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:157) ~[ModelLoaderRegistry.class:?]   However the directory is set up correctly and the file does exist   idk how to upload images so here is a treeview of the directories:   src ├───main │ ├───java │ │ └───net │ │ └───abrasmods │ │ └───abrasmagics │ │ ├───init │ │ ├───items │ │ └───utils │ │ ├───handlers │ │ ├───misc │ │ └───proxy │ └───resources │ └───assets │ └───abrasmagics │ ├───models │ │ ├───block │ │ └───item │ └───textures └───test ├───java └───resources   the file ingot_test.json is under models/item. The directory seems fine and the file does exist so anyone plz help.   i am using intellij and is coding for 1.12.2
  • Topics

×
×
  • Create New...

Important Information

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