Jump to content

[1.12.2] Multiple Capabilities


NolValue

Recommended Posts

So, I've been looking around at various old forum posts and such after being unable to figure this out myself, aside from some github sources which implement their own capability system instead of using forge's which is way too much effort for me to do.

I'm going to go ahead and ask this:

What's the easiest way to implement a multiple capability system, IE Stats (Strength, Constitution, Dexterity, etc. . .) with each stat containing a value.

 

Also, how would one inject it? The new capability system is way messier than IEEP for me to figure out.

 

Other things I need to be able to do is read, set, and add to the stats.
That's really it. 

I've been trying for the past 3 days to get a working code and was unable to. I don't need you to code the full thing out, just some pointers for what I need to do, seeing as the Forge Documentation is very limited in what it tells you.

Link to comment
Share on other sites

42 minutes ago, NolValue said:

So, I've been looking around at various old forum posts and such after being unable to figure this out myself, aside from some github sources which implement their own capability system instead of using forge's which is way too much effort for me to do.

I'm going to go ahead and ask this:

What's the easiest way to implement a multiple capability system, IE Stats (Strength, Constitution, Dexterity, etc. . .) with each stat containing a value.

 

Also, how would one inject it? The new capability system is way messier than IEEP for me to figure out.

 

Other things I need to be able to do is read, set, and add to the stats.
That's really it. 

I've been trying for the past 3 days to get a working code and was unable to. I don't need you to code the full thing out, just some pointers for what I need to do, seeing as the Forge Documentation is very limited in what it tells you.

Are you sure you need multiple capabilities? why not just one capability with all those values in it?

 

What are you using your capability on?

If your using Items/ItemStacks have a look at this code in my mod where I implement both the Energy Capability and my own Weapon Modules capability on my Item/ItemStack

ItemGun

This code is probably very messy and bad, but it was based on code written by one of Actually Additions authors, so I doubt its that horrible.

Edited by Cadiboo

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

6 minutes ago, Cadiboo said:

Are you sure you need multiple capabilities? why not just one capability with all those values in it?

 

What are you using your capability on?

If your using Items/ItemStacks have a look at this code in my mod where I implement both the Energy Capability and my own Weapon Modules capability on my Item/ItemStack

ItemGun

 

 

Well, I am attempting to use it on players, however I can still probably use your code to figure out how to do it for a player.

Also I do want 1 capability with multiple values, sorry for wording it so poorly.

Edited by NolValue
Link to comment
Share on other sites

1 minute ago, NolValue said:

Well, I am attempting to use it on players, however I can still probably use your code to figure out how to do it for a player.

This might be a good post to take a look at, and its relatively recent.

http://www.minecraftforge.net/forum/topic/63654-capabilities/

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

24 minutes ago, NolValue said:

Well, it seems that the new system is far too big of a mess for me to even to begin to attempt to use, so I'm just gonna go ahead and drop modding once again.

 

So thread closed I guess or whatever.

They are hard, but once your heads round them they Just Work (aside from syncing)

 

34 minutes ago, NolValue said:

I actually have been through that post, several times actually. It uses an outdated method for Capabilities which is completely deprecated, otherwise, I would be using that.

What method is "completely deprecated"???

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

8 hours ago, NolValue said:

Well, it seems that the new system is far too big of a mess for me to even to begin to attempt to use, so I'm just gonna go ahead and drop modding once again.

 

So thread closed I guess or whatever.

 

Capabilties are not a "mess" at all. They work quite well. They aren't really that complicated either. You just attach the capability to anything which is a capability provider and define the types of field you want it to contain.

 

Regarding any deprecated methods you might encounter. Deprecated methods can firstly usually still be used, they are just not the best way. Secondly they are often commented with a note that tells you what the replacement method is. Lastly, you can use your IDE to look at he type hiearchy (or "structure") of the class to see a list of available methods and it is usually quite obvious what the new one might be -- often they are named the same but just have a different parameter list prototype.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

47 minutes ago, jabelar said:

 

Capabilties are not a "mess" at all. They work quite well. They aren't really that complicated either. You just attach the capability to anything which is a capability provider and define the types of field you want it to contain.

 

Regarding any deprecated methods you might encounter. Deprecated methods can firstly usually still be used, they are just not the best way. Secondly they are often commented with a note that tells you what the replacement method is. Lastly, you can use your IDE to look at he type hiearchy (or "structure") of the class to see a list of available methods and it is usually quite obvious what the new one might be -- often they are named the same but just have a different parameter list prototype.

6

Well, for someone like me who hasn't touched modding since all the way back in 1.7.10, it's been a huge pain in the butt to learn the capability system. 

 

You telling me the old method is still usable is nice, as I had no idea what the hell a factory was, haha.


Anyways, I'm assuming what I need to do is to have an ENUM with the stats I need, then use an NBT compound to put the ENUM and the Stat's value into the Player, correct?

Link to comment
Share on other sites

Just now, NolValue said:

Well, for someone like me who hasn't touched modding since all the way back in 1.7.10, it's been a huge pain in the butt to learn the capability system. 

 

You telling me the old method is still usable is nice, as I had no idea what the hell a factory was, haha.


Anyways, I'm assuming what I need to do is to have an ENUM with the stats I need, then use an NBT compound to put the ENUM and the Stat's value into the Player, correct?

It doesn’t have to be an enum, it can be almost anything, however the most common things that are used are booleans, enum and integers. Remember you are going to have to be syncing your capability a lot, so yes enums are probably the best choice

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

24 minutes ago, NolValue said:

You telling me the old method is still usable is nice, as I had no idea what the hell a factory was, haha.

A factory is a class that creates instances of another class.

(What is a hammer factory? Why, its a building that builds hammers...)

 

https://en.wikipedia.org/wiki/Factory_method_pattern

Edited by Draco18s

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

I found capabilities very confusing at first, too. The Forge documentation didn't help me at all until I was already thoroughly familiar with capabilities. Try this tutorial.

 

https://www.planetminecraft.com/blog/forge-tutorial-capability-system/

 

It will get you started with a single stat called Mana, but you can obviously extend that to anything you want.

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.