Started by
U.S.S.DEFIANT
on
Topic category: Help with Minecraft modding (Java Edition)
Good evening.
I want to make a procedure for mob AI: if player have some effects, attack him. How can I get the target, that mob want to attack? I tried to use: Get Entity (Event/target entity) is targeting for attack, but it returned null. How can I fix it?
same
Any idea about this?
The returning null error for the 'Get Entity (Event/target entity) is targeting for attack' can be bypassed by putting it in an if block that checks is Get Entity (Event/target entity) is targeting for attack (sub)type of LivingEntity. I don't know why, but it works without crashing.
Got the same issue. So im new to mcreator and I want to make my boss detect the player. Can you explain your answer a bit more cause im new? (screenshot would help A LOT)
Basically, to fix the error of the procedure returning null, you need to put the whole thing in an if block.
In the if block's condition, you put the [is [target entity] (sub)type of {type}] block, but you change the {type} dropdown to be LivingEntity, and you replace [target entity] with [get entity [target entity] is targeting for attack] That should fix the issue.
The end result should be:
[if [is [get entity [target entity] is targeting for attack] (sub)type of {LivingEntity}]]
Do your procedure
Sorry about the lack of screenshot, I don't use image hosting websites, so I can't post a screenshot.
Also, just to clarify, I am using square brackets[] to indicate different procedure blocks, and curly brackets{} to show a dropdown menu.
You could use on entity tick update. Entity iterator is square cube of (attack range of mob). If entity iterator has effect X then set attack target of event/target entity to entity iterator. You could make a local variable to check whether theres more than 1 entity with the effect in range and target one specifically using a random integer or whatever.
If you want the entity to be passive unless the player has the effect then make the ai for the mob to only attack after being attacked first. Probably works.
Thanks everyone!