How do I get the attack target of my entity in the procedure "on entity tick update"

Started by Enderwarp9 on

Topic category: Help with Minecraft modding (Java Edition)

Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How do I get the attack target of my entity in the procedure "on entity tick update"

Hello. 

I wanted to make my entity spawn particles which will damage any entity inside those particles (which works) but this particle process requires me to make a timer. The only procedure in the entity class which constantly runs is the "on entity tick update". The timer requires the procedure to run constantly and that is why I need to use this procedure. Now the problem is that I don't know how I can get the attack target of my entity in this procedure since it allows only the use of target/event entity and entity iterator. Any help is appreciated (I use the 2023.1 version btw) 

Joined Mar 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
There is a code block for …
Sat, 04/01/2023 - 22:05

There is a code block for "Get entity X is targeting for attack" which should be what you need, if I am not mistaken. However I'm not really clear why you need their attack target if you are damaging all nearby entities, so perhaps I am misunderstanding.

Just, if you do use that block, make sure you check the target is not null to avoid crashes.

Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Now the problem is that in…
Tue, 04/04/2023 - 19:29

Now the problem is that in the "on entity tick update", every entity of the mob gets called. Do you know how I can do it so the Event/target entity is only of one entity of my custom mob class? 

Joined Mar 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
There is an "X is of (sub…
Tue, 04/04/2023 - 21:38

There is an "X is of (sub)type Y" block at the bottom of the "Logic" category.

Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Actually that's not exactly…
Tue, 04/04/2023 - 22:49

Actually that's not exactly what I meant. You are right with the entity class but I wanted to only get one single entity from that class. But since on entity tick update calls the entire class I guess it is not possible. Instead I think I found a solution. I just made it that when the entity swings my custom sword then certain particles will spawn one after another by using the "call procedure" block and the "wait X ticks on server side". I hope it will work but I am not sure