Jump to content

Play sound while holding an item.


TKFRvision

Recommended Posts

Hey, I have a question. How do I play a sound while holding an item?

Right now it works kinda but its a very shitty system and its performance properly sucks. I made a class based on MovingSound. It gets triggered by the ontickupdate event. To prevent the triggering of the sound twice I use the NBTCompound in which my MovingSound class writes a value into when its done playing. This value has to get checked on every tick. That sucks. Also it just breaks when I open my inventory.

If you have a better idea please tell me.

Thanks.

Edited by TKFRvision
Link to comment
Share on other sites

I see what you mean but I cant implement it like that (setting the volume to 0 when its not in hand) because idk when to create the instance of movingsound. In the minecart the entityspawn event is used. For items there is no such thing (or is there?)

Edited by TKFRvision
Link to comment
Share on other sites

Well that brings us back to the original problem...do I really have to read the nbt of every of this item every tick to check that the sound is not playing already? Because thats like a lot...Maybe there is a different system for checking that?

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.