Giter Club home page Giter Club logo

Comments (6)

wysohn avatar wysohn commented on June 18, 2024 1

You almost hit the right point, but there is another reason why #SOUND didn't work as intended.

Because how Executor was made, it extracts variable as much as possible from the event class itself.

In fact, #SOUND is designed to used when there is a 'player' variable exists, and the 'player' variable here is the player who got killed not the killer.

To go around with this problem, you have to manually invoke the method of killer's playSound()

This way, you will be able to play sound only for the killer.

But make sure to check if the killer is Player, as any entity can fire PlayerDeathEvent; the playSound() only exists for the Player; therefore, it will make error if the killer is not Player.

To check that, you may use IF statement

IF killer.getType().name() == PLAYER
    killer.playSound(...)
ENDIF

To add one more thing, if you look at the code in the SOUND in Executor folder, all it does is just invoking the same method for the 'player' variable.

from triggerreactor.

wysohn avatar wysohn commented on June 18, 2024 1

Umm actually, you can't do that as of now.

As you can see, the playSound() only accepts float, not double.

to work around on this one, you first save value and use floatValue() method.

volume = 1.0
pitch = 1.0
killer.playSound(someloc, sound, volume.floatValue(), pitch.floatValue())

from triggerreactor.

wysohn avatar wysohn commented on June 18, 2024 1

Or, really, you can create your own Executor xD

I think this way will work better

All you need to do is copy everything in the SOUND executor and change 'player' variable into 'player.getKiller()'

Maybe you can name it like SOUNDKILLER or something

#SOUNDKILLER killer.getLocation() "ENTITY_BLAZE_DEATH" 5.0 1.0

from triggerreactor.

DontActLikeMe avatar DontActLikeMe commented on June 18, 2024 1

Ok thank you so much for all your help. Im definitely gonna try all that you just put down.

from triggerreactor.

DontActLikeMe avatar DontActLikeMe commented on June 18, 2024

i tried both and was getting an error. I made your executor say player.getKiller() and i also did the IF statement but it said it did not recognize the value ENTITY_BLAZE_DEATH. this is how i had it.
dead.getKiller().playSound(dead.getKiller().getLocation(),Sound.ENTITY_BLAZE_DEATH,5,1) i also tried
dead.getKiller().playSound(dead.getKiller().getLocation(),ENTITY_BLAZE_DEATH, 5,1) it can always be me of course im human lol but i looked over each, a dozen times before coming back to you. I wanted to make sure it wasn't just me. I researched links on the play sound parameters to make sure i had them right.

from triggerreactor.

wysohn avatar wysohn commented on June 18, 2024

Ok, the thing is that TriggerReactor doesn't recognize static access xD

So it's nothing wrong with you as you tried the Java thing, but it was too much for TriggerReactor.

So what's the solution? I recently updated it to version 1.3.2, and this version support conversion from String to Enum.

For example,

dead.getKiller().playSound(dead.getKiller().getLocation(), "ENTITY_BLAZE_DEATH", 5, 1)

will work, because now TriggerReactor first check the parameter of method and see if it is Enum, then it will try to convert String value to Enum corresponding to the provided String. So the String you provide here must be exactly matching name with the one in the whatever enum you are trying to use.

I think the 5, 1 part will cause some error as the method only accepts float value. Did you try it? If that works then it's all good, but if it doesn't, try (5.0).floatValue()

Let me know if something still doesn't seem to work.

(Dont forget to get the latest version! I also added wiki about enum conversion, so you might want to take a look)

from triggerreactor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.