Started by
darthewolf
on
Topic category: Help with Minecraft modding (Java Edition)
Title says it all. Is there any way to change/fix this?
I can provide living entity configs/blockbench model/whatever if needed
Topic category: Help with Minecraft modding (Java Edition)
Title says it all. Is there any way to change/fix this?
I can provide living entity configs/blockbench model/whatever if needed
My advice would be to make a procedure to run on entity tick update for your custom entities (or extend the procedure if you already have one):
First check if [Is [Get entity [Event/target entity] is targeting for attack] (sub)type of {Living Entity}] This will check that the attack target (which from now on I'll refer to as [attack target]) is a living entity and avoid crashes.
Then you want to check the distance to the attack target by forming a big < check, where on the left you have the vector procedure block [Get distance between [] and []] And in the two slots, you use [Make vector with x: [X position of [Event/target entity]] y: [Y position of [Event/target entity]] z: [Z position of [Event/target entity]]] for the first one, and the same for [attack target] for the second slots. Then you compare all of that to check that it is less then a small whole number, such as 4.
Inside that if condition, you want to make Event/target entity look at the attack target, then move towards where it is looking.
To make it look at its target, use [Make [Event/target entity] look at x: [X position of [attack target]] y: [[Y position of [attack target]] + [[Get height of [attack target]] * [0.8]]] z: [Z position of [attack target]]]
To make it move towards its looking location, use [Push [Event/target entity] with dx: [[X value of look angle vector of [Event/target entity]] * [0.03]] dy: [0] dz: [[Z value of look angle vector of [Event/target entity]]]
And that should work. Basically, when your entity is targeting something to attack it, and that target is within 4 blocks, it will look at it and move towards its looking destination. The downsides of this method are that your entity, when close to a target in this way, will ignore any hazards or obstacles in its way that it would otherwise avoid (clever players could lure it into a lava pool), and the entity will basically rush past/around the target (you could see this as a downside or an added challenge for fighting it).
I hope this helps.