Jump to content

[1.10.2] Good attributes tutorial/how to use them for players?


RealTheUnderTaker11

Recommended Posts

I can't seem to find any tutorials or threads on how I should use attributes to add traits to players, so how would I do it? The only things on EntityPlayer related to attributes seem to be getters. I gather I should probably be using AttributeModifier somehow, but at the same time there is a whole list of IAtributes in SharedMonsterAttributes. My end goal is to use these to change the players attack speed, max health, and movement speed.

So is there any good resources I can use to figure out what I need to do?

My IGN is TheUnderTaker11, but when I tried to sign up for this site it would not send the email... So yea now I have to use this account.

Link to comment
Share on other sites

If you want to modify the values of existing attributes on entities that aren't your own, use attribute modifiers. The wiki has an explanation of attributes and modifiers here.

 

If you want to store custom data on entities that aren't your own, use capabilities.

 

I have a capability that manages an attribute modifier for

SharedMonsterAttributes.MAX_HEALTH

here: API, implementation.

 

It's also used by the following classes:

  • [url=https://github.com/Choonster/TestMod3/blob/f2476600a276d8a95280078e61049b709ba90466/src/main/java/choonster/testmod3/command/CommandMaxHealthBase.java]CommandMaxHealthBase[/url]


  • [url=https://github.com/Choonster/TestMod3/blob/f2476600a276d8a95280078e61049b709ba90466/src/main/java/choonster/testmod3/command/CommandMaxHealthAdd.java]CommandMaxHealthAdd[/url]


  • [url=https://github.com/Choonster/TestMod3/blob/f2476600a276d8a95280078e61049b709ba90466/src/main/java/choonster/testmod3/command/CommandMaxHealthGet.java]CommandMaxHealthGet[/url]


  • [url=https://github.com/Choonster/TestMod3/blob/f2476600a276d8a95280078e61049b709ba90466/src/main/java/choonster/testmod3/command/CommandMaxHealthSet.java]CommandMaxHealthSet[/url]


  • [url=https://github.com/Choonster/TestMod3/blob/f2476600a276d8a95280078e61049b709ba90466/src/main/java/choonster/testmod3/block/BlockMaxHealthGetter.java]BlockMaxHealthGetter[/url]


  • [url=https://github.com/Choonster/TestMod3/blob/f2476600a276d8a95280078e61049b709ba90466/src/main/java/choonster/testmod3/block/BlockMaxHealthSetter.java]BlockMaxHealthSetter[/url]


  • [url=https://github.com/Choonster/TestMod3/blob/f2476600a276d8a95280078e61049b709ba90466/src/main/java/choonster/testmod3/item/ItemMaxHealthGetter.java]ItemMaxHealthGetter[/url]


  • [url=https://github.com/Choonster/TestMod3/blob/f2476600a276d8a95280078e61049b709ba90466/src/main/java/choonster/testmod3/item/ItemMaxHealthSetter.java]ItemMaxHealthSetter[/url]

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

If you want to add information to a player, use a capability, you can read up on it here: http://mcforge.readthedocs.io/en/latest/datastorage/capabilities/

Yes I have already used capabilities on players to do a different function in my mod, but I'm asking how to actually change the max health or whatever else of a player.

If you want to modify the values of existing attributes on entities that aren't your own, use attribute modifiers. The wiki has an explanation of attributes and modifiers here.

 

If you want to store custom data on entities that aren't your own, use capabilities.

 

I have a capability that manages an attribute modifier for

SharedMonsterAttributes.MAX_HEALTH

here: API, implementation.

 

It's also used by the following classes:

Wow thank you so much for the examples, that's awesome you have a whole mod just for helping people on these forums.

Also I had seen that wiki page that you linked, because I actually found a different thread where you had linked that same page before and I went to it. Although it does explain what attributes are, it doesn't really say how to use them for my purposes.

edit: Jesus the more I read through this the less I feel like I know. I'm slowing catching on though... Slowly.

My IGN is TheUnderTaker11, but when I tried to sign up for this site it would not send the email... So yea now I have to use this account.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.