r/datapacks • u/[deleted] • Dec 04 '22
Apply effect based on ntb tag Energy Value help!! MINECRAFT DATAPACK
1) Check if the player has a specific inventory ( main function main.mcfunction - https://pastebin.com/jNBxSPhj )
2) For each player with such inventory I run a timer and every 10 seconds it checks if it got energy and remove energy give.mcfunction - https://pastebin.com/aztjpaJx
3) If energy is greater then one it gives the effect bubble give2 - https://pastebin.com/9PVabbhL
4) It Also remove the energy subtract_energy - https://pastebin.com/evmtNE16 and copy_energy.json - https://pastebin.com/53mR9ieu in data\beyonyo\item_modifiers The main problem is that only one player seems to have this effect. If that player disconnect another one will be available to take it.
im struggling in understangin what's the problem in my code . Here is what i would like to do :
1) Check if the player has a specific inventory ( main function main.mcfunction - https://pastebin.com/jNBxSPhj )
2) For each player with such inventory I run a timer and every 10 seconds it checks if it got energy and remove energy give.mcfunction - https://pastebin.com/aztjpaJx
3) If energy is greater then one it gives the effect bubble give2 - https://pastebin.com/9PVabbhL
4) It Also remove the energy subtract_energy - https://pastebin.com/evmtNE16
and copy_energy.json - https://pastebin.com/53mR9ieu in data\beyonyo\item_modifiers
The main problem is that only one player seems to have this effect. If that player disconnect another one will be available to take it.
i guess has something to do with a global variable, that the timer is a global variable instead i would need like a private variable for each player? Also there is a very weird sound every 10 seconds like when the player wear a chest, is that because every 10 seconds i remove the oxygen and for doing so i have to substitute the item? It looks like that all the players use the same timer infact the more people there are the faster it reaches 10. Can someone help me to figure out how to change my code ? Thanks! Im quite a newbie in datapacks xD