SHsuperCM Posted September 11, 2016 Share Posted September 11, 2016 Since I decided that capabilities are waay too complicated for me to handle, I'm now looking for a way to just save an NBT compound onto a file in the world folder(WORLD! NOT DIMENSION!) And read it later. This ofc will only be done on server side(And I'll mess later with packets) Quote Doing stuff n' things Link to comment Share on other sites More sharing options...
SHsuperCM Posted September 11, 2016 Author Share Posted September 11, 2016 If you want stuff attached to the world, use WorldSavedData. If you want stuff attached to players or entities, do not do this yourself! Capabilities are the way to go. I really cant understand it! Please just give me a video that explains it really! Capabilities seem so complicated for me! Quote Doing stuff n' things Link to comment Share on other sites More sharing options...
SHsuperCM Posted September 11, 2016 Author Share Posted September 11, 2016 First off, Thank you so very much for taking your time to explain this! It means alot to me that there is someone that is willing to help.. Now, I've read what you said about 4 times, Repeating sections again and again.. But I still struggle to understand.. Do I need to make a custom CapabilityProvider? How? Do I need to attach the Capability some how to the CapabilityProvider? How? Can you explain what you mean by "implementation of an interface"? I probably know this but dont know how its called... Do you know of any open source mods that do this? Let's say, Add an Capability to the Player/manipulating it/checking for it's values? I belive this is a "valid" capability? public interface ICResearch{ boolean getMainResearch(); } Quote Doing stuff n' things Link to comment Share on other sites More sharing options...
Animefan8888 Posted September 11, 2016 Share Posted September 11, 2016 First off, Thank you so very much for taking your time to explain this! It means alot to me that there is someone that is willing to help.. Now, I've read what you said about 4 times, Repeating sections again and again.. But I still struggle to understand.. Do I need to make a custom CapabilityProvider? How? Do I need to attach the Capability some how to the CapabilityProvider? How? Can you explain what you mean by "implementation of an interface"? I probably know this but dont know how its called... Do you know of any open source mods that do this? Let's say, Add an Capability to the Player/manipulating it/checking for it's values? I belive this is a "valid" capability? public interface ICResearch{ boolean getMainResearch(); } Implementation is similar to extending class, you just are not limited by how many you can implement and instead of saying extends it is implements and you can only implement and interface. Tinkers Construct I believe is Open Source and should have some sort of capability. Also interfaces can extend interfaces. Read the stuff in parentheses as that is where diesieben denotes more information and names of interfaces and classes. Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator. Link to comment Share on other sites More sharing options...
Draco18s Posted September 11, 2016 Share Posted September 11, 2016 I think it needs to extend a Capability object/interface of some sort, but that would be a valid interface for the custom one, yes. You'd then need to implement it. I'm away from dev, so I can't check. Quote 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 More sharing options...
SHsuperCM Posted September 11, 2016 Author Share Posted September 11, 2016 Do I need ICResearch to extend a custom provider? If so, what's a valid capability provider? Quote Doing stuff n' things Link to comment Share on other sites More sharing options...
Animefan8888 Posted September 11, 2016 Share Posted September 11, 2016 Do I need ICResearch to extend a custom provider? If so, what's a valid capability provider? Capabilities are simple. There are capability providers (interface ICapabilityProvider ). By default these are Entity , TileEntity , ItemStack and World . These now have two very simple methods: hasCapability and getCapability . hasCapability checks if the provider has the given capability ("do you have an inventory on the west side?"). getCapability obtains the capability instance ("give me your inventory on the west side"). A capability itself is now represented by an interface (for inventories it's IItemHandler as an example) and a Capability object. The Capability object is just the identifier for the capability (for IItemHandler it's stored in ItemHandlerCapability.CAPABILITY_ITEM_HANDLER ). You pass this object into hasCapability / getCapability to interact with the capability provider (see above). In this example getCapability would then give you back an IItemHandler . So far this is just for things providing their own capabilities. But you want to attach a capability to something that is "not yours" (the player entity). For that you can use the AttachCapabilitiesEvent , which allows you to provide your own capability provider instance (i.e. something that provides capabilities via hasCapability and getCapability ). Forge will then multiplex ("combine") the original provider (in this case the player entity, remember all entities implement ICapabilityProvider ) with your attached one (and any others attached by other mods). How to make your own capability? Well, first you need an interface that represents it and an implementation for that interface (an interface on it's own is pretty useless without implementation, right?). Then you need to register it using CapabilityManager.register and request the capability instance using @CapabilityInject . You now implement ICapabilityProvider and you can expose your capability. Last step, how to make your capability save to disk? If you are one of the "normal" capability providers this is easy (entities, tile entities, etc. all have mechanics to save to disk, they can just pass these on to their capabilities). If you are in an attached provider however you need to additionally implement INBTSerializable on your capability provider. If you do that, forge will call the methods defined in that interface on your provider and let you save to disk that way. Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator. Link to comment Share on other sites More sharing options...
SHsuperCM Posted September 11, 2016 Author Share Posted September 11, 2016 But I'm stupid.... I need to see a code's prespective of using the providers to capabilities Sadly I also need to leave the DEV pc for an hour or 2.... I'll try to awnser stuff from my phone I guess... Quote Doing stuff n' things Link to comment Share on other sites More sharing options...
SHsuperCM Posted September 11, 2016 Author Share Posted September 11, 2016 Do I use the Entity provider is what you mean? Quote Doing stuff n' things Link to comment Share on other sites More sharing options...
Choonster Posted September 11, 2016 Share Posted September 11, 2016 Do you know of any open source mods that do this? Let's say, Add an Capability to the Player/manipulating it/checking for it's values? I have an example in my mod: API, implementation This is a bit complex because the IMaxHealth object stores the entity's bonus max health and manages an AttributeModifier that actually applies the bonus max health to the entity. Quote 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 More sharing options...
SHsuperCM Posted September 13, 2016 Author Share Posted September 13, 2016 I attempted again and again for the past days and couldnt figure it still.. I think ill just go with my previous plan which is using the achievement system to Do this... I dont know why capabilities are do hard to use really, usally i learn these things really quickly.. Quote Doing stuff n' things Link to comment Share on other sites More sharing options...
Animefan8888 Posted September 13, 2016 Share Posted September 13, 2016 I attempted again and again for the past days and couldnt figure it still.. I think ill just go with my previous plan which is using the achievement system to Do this... I dont know why capabilities are do hard to use really, usally i learn these things really quickly.. Jaeblar has a slight outline of Capabilities http://jabelarminecraft.blogspot.com/p/minecraft-17x.html Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator. Link to comment Share on other sites More sharing options...
Recommended Posts
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.