Jump to content

Recommended Posts

  • 3 weeks later...
Posted

If you still are thinking about this, then I would suggest you store players position in variable

 

then on specifid tick you calculate the distance the player traveled since the last "readout".

 

lets say the tick is every second then this pseudo code should be right.

 

//calculate distance since last reading
diffx = player.x - prev_posx
diffy = player.y - prev_posy
diffz = player.z - prev_posz

//calculate overall distance
distance = sqrt( diffx + diffy + diffz)

//calculate speed
// speed = distance * 60 *60 /1000
speed_in_km_h = distance*3,6

// store player position for next time
prev_posx = player.x
prev_posy = player.y
prev_posz = player.z

Not all things in the world are red, there are round objects too!

Posted

Another way to get the distance (in a perhaps more cleaner way) could be like this:

Vec3 lastPosVec = new Vec3(prev_posx, prev_posy, prev_posz);
Vec3 currentPosVec = new Vec3(player.x, player.y, player.z);

// Euclidean distance between your last and current position. 
double distanceTraveled = lastPosVec.distanceTo(currentPosVec);

 

As for handling the gui, I am afraid I cannot be of any help there as I have no experience in that.

If you haven't so far, you should perhaps read this:

http://www.minecraftforge.net/wiki/Gui_Overlay

I still haven't published a mod because I can never get that in-dev version just right to warrant a public release. And yes, after two years of mod development I am still learning to speak Java.

 

Follow me on GitHub: https://github.com/yooksi

Contact me on Twitter: https://twitter.com/yooksi

Read my Minecraft blog: https://yooksidoesminecraft.blogspot.de/

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.