WeaponMechanics / MechanicsMain

A New Age of Weapons in Minecraft.
https://www.spigotmc.org/resources/WeaponMechanics.99913/
MIT License
71 stars 26 forks source link

listenerConditions in Lever firemode "Open" mechanics cause no sound to be played #428

Open galacticwarrior9 opened 1 month ago

galacticwarrior9 commented 1 month ago

Current/Expected Behavior

If I add listenerConditions to a CustomSound mechanic under the Open mechanics of a Lever Firearm_Action weapon, the sound will not play. However, it will play correctly if moved under the Close mechanics, or if the listenerConditions are removed.

Steps To Reproduce

Consider the following mechanic:

  Firearm_Action:
    Type: "LEVER"
    Open:
      Time: 17
      Mechanics:
        - "CustomSound{sound=bolt_open, volume=0.25, pitch=1, noise=0.1, listenerConditions=[Range{max=6}], delayBeforePlay=10}"

The bolt_open sound does not play when I fire the weapon. But now if I remove the listenerConditions and /wm reload, the sound will play as expected:

  Firearm_Action:
    Type: "LEVER"
    Open:
      Time: 17
      Mechanics:
        - "CustomSound{sound=bolt_open, volume=0.25, pitch=1, noise=0.1, delayBeforePlay=10}"

It seems to be specific to Open mechanics because the same mechanic under Close works correctly.

Log File

Log is here, although there appears to be nothing of note.

Anything else?

No response

galacticwarrior9 commented 1 month ago

Upon further investigation, it seems the real issue is some kind of incompatibility between listenerConditions and delayBeforePlay when they are in the same mechanic.

Works:

  Firearm_Action:
    Type: "LEVER"
    Open:
      Time: 17
      Mechanics:
        - "CustomSound{sound=mosin_bolt_open, volume=3, pitch=1, noise=0.1, delayBeforePlay=5}"

Doesn't work:

  Firearm_Action:
    Type: "LEVER"
    Open:
      Time: 17
      Mechanics:
        - "CustomSound{sound=mosin_bolt_open, volume=3, pitch=1, noise=0.1, delayBeforePlay=5, listenerConditions=[Range{max=6}]}"
CJCrafter commented 3 weeks ago

I can't think of any obvious reason why that might be the case... delayBeforePlay doesn't actually change how mechanics are called, it just delays it. It's one of those special arguments...

Have you been able to find more info on what is causing the issue?