Posted October 13, 20169 yr A little question but I dont find a solution: How can I set the max Health of a Player, e.g. that the player only has 5 hearts
October 13, 20169 yr You need to apply an attribute modifier to the player. When I did this in my mod, I created a capability to manage the modifier. You can see the API here and the implementation here. Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
October 13, 20169 yr You need to apply an attribute modifier to the player. When I did this in my mod, I created a capability to manage the modifier. You can see the API here and the implementation here. Is there a more simple way of doing it? 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/
October 13, 20169 yr You need to apply an attribute modifier to the player. When I did this in my mod, I created a capability to manage the modifier. You can see the API here and the implementation here. Is there a more simple way of doing it? It depends on what your needs are. When does the player's maximum health need to change? How often does it need to change? Are there existing systems (e.g. potions, equipment) that will apply the modifier when you need it? Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
October 13, 20169 yr It depends on what your needs are. When does the player's maximum health need to change? How often does it need to change? Are there existing systems (e.g. potions, equipment) that will apply the modifier when you need it? Can you explain that a bit more? If you would want for the players health to not exceed 5 hearts for example I thought you only need to change it once when the player enters the world. 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/
October 13, 20169 yr It depends on what your needs are. When does the player's maximum health need to change? How often does it need to change? Are there existing systems (e.g. potions, equipment) that will apply the modifier when you need it? Can you explain that a bit more? If you would want for the players health to not exceed 5 hearts for example I thought you only need to change it once when the player enters the world. You could apply the modifier once when the player enters the world, but that will be a static reduction and won't account for other modifiers being added or removed. If you want to change the modifier's amount, you need to handle removing it, re-calculating the reduction, making sure the max health doesn't reach 0 and re-applying it. I chose to do this with a capability. Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
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.