Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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

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.

  • Author
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.

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.

  • Author
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 ¬¬)

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.

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

  • Author
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?

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.