Jump to content

[Solved][1.8.9] Replicating Vanilla Compass Functionality


yopu

Recommended Posts

Hey guys, after much frustration and fruitless searching I come in search of the wisdom of those who have come before me.

 

I am attempting to replicate the functionality of the vanilla compass. My compass would point to the player's last death. I already have the player spawn with the "Grave Compass" item, nbt data included for the BlockPos. I'm running into a wall when it comes to updating the texture in real time. I attempted to look at the rendering code for the vanilla compass only to realize that it is hard coded. My latest effort was to use ModelLoader.setCustomMeshDefinition however that would limit me to only the information provided in the item stack. What classes should I be looking at to enable me to update the item's texture in a similar manner to its vanilla counterpart.

 

Thanks.

Link to comment
Share on other sites

Have you looked in the TextureCompass class? (net.minecraft.client.renderer.texture.TextureCompass) It looks promising. It contains an updateCompass function which you pass in coords to where you want the compass to point to.

Did I help you? Don't be afraid to give that 'thank you' button a good smack for me!

It's been looking at me weirdly for a while now.

Link to comment
Share on other sites

That is in fact where you should look.  The method used has a whole ton of parameters you can exploit to get all kinds of information.

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.

Link to comment
Share on other sites

I have looked into TextureCompass. Implementing it would be no issue for me. What I can't seem to figure out is how to register my "TextureCompass" class. Vanilla's is hard coded in RenderItemFrame to check if the the item being rendered is the vanilla compass. Same story in TextureAtlasSprite.makeAtlasSprite()

Link to comment
Share on other sites

Update:

 

I've registered my subclass of TextureCompass during preinit on the client side via the TextureStitchEvent.Pre event.

I'm using the TextureMap.setTextureEntry() function and the resource location of my texture.

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.