Make entity say something once when setting attack target.

Started by moffmoth1 on

Topic category: Help with MCreator software

Active 3 months ago
Joined Apr 2022
Points:
450

User statistics:

  • Modifications: 0
  • Forum topics: 2
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 4
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.

Active 1 month ago
Joined May 2021
Points:
827

User statistics:

  • Modifications: 4
  • Forum topics: 11
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 353
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}

Active 3 months ago
Joined Apr 2022
Points:
450

User statistics:

  • Modifications: 0
  • Forum topics: 2
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 4
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.

Active 2 months ago
Joined Jul 2020
Points:
705

User statistics:

  • Modifications: 0
  • Forum topics: 7
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 105
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.

Active 3 months ago
Joined Apr 2022
Points:
450

User statistics:

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

NBT code; not working.

Like this? Because still no luck.

Active 3 months ago
Joined Apr 2022
Points:
450

User statistics:

  • Modifications: 0
  • Forum topics: 2
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 4
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!!