Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.16.5] Entity with dynamically changing stats (attributes?)


Recommended Posts

Hello! I'm currently working on a mob and I would like its stats to be able to change depending on what/how many mobs are around it, such as dealing knockback if a certain mob is in range, or having N health where N is the number of nearby mobs. I was hoping to be able to use the attributes for this (.MAX_HEALTH, .FOLLOW_RANGE, .MOVEMENT_SPEED, etc.) but that has been proving more difficult than I anticipated. Are there any other ways I can set many different stats for my entity, but dynamically as mobs move in and out of range as opposed to the attributes which are seemingly only on setup?

Link to comment
Share on other sites

Attributes are the way to go. You can add and remove modifiers at will while the entity is "alive". This happens for living entities when they equip an item - the item's attribute modifiers are then applied to the entity, potentially increasing its attack damage or other attributes.

  • Thanks 1
Link to comment
Share on other sites

That's good to hear, I really liked the way attributes had all the stats laid out. Though when I was looking for ways to edit them I couldn't find much, running setCustomAttributes in my entity didn't seem to change the stats at all and both the EntityAttributeCreationEvent and the EntityAttributeModificationEvent didn't quite seem to be what I was looking for. What would I need to do change them as often as I'm trying to?

Link to comment
Share on other sites

2 hours ago, Tybonel13 said:

What would I need to do change them as often as I'm trying to?

Finally found something, turns out I was overcomplicating it. Instead of firing events or trying to change baked-in methods I can just set values of the attributes directly. 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.