Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • Get World Height?
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 1
pro-mole

Get World Height?

By pro-mole, July 22, 2013 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

pro-mole    2

pro-mole

pro-mole    2

  • Stone Miner
  • pro-mole
  • Members
  • 2
  • 84 posts
Posted July 22, 2013

So, this is one of those things I could find out with extensive testing, but it'll be hours until I get home and I'm also hoping somone else will be benefitted by this post.

 

Simple question, then: world.getHeightValue(x,z) will return what Y value, by definition? And more specifically, if I use this function in an area where there's a tree, will it get me the height of the leaves or the height of the ground under it?

  • Quote

Share this post


Link to post
Share on other sites

hydroflame    208

hydroflame

hydroflame    208

  • World Shaper
  • hydroflame
  • Members
  • 208
  • 1511 posts
Posted July 22, 2013

welll .. you could have looked at the code directly (unless you dont ahve access from where you are) but it will return the first opaque bloc (aka leaves no, wood yes)

  • Quote

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Share this post


Link to post
Share on other sites

Armeleon    1

Armeleon

Armeleon    1

  • Tree Puncher
  • Armeleon
  • Members
  • 1
  • 27 posts
Posted July 23, 2013

I agree with that guy ^^.  THe first opaque block from the top of the sky.  However, I want to add that if you gen your stuff too early, trees might not be in place yet.  I had that problem once.

  • Quote

Share this post


Link to post
Share on other sites

pro-mole    2

pro-mole

pro-mole    2

  • Stone Miner
  • pro-mole
  • Members
  • 2
  • 84 posts
Posted July 23, 2013

Yea... actually no. I'm using that function to try and find trees for my worldGen. My problem, though, is not that the gen is made too early but:

 

a) This function returns the y value of the block just above the top most for given X and Z(i.e., it's an air block)

 

and b) It does not make any distinction between solid blocks or not. I got both water and leaves on the position just below that value.

 

Thanks for the prompt reply, guys, but you might be thinking of a different version of the code(I'm working with 1.5.2).

  • Quote

Share this post


Link to post
Share on other sites

hydroflame    208

hydroflame

hydroflame    208

  • World Shaper
  • hydroflame
  • Members
  • 208
  • 1511 posts
Posted July 23, 2013

why dont you simply do a loop ?

its not gonna kill anyone

  • Quote

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Share this post


Link to post
Share on other sites

hydroflame    208

hydroflame

hydroflame    208

  • World Shaper
  • hydroflame
  • Members
  • 208
  • 1511 posts
Posted July 23, 2013

for(int i = 0; i < 256; i++){
    if(world.getBlockID(x, i, z) == 0){
        return i;
    }
}

 

and or check that the block id is part of those you want to be considered max

 

 

  • Quote

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Share this post


Link to post
Share on other sites

pro-mole    2

pro-mole

pro-mole    2

  • Stone Miner
  • pro-mole
  • Members
  • 2
  • 84 posts
Posted July 23, 2013

I am doing loops, but trying to reduce them. I already get some hiccups when generating new chunks as it is, I'd like my code to be minimally leaner.

 

Besides, I can use getHeightValue, I just need to check a few blocks down in these cases. I wanted to clarify because the documentation is vague and the code isn't much better either(it just takes this value from an array, but doesn't explain where this array is filled).

  • Quote

Share this post


Link to post
Share on other sites

hydroflame    208

hydroflame

hydroflame    208

  • World Shaper
  • hydroflame
  • Members
  • 208
  • 1511 posts
Posted July 23, 2013
but doesn't explain where this array is filled

 

well you can always follow the stack trace btw..............

  • Quote

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 1
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • poopoodice
      [1.16.4] How i can open a container by clicking on my mob

      By poopoodice · Posted 6 minutes ago

      Well, since  public Container createMenu(int id, PlayerInventory playerInventory, PlayerEntity playerEntity <--------) { return new MyModContainer(id,playerInventory, world,extraDataWriter); } you already have the player, why don't you just pass the player in? Also getEntityByID is using entityID not UUID, use ServerWorld#getEntityByUuid/getPlayerByUuid although it is not necessary because you've got the player already.  
    • MKR0902
      1.12.2 Forge Server Not starting with command arguements

      By MKR0902 · Posted 16 minutes ago

      trying to start the forge server with more memory using the command  java -Xmx1G -Xms1G -jar minecraftforge-universal-1.6.2-9.10.0.804.jar nogui but keep getting the error: launcher.lang.reflect.InvocationTargetException also happens if I use the megabyte version, so like 1024M.
    • Thorius
      I don't know how forge works

      By Thorius · Posted 16 minutes ago

      For the client you have to select the location of your minecraft installation, .minecraft
    • Thorius
      I don't know how forge works

      By Thorius · Posted 21 minutes ago

      The place where you installed the server with forge should have a folder named mods propably. Put your mods in there.
    • Mark74
      I don't know how forge works

      By Mark74 · Posted 43 minutes ago

      Hi! I started a Server with Forge, and now i want to install some mods in this server, but i don't know how to do it. In the forge installer i have the option to install client, but when i want to install it in a folder in Disk D, there is an error : "The directory is missing a launcher profile. Please run the minecraft launcher first." But i have the minecraft opened so idk what to do or how it works.
  • Topics

    • Klarks
      39
      [1.16.4] How i can open a container by clicking on my mob

      By Klarks
      Started Saturday at 09:56 PM

    • MKR0902
      0
      1.12.2 Forge Server Not starting with command arguements

      By MKR0902
      Started 16 minutes ago

    • Mark74
      2
      I don't know how forge works

      By Mark74
      Started 43 minutes ago

    • Amazinwave
      0
      Amazinwave

      By Amazinwave
      Started 43 minutes ago

    • EthanDev
      2
      Why does Forge installer 1.8.9 have Vape as an execution parent?

      By EthanDev
      Started 2 hours ago

  • Who's Online (See full list)

    • Amazinwave
    • Thorius
    • Joshthehoneskid
    • vemerion
    • CookieLukas
    • adem
    • MKR0902
    • Nuparu00
    • Beethoven92
    • FlashHUN
    • Wintersky20
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • Get World Height?
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community