Jump to content

Recommended Posts

Posted

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 ^_^

Posted

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.

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.

Posted
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.

Posted
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.

Posted
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 ¬¬)

Posted

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.

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.

Posted

THey arnt, as stated above you need to do so in the AttachCapabilityEvent.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Posted
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?

Posted

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.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

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.