Jump to content

Recommended Posts

Posted (edited)

I was using this method I found on the Internet yet it still doesn't work

 

public void generateNestUnderground(World world, Random random, int chunkX, int chunkZ, Random rand) {        
        int x = chunkX * 16 + random.nextInt(16);
        int z = chunkZ * 16 + random.nextInt(16);
        int xy = x >> 4;
        int zy = z >> 4;
        int height = world.getChunkFromChunkCoords(xy, zy).getHeight(new BlockPos(x & 15, 0, z & 15));
        int y = height - 1;
        
            if(world.getBiomeForCoordsBody(new BlockPos(x,y,z)).getBiomeClass().equals(BiomePlains.class)) {
                
                if((random.nextInt(120) + 1) <= 1) {
                    boolean place = true;
        
                    for(int Y = 0; Y < 30; Y++) {
                        for(int Z = 0; Z < 9; Z++) {
                            for(int X = 0; X < 11; X++) {
                                if(world.getBlockState(new BlockPos(X + x, Y + y + 1, Z + z)).getBlock() != Blocks.AIR) {
                                    place = false;
                                }
                            }
                        }
                    }
                    
                    if(place) {
                        dragonNest.generate(world, random, new BlockPos(x,y,z));
                }
            }
        }
    }

All throughout the web I had been asking yet I always get the answer "you use ChunkProviderOverWorld" my question is how?           

Edited by TheRPGAdventurer
  • Replies 57
  • Created
  • Last Reply

Top Posters In This Topic

Posted
19 minutes ago, TheRPGAdventurer said:

generateNestUnderground

This does not generate underground due to these lines.

20 minutes ago, TheRPGAdventurer said:

 int height = world.getChunkFromChunkCoords(xy, zy).getHeight(new BlockPos(x & 15, 0, z & 15));
        int y = height - 1;

20 minutes ago, TheRPGAdventurer said:

dragonNest.generate(world, random, new BlockPos(x,y,z));

 

20 minutes ago, TheRPGAdventurer said:

