GiantNuker Posted March 17, 2017 Posted March 17, 2017 Hi, I am working with Minecraft 1.11.2 and I am having a problem with the capability system. There is the "AttachCapabilitiesEvent" but my problem is if my mod is installed AFTER a world is generated, I cannot attach ANY capabilities!(My mod REALLY needs this one) Thank you for your time Quote
Draco18s Posted March 18, 2017 Posted March 18, 2017 What are you trying to attach a capability to? You can't install a mod while the game is running which means that the event should work just fine. 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.
GiantNuker Posted March 18, 2017 Author Posted March 18, 2017 14 hours ago, Draco18s said: What are you trying to attach a capability to? You can't install a mod while the game is running which means that the event should work just fine. When I am in my development environment and I run my mod, it has a capability check which determines if it can run. My mod attaches capabilities to the player(specifically them "magic user" capability) and the mod fails without it. Quote
Jay Avery Posted March 18, 2017 Posted March 18, 2017 7 minutes ago, GiantNuker said: When I am in my development environment and I run my mod, it has a capability check which determines if it can run. My mod attaches capabilities to the player(specifically them "magic user" capability) and the mod fails without it. What? Your mod attaches capabilities, but if your mod capability isn't already there then your mod doesn't run...? Post your code to explain what is happening. Quote
GiantNuker Posted March 20, 2017 Author Posted March 20, 2017 On 3/18/2017 at 9:35 AM, Jay Avery said: What? Your mod attaches capabilities, but if your mod capability isn't already there then your mod doesn't run...? Post your code to explain what is happening. if (!player.hasCapability(MagicUserProvider.USER_CAP, null)) throw new IllegalArgumentException("player object must have capability") Will capabilities automatically be created?(In which case this code is completely pointless ) Quote
Jay Avery Posted March 20, 2017 Posted March 20, 2017 No, capabilities are not created automatically. What exactly are you trying to do? Quote
Matryoshika Posted March 20, 2017 Posted March 20, 2017 You need to manually attach the Capability to the intended object, as well as register the Capability. To attach a Capability to an Entity (like a player) you need to use an @Mod.EventBusSubscriber annotated eventhandler for the AttachCapabilitiesEvent<Entity> event. To register the Capability, call CapabilityManager::register with the Interface class, an IStorage object for the Capability, and lastly a Factory for said Capability (Most just call a new instance of the Capability with lambda). It would be easiest for everyone if you posted your code, and state what you have tried already. Quote Also previously known as eAndPi. "Pi, is there a station coming up where we can board your train of thought?" -Kronnn Published Mods: Underworld Handy links: Vic_'s Forge events Own WIP Tutorials.
GiantNuker Posted March 26, 2017 Author Posted March 26, 2017 Ok, I did not realize that capabilities were attached automatically. Quote
LexManos Posted March 26, 2017 Posted March 26, 2017 THey arnt, as stated above you need to do so in the AttachCapabilityEvent. Quote I do Forge for free, however the servers to run it arn't free, so anything is appreciated. Consider supporting the team on Patreon
GiantNuker Posted March 31, 2017 Author Posted March 31, 2017 On 3/26/2017 at 0:11 PM, LexManos said: THey arnt, as stated above you need to do so in the AttachCapabilityEvent. I mean when a new mod is added all entities will get a run through of the AttatchCapabilitiesEvent? Quote
LexManos Posted March 31, 2017 Posted March 31, 2017 Every time time the entity class is loaded it will fire the event. It doesnt care if mods are added or not. Has nothing to do with the world being old or new. Its whenever the instance of the class is created in the JVM. Quote I do Forge for free, however the servers to run it arn't free, so anything is appreciated. Consider supporting the team on Patreon
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.