sp614x / optifine

1.8k stars 418 forks source link

[Bug] is_aggressive, aggression state unavailable with certain entities #7458

Open Nuanulla opened 1 year ago

Nuanulla commented 1 year ago

Description of Issue

is_aggressive is a boolean that reflects an entity's aggressive state where they are tracking a target to attack. The boolean doesn't reflect base hostility of a mob toward player or another mob. On the other hand, the boolean doesn't solely reflect any one attacking state. OptiFine's is_aggressive is correctly detecting the state change in mobs such as Piglin, Drowned, and Zombie. However, it isn't detecting mob aggression in Ghasts and Blazes. Consequently, when this boolean variable is included in a Ghast CEM Animation statement, for example, the variable remains False through all in-game conditions.

is_aggressive wishlist: Ghast Blaze Warden

Steps to Reproduce

When the next version of my pack releases, refer to the following line in my Blaze.jem file: "var.hostile_counter": "if(is_aggressive, 1, var.hostile_counter)"

Otherwise, include these statements to test in-game: "body.visible": "!is_aggressive"

This is a simple statement that turns a mob's body/torso invisible when it is in an aggressive state. Include and alter where appropriate.

OptiFine Version

I5 pre7 (for Game Version 1.20.1)

Installation Method

JAR file in mods folder

Fabric/Forge Version

47.0.35

Other Installed Mods

no-telemetry-1.7.0 ShoulderSurfing-Forge-1.20.1-2.4

Log Files/Crash Reports

F3 Debug Screenshot

Prior Testing

Additional Information

Nuanulla commented 1 year ago

Use any version 4.2.9 and after to test this bug: https://modrinth.com/resourcepack/nier-automata-resource-pack/version/4.2.9-50

Look at how the eyes change color with Zombies and not so with Ghasts and Blazes. All entities share the same relevant behavior code for CEM animation.

sp614x commented 1 year ago

Client ghasts don't have an aggressive mode. They only have an attacking animation which briefly shows the shooting texture. This is not supported by OF yet. Blazes change to "burning" state when aggressive, is_burning should work for them.

Nuanulla commented 1 year ago

Client ghasts don't have an aggressive mode. They only have an attacking animation which briefly shows the shooting texture. This is not supported by OF yet. Blazes change to "burning" state when aggressive, is_burning should work for them.

I see! I didn’t realize this behavior isn’t consistent across all player-hostile mobs. I can somewhat work with the conditions you mentioned for now. Hopefully we can get proper consistent is_aggressive states for the two mobs soon as I do depend on it for my mobs to change eye colors. Thanks for the reply.

Nuanulla commented 1 year ago

To give a bit more context, the below is the part of my animation code that relies on is_aggressive to 'trap' an entity in its aggression state: "var.hostile_counter": "if(is_aggressive, 1, var.hostile_counter)", "varb.is_hostile": "in(var.hostile_counter, 1)" I use this code to identify which mobs have detected the player or a valid target entity, changing eye color from passive yellow to hostile red.

Ghast's shooting texture, in particular, is interesting as I could make a unique emissive overlay applied to that texture to identify when Ghast is attacking (this mimics enemy behavior in NieR:Automata). Unfortunately, since it's unavailable for other mobs and this mob behavior doesn't appear consistent, I'm relying on is_aggressive for my animation code.

Nuanulla commented 1 year ago

Also can't find aggression state in Pillager entities. Is this because they track targetable entities even in their 'passive' state? Either way, is it possible to align their behavior with other mobs through the is_aggressive boolean? (as in allow OptiFine to detect Pillager state as aggressive when they are actively attacking, as like with zombies, skeletons, and most other hostile mobs)

Nuanulla commented 1 year ago

Updated post with "is_aggressive wishlist". Adding Warden entity as is_aggressive doesn't work with this model, either.