Started by
ILikeAlienDinosaurs
on
Topic category: Help with Minecraft modding (Java Edition)
I want to make a mob attack when it isn’t being looked at. I need a metric butt-ton of help though.
Topic category: Help with Minecraft modding (Java Edition)
I want to make a mob attack when it isn’t being looked at. I need a metric butt-ton of help though.
Getting the entity to attack or not attack based on a condition is possible; you can use the 'set attack target' function to make the entity hostile towards the player. Deaggroing it is trickier, but also possible, you can summon an invisible, unkillable entity and have the mob target that instead, then despawn the invisible entity. It's awkward, but it works.
The tricky part here is the look condition. You can get the vector of the player's look direction, and the block they're looking at... but getting the entity will require math. You can use the x/y/z look-angle-vector functions for the player to get the individual components of the direction they're looking at, but you then need a function to somehow check if your mob's position is along the look angle vector of the nearest player. I've done a bit of work with trig functions and entities, but this would probably be a lot more difficult. Smarter people than myself might be able to provide an explanation on how to actually write this. But yes, essentially, a function that checks if the mob's position is within a certain range of the player's look vector.
Uhh very confusing, but thanks
Also, any idea how to make a bleed effect that changes the texture of your healthbar?