I have an item in my mod called the Endowing Rod. It is similar to Botania's divining rod. I want to make it show some on screen text when holding the item, but I don't know how.
I need player's energy to be a variable that is for each player, so they all can have an individual energy value.
I'm guessing the on-screen text needs to be in the loop of the game's logic so the energy value can be updated when it goes up or down.
Thanks in advance!
Just wondering, how does someone learn everything they need to know about forge to make a mod like Botania. I looked at botania's github and I don't understand much of it. Most tutorials don't go into detail for the exact stuff I'm looking to add to my mod.
The way I do it is by subscribing to the RenderGameOverlayEvent. Since this is only called client side, you can safely use Minecraft.getMinecraft() to access any client side information (like the player). You can then check the player is holding the desired item, and get whatever information you need.
About data tied to each player, I suggest you use Capabilities (have a search for it). I've not played with it much yet, but you can attach capabilities to players to store whatever data you want. You could then retrieve it in your overlay rendering to show the data on the screen.
The way I do it is by subscribing to the RenderGameOverlayEvent. Since this is only called client side, you can safely use Minecraft.getMinecraft() to access any client side information (like the player). You can then check the player is holding the desired item, and get whatever information you need.
About data tied to each player, I suggest you use Capabilities (have a search for it). I've not played with it much yet, but you can attach capabilities to players to store whatever data you want. You could then retrieve it in your overlay rendering to show the data on the screen.
Thanks for the help so far, but what class should I put the first part in?
Well all you're doing is subscribing to an event. This is just a method with the event as the only parameter and has the annotation SubscribeEvent over the method. The class then needs to be registered to the relevant event bus. If you've never used it before, I strongly advise you lookup a tutorial about them.
Hello.
I have an item in my mod called the Endowing Rod. It is similar to Botania's divining rod. I want to make it show some on screen text when holding the item, but I don't know how.
Ex.
if holding item
showtextonscreen(Network Energy: + player's energy)
if not holding item
hidetext
I need player's energy to be a variable that is for each player, so they all can have an individual energy value.
I'm guessing the on-screen text needs to be in the loop of the game's logic so the energy value can be updated when it goes up or down.
Thanks in advance!
Just wondering, how does someone learn everything they need to know about forge to make a mod like Botania. I looked at botania's github and I don't understand much of it. Most tutorials don't go into detail for the exact stuff I'm looking to add to my mod.
I have no clue what I'm doing.
The way I do it is by subscribing to the RenderGameOverlayEvent. Since this is only called client side, you can safely use Minecraft.getMinecraft() to access any client side information (like the player). You can then check the player is holding the desired item, and get whatever information you need.
About data tied to each player, I suggest you use Capabilities (have a search for it). I've not played with it much yet, but you can attach capabilities to players to store whatever data you want. You could then retrieve it in your overlay rendering to show the data on the screen.
Thanks for the help so far, but what class should I put the first part in?
I have no clue what I'm doing.
Well all you're doing is subscribing to an event. This is just a method with the event as the only parameter and has the annotation SubscribeEvent over the method. The class then needs to be registered to the relevant event bus. If you've never used it before, I strongly advise you lookup a tutorial about them.