Posted August 7, 201312 yr Anyone know how a mob can play music RIGHT when it spawns... and upon death, the music stops... So far I only have 2 boss mobs, but this is still very important to me! I am aware of the .playSoundatEntity and the onDeath... BUT I DONT EXACTLY KNOW HOW TO CONSTRUCT THE CODE!
August 7, 201312 yr So you don't know how to load the sound to the sound-pool and such? If you don't, I can help you there. With playing the sound on spawn... How is the boss mob spawned? If it is spawned via an item or such, you can play the music via the constructor of the boss mob. Yeah just play the sound via the mob's (entity's) constructor. Then you can do the LivingDeathEvent (I think its called that) and stop the song from playing... To be more clear, the only way I can think of STOPPING the music when the boss dies is to, on the construction of the boss, create a new thread that plays the music. Then, using the LivingDeathEvent afore mentioned, stop the thread, thus stopping the music. If you need help just ask I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes. I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there
August 8, 201312 yr Author I read the part you crossed out... It actually is summoned via Item... So how do I actually play the music with the item?
August 8, 201312 yr Well then You could do the same thing. But then if you didn't want to do that, you could create the thread when you summon the boss. Sam concept really. And you would still need the LivingDeathEvent thing I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes. I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there
August 10, 201312 yr And instead of using the LivingDeathEvent you could better override setDead() with the line diesieben07 posted to stop the sound. Author of PneumaticCraft, MineChess, Minesweeper Mod and Sokoban Mod. Visit www.minemaarten.com to take a look at them.
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.