Jump to content
  • Home
  • Files
  • Docs
  • Merch
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
  • Player position in RenderGameOverlayEvent? [SOLVED]
1.13 Update Notes for Mod Creators
Sign in to follow this  
Followers 2
Targren

Player position in RenderGameOverlayEvent? [SOLVED]

By Targren, August 27, 2013 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

Targren    0

Targren

Targren    0

  • Tree Puncher
  • Targren
  • Members
  • 0
  • 34 posts
Posted August 27, 2013

My latest mini-mod practice project is to duplicate an old mod I saw in a let's play once, which would simply tell you on the Debug (F3) screen if you're standing in a slime chunk (I'll find this useful for my future slime-spawning mod since Rei's detection is wonky). I've sussed out how to add the text to the Debug screen, no problem. 

 

Where I'm getting caught up is getting my current position in order to do the calculations. Unlike the other events I've dealt with to date, world, position, and player don't seem to show up in the inheritance chain for RenderGameOverlayEvent. Please forgive me if I'm missing something obvious -- I've been working with a certain other language for several years that has sabotaged my brain's ability to properly map out scoping.

 

I figure that, if the answer to my question is "no", then I can "scrape" the X and Z coords out of the debug text lines and use them, but if there's a way to get posX and posZ straight, it'll be that much cleaner.

 

 

  • Quote

Share this post


Link to post
Share on other sites

shadowmage4513    43

shadowmage4513

shadowmage4513    43

  • Creeper Killer
  • shadowmage4513
  • Forge Modder
  • 43
  • 157 posts
Posted August 27, 2013

Most of those things (world, player...) are not needed to be sent in the event, as there exist only a single one for each client.  E.G each client only has a single world object, and is responsible for the position of a single player.  As such, these fields are accessible directly from the Minecraft class, in the form of  Minecraft.getMinecraft().thePlayer  and Minecraft.getMinecraft().theWorld  ..  These are a global reference can be accessed from anywhere (as long as it is client side, trying to use either on server side will crash with a ClassNotFound exception for Minecraft.class)

 

That gets you the 'controlling' client player, and the world he/she is currently residing in.  From there you can easily poll the player.posX/etc to get your positioning to calculate your chunks :)

  • Quote

Share this post


Link to post
Share on other sites

Targren    0

Targren

Targren    0

  • Tree Puncher
  • Targren
  • Members
  • 0
  • 34 posts
Posted August 27, 2013

That, my friend, is exactly what I needed. Thank you!

 

I still seem to have a glitch in my code somewhere, so I'm not done bughunting yet, but that was a big boost. Much obliged.

  • Quote

Share this post


Link to post
Share on other sites

MineMaarten    48

MineMaarten

MineMaarten    48

  • Creeper Killer
  • MineMaarten
  • Members
  • 48
  • 169 posts
Posted August 27, 2013

One of another problem you could encounter is that I don't think the data which says which chunks are slime chunks is available client sided...

  • Quote

Share this post


Link to post
Share on other sites

Targren    0

Targren

Targren    0

  • Tree Puncher
  • Targren
  • Members
  • 0
  • 34 posts
Posted August 29, 2013

One of another problem you could encounter is that I don't think the data which says which chunks are slime chunks is available client sided...

 

Yeah, I was just coming back to post something to that effect. Using Minecraft.getMinecraft().theWorld will return a "Multiplayer" world, even if loaded single player. I'm pretty sure it's the same case for loading .thePlayer.

 

What I've ended up doing was trapping WorldEvent.Load and saving the world and the seed into static values for the mod, and that worked nicely. I've now got my "Slime Chunk: Yes/No" line on the debug screen.

 

Of course, I can't stop there. Now the wild hair has expanded so that I want a line of all spawnable monsters for the given location (I saw a let's play on YT with such a mod once, but it doesn't seem to exist for 1.5.2).

 

