Posted March 21, 20178 yr So, I have set up a "digital" compass in my mod. When you shift+right click it opens a GUI which you can use to turn it on or off. It is on then I have a renderer that pops at the top of the screen "DIRECTION_FACING" (being one of the four directions). The question I have is once it is turned on, I can put it in a chest and it will stay on, however once you leave game and rejoin you have to turn it on again. Is it possible to set it up so that if it is turned on its saved "on?" I feel like maybe nbt could do it? I'm not experienced with nbt at all so any help is great! Thank you
March 21, 20178 yr I guess you could use Capabilitys Classes: 94 Lines of code: 12173 Other files: 206 Github repo: https://github.com/KokkieBeer/DeGeweldigeMod
March 21, 20178 yr Show the code for your compass item. Here is info about capabilities: https://mcforge.readthedocs.io/en/latest/datastorage/capabilities/
March 21, 20178 yr Author Just now, Jay Avery said: Show the code for your compass item. Here is info about capabilities: https://mcforge.readthedocs.io/en/latest/datastorage/capabilities/ It is spread across 4 classes, 2 gui, 1 item, 1 guihandler, want them all?
March 21, 20178 yr 3 minutes ago, minecraftbigfoot said: It is spread across 4 classes, 2 gui, 1 item, 1 guihandler, want them all? Yep!
March 21, 20178 yr Author Just now, Jay Avery said: Yep! GuiDCompass: http://pastebin.com/Tkb5YVCX / GuiDCompassDisplay: http://pastebin.com/K6V6yBAN ItemDCompass http://pastebin.com/NqaipQUe / BrandyGuiHandler: http://pastebin.com/B1t4S5u8 I know my code is messy, this is my first mod
March 21, 20178 yr So, the player activates your item and then something is added to the player's overlay display that shows their direction, even when they put the item down? (just checking I understand your aim) To make it work consistently, you will need to store the information in the player (using a capability). Otherwise, what happens if one player activates a compass and another doesn't? Currently, you're storing the state in a static field in your item class so it will apply the same thing to all players no matter what.
March 21, 20178 yr Author That is my aim, yes. Okay I will do some reading into capabilities and get back with some results! Thank you Sir.
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.