Jump to content

1.12 Instead of using world#getHeight as a Y coordinate in the nether. What is a better one that adapts below the bedrock roof.


TheRPGAdventurer

Recommended Posts

Do you know something that goes with a BlockPos? I need that because when i make my dragon fly by pressing space, it needs an altitude in order to lift off. When I fly it in a place and there is a Block above like the nether, it just jumps upward  without liftoff trying to get the heighest height possible then the minecraft:block above blocks it.

/**
     * Returns the distance to the ground while the entity is flying.
     */
    public double getAltitude() {    
    	BlockPos groundPos =  world.getHeight(getPosition()); 
        return posY - groundPos.getY(); 
    }

 

Link to comment
Share on other sites

The problem is that when I liftoff and there is a block above like in the nether, it would just try to reach that height because the getHeight() method finds the highest possible solid block but then gets blocked by the blocks solidity. I changed my code btw to fit in with integers.

public double getAltitude() {
          int blockX = (int) (posX - 0.5);
          int blockZ = (int) (posZ - 0.5);
          return posY - world.getHeight(blockX, blockZ); 
     }

 

Link to comment
Share on other sites

Just now, diesieben07 said:

So you are still using getHeight, not getActualHeight.

yes, the get actual height one will make the dragon jump high until it reaches "y 256" before spreading it's wings, because of |"return nether ? 128:256; "| Got a better Y coords because Im trying to make a custom one as an alternative, any advices?

Edited by TheRPGAdventurer
wrong grammar changed "to" to before
Link to comment
Share on other sites

Ah, the Nether is tricky because the normal gaming space is all enclosed. I think the OP's problem is that a flying algorithm written for an open-sky dimension (such as the End) will try to get above the Nether's bedrock ceiling. There's not much up there except patches of mushrooms (and the occasional zombie-pigman grinder  >:D ).

 

@TheRPGAdventurer, I think you will want to write your own custom method to detect large open spaces within the nether. You'll probably also want your dragon to fly through netherrack without destroying it (the way vanilla dragons fly through endstone).

 

You have some logic to work out, but you might find hints in the projects of others who have built villages in the nether (so they also had to figure out how to detect open spaces and where there floors were). Try searching out discussions and code from those other projects both here and at github.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Link to comment
Share on other sites

Just now, jeffryfisher said:

Ah, the Nether is tricky because the normal gaming space is all enclosed. I think the OP's problem is that a flying algorithm written for an open-sky dimension (such as the End) will try to get above the Nether's bedrock ceiling. There's not much up there except patches of mushrooms (and the occasional zombie-pigman grinder  >:D ).

 

@TheRPGAdventurer, I think you will want to write your own custom method to detect large open spaces within the nether. You'll probably also want your dragon to fly through netherrack without destroying it (the way vanilla dragons fly through endstone).

 

You have some logic to work out, but you might find hints in the projects of others who have built villages in the nether (so they also had to figure out how to detect open spaces and where there floors were). Try searching out discussions and code from those other projects both here and at github.

thanks for the suggestion but my dragon cannot break blocks. ;P Also do you know mods that spawn nether villages or other structures? I don't really know all the whole minecraft nods.

Link to comment
Share on other sites

8 hours ago, TheRPGAdventurer said:

do you know mods that spawn nether villages

I only know that I have seen threads in this forum asking for help with such mods. Seek and you (or your favorite search engine) will find them, possibly linked to github repositories.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Link to comment
Share on other sites

Just now, jeffryfisher said:

I only know that I have seen threads in this forum asking for help with such mods. Seek and you (or your favorite search engine) will find them, possibly linked to github repositories.

I finally come up for an idea when looking for MO Biomes source code, what if I get the world's blockstate then detect if it is solid or not but I have trouble understanding the difference between isNormalCube() and isBlockNormalCube(), or just use isSolid()?

Link to comment
Share on other sites

If you look for solid, then you could end up under lava. I suggest "coming up for air" using isAir(). Decide what you will do when you find no adequate air pocket below 127. The algorithm for placing a nether portal might offer a clue.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Link to comment
Share on other sites

Just now, jeffryfisher said:

If you look for solid, then you could end up under lava. I suggest "coming up for air" using isAir(). Decide what you will do when you find no adequate air pocket below 127. The algorithm for placing a nether portal might offer a clue.

Class for which I will find the nether portal algorithim? Location? Thanks!

Link to comment
Share on other sites

Just now, TheRPGAdventurer said:

Class for which I will find the nether portal algorithim? Location? Thanks!

But I think I am starting to get it, what if I just detect if it is standing on a solid block. BTW, getheight just detects the heighest solid block. Because instead of finding the heighest block above just get the block this entity is standing, this.getPosition()?

Edited by TheRPGAdventurer
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.

Announcements



×
×
  • Create New...

Important Information

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