Started by
SuperMax64
on
Topic category: Help with Minecraft modding (Java Edition)
when i created a custom liquid block, it turned out in the game that it has absolutely no sound. No splash sounds when the player enters it, no flow sound, not even bubbles when splashing. Also, there is no liquid fog inside the liquid. How can this be fixed? I tried to create liquid in another mod but the problems are the same.
Add sounds in the blocks properties, either import custom ones or use the vanilla water sounds. If youve got that then you need to make a procedure, when entity collides with block. Then just play sound vanilla water splash. If you want the sound to get louder depending on player velocity then use delta movement x y z and use that to get an integer and add it to the sound. For the ambient sound, idk theres probably an option in properties, if not then use a on tick update, make the block tick every 20 ticks that way a sound of 1 second will loop continuously. Use the play sound vanilla water flow sound on tick update. Idk if its actually 1 second but just make the tick the same as the sounds length in ticks, 20 ticks = 1 second. Idk what you mean about the bubbles.
hello, thanks for answering, i'm not good at programming, so could you explain in which file and in which place in the file you can specify sounds? about setting the sound for interaction with the player, i'll try. By bubbles i meant particles that are formed when the player falls into the water. I also said that underwater fog is not displayed in my liquid.
These would be the procedures.
On tick update:
On mob/player collides with block:
^The first if logic is so the sound doesn't continuously play while the player is under the water. You could also add spawn particles:bubbles under the 2 play sounds above. Theres also an underwater.loop sound which you could play, to do that make the if statement above an if else and play the sound under the else.
Also, idk if this will work so if it doesn't work it doesn't necessarily mean you did it wrong.
thank you very much! the first procedure works perfectly. but the second one plays the sound every tick while the player is floating on the surface of the water.
is it possible to change the tick rate for player collisions with block?
Try changing the 1st IF statement by adding a (not) block before the get block at x y+1 z. That should make the sound only play when entering or exiting the water or if the player is bobbing up and down. If that doesnt work try this:
For the sound playing on each tick, you could find out the length of the sound and then make a cooldown/timer for the same amount. This seems a bit over the top and maybes theres an easier solution. But to do this you would make a local variable eg timer. On the procedure you would make an IF timer = 0, then play the procedure above and then set timer to (length of sound in ticks), Else set timer to (get timer (-1)). This will count down the timer each tick.
Try the first thing and if it doesnt solve the issue try the second with the first as well.
You could also add a get block at x y+2 z and check if its NOT your custom fluid instead of checking y+1 is NOT. That might help.