Started by
softmushroombaby
on
Topic category: Help with Minecraft modding (Java Edition)
I'm trying to make it so a custom entity dances, or plays a different animation, when a player puts on a custom disc! But the code isn't working! Apparently, the "source entity" is causing problems? i don't understand, I'm new to this and don't understand dependancies
Heres a link version in case the image broke https://imgur.com/a/peNQtJt
Edited by softmushroombaby on Sat, 04/05/2025 - 06:41
If u want them to dance if a certain song is playing I would instead set a NBT tag on the block on right click instead. Then on the blocks tick update in a radius of the block check for the mob. If the mob exists in the radius and has the tag make the entity the play the animation.( make sure u set a tag on the entry so the animation doesn’t repeat.)
also the entity wouldn’t be the event target since ur checking if player right clicks block. It would just be the block not entity.
you could use the block "for each entity at xyz with radius n, as entity iterator, do"
if: entity iterator is of type weiss = true,
then: play animation and change texture.
unless you want to use the entity on tick update procedure, to check for noteblocks with the correct disk within a certain radius.
Life saver, this worked!! You're a lifesaver!
https://imgur.com/a/XjzFdF5
What I want to do now is
also is there a way to stop the entity from moving or looking around? i kinda want them to stick strictly to their animation
1: Ur gonna need to mark the jukebox with a NBT(so u can check it across different procedures). Then on the entity tick update check in a radius if the block with the NBT exists. If not have a cancel animation to cancel the animation.
2. Use the if entity is hurt condition. If true then cancel the animation.
3. Just use the override motion block and set all to 0.
but wouldnt the animation just start again at the next entitytickupdate? maybe a custom potion effect that is applied upon damage, and prevents the animation from starting.
event: entitytickupdate
if NOT entity has potioneffect,
then if block with nbt exists
play animation
if starting the music is supposed to pacify an angered mob, that you have hit prior, the entity iterator procedure can remove the potion effect, maybe with a certain probability.
Well u will need some kind of condition to stop animation from playing continuously.
Good news!! I have a working procedure for an entity stopping when hurt!
https://imgur.com/a/8Dy4KNR
I'm still lost on what to do on how to stop an entity when you turn the music off though-- I have no clue how NBTs work!
Mmm so what u need is to use the template option top left. There is a option for 6x6x6 to check blocks in an area.
So use the trigger on tick update for the entity. Once u marked the block with the NBT tag on right click. U can use an “if” inside the 6x6x6 blocks to check for block that has the tag. If true make the entity dance.
I could make an example for u but I’m away from my computer atm.
yeah, the 6x6x6 option is the best choice (although i think its actually a 7x7x7 template). The IF should set the provided "found" variable to true or false, which is then returned to the entiy. that way, it will stop the animation automatically, if the nbt stops being found. you then only have to remove the nbt, when it stops playing. you can set the procedure that initially gives the nbt value, to remove the value, after the right amount of ticks (theres a block for that). since the procedure already gives the nbt tag, when you rightclick WITH the music disk, just make rightclicking a jukebox with anything other than the disk remove the tag.
Yes doing that should work.
To answer your question. NBTs are like locals but they are saved and don’t reset unless the entity dies or leaves the game. They are like global variables but are not permanent. Local variables don’t save and reset once the procedure ends.
HAZA! HAZA! I got it all of it down! These are the codes are used! Thank you for all your help, you two!
https://imgur.com/a/ifQhit6
👍Np