Topic category: Help with Minecraft modding (Java Edition)
I made this code in order to make music play once (Like it doesn't keep playing the audio file over and over again so the audio doesn't overlap) a specific enemy gets aggravated towards the player. It does this value check for this custom variable I made that's supposed to check if the value is false, if it's false it sets it to true and then checks if the player is in survival, if they are it plays the audio. After that the audio shouldn't repeat but somehow it does? The whole code sequence shouldn't work because the custom variable value is set to true. When I say it still plays, I mean that when I kill the enemy and spawn another one, the audio file starts repeating and I can't wrap my head around why. (Also I have a piece of code that stops the music once the entity dies.) I am a beginner at this and I would really like some help!
I have found a solution to my problem and the audio will now play only one time when the entity sees you and will reset once the entity dies so the audio will play again when you encounter another one. But now it plays the audio when any entity gets aggravated toward the player. When that entity is killed the music will not stop until I kill the entity that is tied to the procedure. Or so I think the entity is.