if((random.nextInt(120) + 1) <= 1) {

This line makes the chance of it spawning 1 in 120.

21 minutes ago, TheRPGAdventurer said:

if(world.getBlockState(new BlockPos(X + x, Y + y + 1, Z + z)).getBlock() != Blocks.AIR) {

This line makes the chance harder if it was underground, but since it is above ground this works.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
Just now, Animefan8888 said:

This does not generate underground due to these lines.

 

This line makes the chance of it spawning 1 in 120.

This line makes the chance harder if it was underground, but since it is above ground this works.

got any examples, tutorials or exactly tell me how to do it?

Posted

Basically everything is correct if you want it to generate above ground. And as rare as I said. With the variable "height" you get the height of the chunk, or the average height. To put it simply it is typically above ground. To make it generate underground subtract some from the "height" variable.

 

You might also want to remove the 

33 minutes ago, TheRPGAdventurer said:

                    for(int Y = 0; Y < 30; Y++) {
                        for(int Z = 0; Z < 9; Z++) {
                            for(int X = 0; X < 11; X++) {
                                if(world.getBlockState(new BlockPos(X + x, Y + y + 1, Z + z)).getBlock() != Blocks.AIR) {
                                    place = false;
                                }
                            }
                        }
                    }

Because this serves only to make sure the Block is air and underground that is not very likely to happen.

 

The 1 in 120 chance is not that bad, but it does make it hard to debug and make sure that it is generating so i suggest lowering it to something like 1 in 25 while testing.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
Just now, Animefan8888 said:

Basically everything is correct if you want it to generate above ground. And as rare as I said. With the variable "height" you get the height of the chunk, or the average height. To put it simply it is typically above ground. To make it generate underground subtract some from the "height" variable.

 

You might also want to remove the 

Because this serves only to make sure the Block is air and underground that is not very likely to happen.

 

The 1 in 120 chance is not that bad, but it does make it hard to debug and make sure that it is generating so i suggest lowering it to something like 1 in 25 while testing.

how about 1 and 15? or 1 and 10? My idea is to lower it to see if it does spawn.

Posted
1 minute ago, Animefan8888 said:

That will significantly increase your chances. I already tested it myself and unless dragonNest.generate doesn't work it should generate for you.

I really need an answer, I am not killing you to get one tho, but last time I posted the same problem, it got 4000 views so a lot of people other than me seriously needs an answer and I don't really fully know this game, I mean I know how a game works like you need a model an AI to program a living creature in a game but my problem is I don't know how it works in code.

Posted
1 minute ago, TheRPGAdventurer said:

I really need an answer, I am not killing you to get one tho, but last time I posted the same problem, it got 4000 views so a lot of people other than me seriously needs an answer and I don't really fully know this game, I mean I know how a game works like you need a model an AI to program a living creature in a game but my problem is I don't know how it works in code.

When I said 

7 minutes ago, Animefan8888 said:

That will significantly increase your chances.

I didn't mean that it would increase your chances of it working, but that it would increase the chance of you finding it.

Also where are you calling this method from? Because it needs to be called from an IWorldGenerator and that IWorldGenerator needs to be registered via GameRegistry.registerWorldGenerator

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
Just now, Animefan8888 said:

When I said 

I didn't mean that it would increase your chances of it working, but that it would increase the chance of you finding it.

Also where are you calling this method from? Because it needs to be called from an IWorldGenerator and that IWorldGenerator needs to be registered via GameRegistry.registerWorldGenerator

I know! I understand the first sentence because it was explained in the tutorial! I am calling this in an IWorldGenerator, and registered it but the tutorial just explains spawning it above ground and I can't find one that spawns below ground.

Posted (edited)
2 minutes ago, TheRPGAdventurer said:

spawns below ground.

Simple it is a matter of changing the y variable.

19 minutes ago, Animefan8888 said:

To make it generate underground subtract some from the "height" variable.

...before you create the y variable.

Edited by Animefan8888

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
Just now, Animefan8888 said:

Post your new code, the whole class if it doesn't work.

I haven't tested it yet, because it's midnight in my country, and I can't even assure if i can do it tommorow because it's saturday and I'm banned using it on sunday to thursday because when it is sunday, it is monday tommorow! and I can't wake up early, I know necro posts are banned but can you give me a permission to allow it?

Posted

It is your topic/thread and the problem hasn't been confirmed solved, I know I won't have a problem after a week and a couple days. And if you feel uncomfortable doing it you can always make a new topic/thread.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
Just now, Animefan8888 said:

It is your topic/thread and the problem hasn't been confirmed solved, I know I won't have a problem after a week and a couple days. And if you feel uncomfortable doing it you can always make a new topic/thread.

k gonna tag you!

Posted
1 hour ago, Animefan8888 said:

It is your topic/thread and the problem hasn't been confirmed solved, I know I won't have a problem after a week and a couple days. And if you feel uncomfortable doing it you can always make a new topic/thread.

Ok it does spawn above ground, 

2017-06-09_10.46.22.png

Posted
Just now, TheRPGAdventurer said:

like 

int y = height - 78;  // it used to be -1.

Yes, now it will spawn 78 blocks below the top of the ground, which could be negative, which is out of bounds so you will want to check for that.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
Just now, Animefan8888 said:

Yes, now it will spawn 78 blocks below the top of the ground, which could be negative, which is out of bounds so you will want to check for that.

so it only spawns only and exactly -78 right? How do I make it like 65 to 78?

Posted
Just now, TheRPGAdventurer said:

so it only spawns only and exactly -78 right? How do I make it like 65 to 78?

Random#nextInt(78 - 65) + 65 Will give you a random number between 65 and 78.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

Note that 65 is "above ground" for most biomes.

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.

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.

Announcements




×
×
  • Create New...

Important Information

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