Bouncing around the code suggests I'm looking for IChunkProvider.getPossibleCreatures() but I'm still having some trouble sussing that one out. I'm not sure if I'm using the wrong positioning or the wrong provider, but it just keeps returning EntityEnderman and that's it. It's closer than I was yesterday, though.

 

Update: Or possibly I should take a look in WorldEvent.java which seems to obligingly provide a static PotentialSpawns class... Nerp... that seems to be for adding potential spawns...

  • Quote

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 2
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • darkgreenminer
      [1.12.2] Multiple Structure Generation

      By darkgreenminer · Posted 39 minutes ago

      Someone else had that same problem of their mod only spawning the last structure added to WorldGenCustomStructures, and I remembered that the solution I found was what a commentor named Redstone Tim mentioned, that in WorldGenStructure you have to remove 'static'.  I'm happy to email my version of these two classes to you if you want to have a look.  It took me hours and hours to get them working.  I have no idea what might cause the cascading gen lag, but fixing the multiple structure problem might help.    
    • troyvs
      problems starting with modding

      By troyvs · Posted 1 hour ago

      what command did you run to set up?  
    • MightyAhmed
      Immediate Crash On Any Version Of Forge

      By MightyAhmed · Posted 2 hours ago

      ok so its been a while but it was workling fine before somehow but now minecraft still works it just freezes and lagspikes every 5 seconds please help me on this issue i cant find anything on the internet also ihave 4GB ram total in my computer and i have dedicated 2gb ram to minecraft in the JVM arguments section also i have 125 mods installed.
    • deanvangreunen
      Custom Armor Item - Help - MC/Forge 1.14.4/1.14.3

      By deanvangreunen · Posted 2 hours ago

      Hello, I'm in progress of making a Minecraft 1.14.4 Mod using Forge. Needing some help, Could you please look at the following Class File and Explain what I'm doing wrong or what I should be doing?.   The "OnArmorTick" and other ".....Tick" functions don't work.   My intent: - if water is below and near player by 1 block while the boots are on then turn the water into ice. I'm trying to implement "Frost Walking Boots"   Code: - FrostBootsItem.java <- File I need help with - My Project Repo  <- Repo, So if you want to see how my mod is setup. (includes my world saves, etc)   Dev Details: - Minecraft Version: 1.14.4 - Minecraft Snapshot: 20191020-1.14.3 - Forge Version: 1.14.4-28.1.61   Notes: - I've followed a tutorial for 1.14.4 modding by MCJty on youtube (The author of RFTools) - I'm new to minecraft modding. I have expeirenced as a software developer/engineer.   ❤️❤️❤️❤️❤️❤️❤️❤️❤️  ❤️  .Thanks in advance. ❤️  ❤️❤️❤️❤️❤️❤️❤️❤️❤️ 
    • DragonITA
      [1.14.4] How to get Minecraft Horse model/texture to make a custom unicorn?

      By DragonITA · Posted 2 hours ago

      please see the screenshoot above.
  • Topics

    • Merthew
      8
      [1.12.2] Multiple Structure Generation

      By Merthew
      Started November 7, 2018

    • coolian
      1
      problems starting with modding

      By coolian
      Started October 9

    • MightyAhmed
      83
      Immediate Crash On Any Version Of Forge

      By MightyAhmed
      Started November 10

    • deanvangreunen
      0
      Custom Armor Item - Help - MC/Forge 1.14.4/1.14.3

      By deanvangreunen
      Started 2 hours ago

    • DragonITA
      48
      [1.14.4] How to get Minecraft Horse model/texture to make a custom unicorn?

      By DragonITA
      Started December 9

  • Who's Online (See full list)

    • jan
    • LTNightshade
    • ignaciro
    • Zero
    • troyvs
    • CrackThrough
    • A-Game
    • Guy123
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • Player position in RenderGameOverlayEvent? [SOLVED]
  • Theme
  • Contact Us
  • Discord

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