FiguraMC / Figura

Extensively customize your character with Figura!
https://modrinth.com/mod/figura
GNU Lesser General Public License v2.1
225 stars 44 forks source link

ON_PLAY_SOUND event doesn't capture most sounds #197

Open Gakuto1112 opened 6 months ago

Gakuto1112 commented 6 months ago

Description

ON_PLAY_SOUND event doesn't capture most sounds played in Minecraft. It captures only sounds played by avatars or UIs. The following video describes this issue.

The video that describes this issue (This link has expiration date. If you can't watch the video, please watch in the conversation thread.)

In this video, I used the following script for the test.

events.ON_PLAY_SOUND:register(function (id, pos, vol, pitch, isLoop, category, path)
    print(id)
end)

keybinds:newKeybind("test_sound", "key.keyboard.z"):onPress(function ()
    sounds:playSound("minecraft:entity.player.levelup", player:getPos())
    print("Played a sound")
end)

This script outputs the sound id that ON_PLAY_SOUND captures and plays a sound when pressing a key. In above video, the script outputs only sounds played by itself and UIs.

In this conversation, @KitCat962 said that this may be a 1.20.4 bug.

How to reproduce

  1. Run above script.
  2. Emit sounds by doing something such as eating something, placing a block, shooting an arrow.
  3. You will see that the script doesn't output anything.

Expected behavior

According to this conversation, ON_PLAY_SOUND event captures most sounds including eating, placing, shooting sounds.

Enviroments

Item Version
Minecraft 1.20.4
Fabric Loader 0.15.7
Fabric API 0.96.4+1.20.4
Figura 0.1.4+1.20.4