Make entity say something once when setting attack target.

Started by moffmoth1 on

Topic category: Help with MCreator software

Joined Apr 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Make entity say something once when setting attack target.

Hello!

I have my code set up so that, upon a custom entity spotting a player and choosing to attack, it plays a sound. However, it rapidly plays it as long as it's attacking the player and I can't seem to make it stop. I want it to only happen once per player it attacks.

Joined May 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
First calculate the length…
Sun, 04/24/2022 - 05:36

First calculate the length of the sound in ticks, then in the same procedure add the blocks - wait <#> ticks, and insert <execute command [stopsound ... your_custom_sound}

Joined Apr 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I have three sounds in the…
Sun, 04/24/2022 - 18:55

I have three sounds in the soundbank for it. I want it to only play once per time the entity sets its sights on a player. Something like this:

Entity sees Player
Entity plays sound once
Entity is hit by skeleton, changing attack target
Entity does not play sound
Entity kills skeleton
Entity re-sees Player
Entity plays sound once

I have it working, except the sound plays each tick that the entity has its eyes on the player.

Joined Jul 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Have an nbt that turns to…
Sun, 04/24/2022 - 19:06

Have an nbt that turns to true if it is focused on player, and false if it isnt. If focused on the player, play the sound then turn it true.

Joined Apr 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Like this? Because still no…
Sun, 04/24/2022 - 19:14

NBT code; not working.

Like this? Because still no luck.

Joined Apr 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Update! I got it working, it…
Sun, 04/24/2022 - 19:57

Update! I got it working, it just doesn't re-play the sound if the entity changes targets and then back to the player. Still! This is great!!