Jump to content

[1.7.2] sound bug with tick event with demostration video


Recommended Posts

the video explains it better then the text



ok the video explains the issue but to go over it briefly in text:


the goal: when you hold an electric bunny you get a sound that plays just once untill you hold something else and then rehold the bunny at which point it plays a different sound again just once


How is this ment to happen : well we check to see if the player has an item in thier hands, if they do we see what it is.. now if it is an electric bunny AND if the config allows the bunnys to cry AND our soundtoggler is set to false (which it starts off as) then we play a random sound then set the toggler to true to prevent it going on repeat. once another item is chosen (anything thats not an electric bunny) we set the sound toggle to false so another sound can be played


What happens : when the player switches to electric bunny we see it is an electric bunny, the config is true and soundtoggle is false but it skips the playing of the sound and sets the soundtoggle to true, soon as we choose an item thats not an electric bunny it plays the sound, it then wont play it again untill we choose the electric bunny and again deselect it.


Conclusion, it seems like its putting the sound in a buffer and not playing it until after sound is false again. i thought it was my soundhandler but other sounds play perfectly fine, despite using the same handler!


the event handler in question https://github.com/mrgreaper/TwistedMod2/blob/master/src/main/java/com/mrgreaper/twisted/handlers/EventHookHandler.java (this will show the revised but still not working code)


the sound handler






Changed the code under the advice of spacemaniac on irc, much neater code...same bug


im thinking its a bug with forge perhaps




as you can see the debug text that should be fired once when the bunny is selected and the sound is played fires twice when the object is selected but no sound and once when the item is no longer selected but the sound then plays....thats not how the code should work logicly!





Link to comment
Share on other sites

Sorry to make a little Offtopic but I am working on my own mod which uses sounds and hasn't been tested on MP yet, so:

"Another flaw with your system is, that it will not work in multiplayer, because you only have one sound toggle."

Do you mean that if I create @ForgeSubscribe to an (example) PlayerInteractEvent in which I will call: world.playSoundAtEntity(player, "mod:sound", 1.0F, 1.0F); when player right-clicks some block, this will NOT be played for all players around? I mean: will all players around hear the sound made by some player? And if not, will this crash or just be played for this one triggering player? And (if other won't hear it) do I really need to use packets?

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites


If you only want to make a funny sound for the player holding the item, client-side all the way. You don't even need to change the sound toggle, since there only is one player on client-side.



No, what he meant is, his sound toggle as of now, is not player sensitive. If two players equip the item, only the first one will trigger a sound. The flag will be false for the second one. Even more bizarre, if after that, one of the player unequip the item, the other will get a sound.

Link to comment
Share on other sites

That's a tough one. I too sat there like: "what on earth?!?". But here is the problem: There are always 2 players, client & server and both will fire a TickEvent. So your stuff gets executed twice, which makes it derp up. You need to only do this either on the server or only on the client.

Another flaw with your system is, that it will not work in multiplayer, because you only have one sound toggle. So as soon as there is more than one player on the server it will get screwed up again. You need to store the sound toggle "in" the entity player, I suggest using IExtendedEntityProperties for that.


hmm i did it the same way in 1.6.4 (well ok i used a tick handler but now ticks are events) i did try to make it server side only and the debug text repeated indeafenatly when the item is held but no sound, and if i made it client side on sound repeated all the time the item was held (played over itself).


im looking at a guide for IExtendedEntityProperties now and trying to absorb the knowledge contained thier in.



with out the sound toggle the sound will play every tick as every tick the conditions will be true, so it has to be there. my sound handler deals with all sounds and ensures that any sound that needs to be played is heard by all in range, it actualy gets the coords of the entity its given and plays the sound there, the upshot is all hear the sound (here thats not really needed but is a bonus, in other stuff it will be needed) the downside is the sound does not move with the entity that made it and stays localised to that area.... im sure theres ways of getting it to track with the entity i just havent looked into it yet.

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.

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.