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

I've thought of this scenario, and I'm not sure how the capability system would behave in it:

Say mod A defines a handler interface adev.amod.AHandler, and uses it as a capability:

@CapabilityInject(AHandler.class)
public static Capability<IItemHandler> A_HANDLER_CAPABILITY = null;

However, it doesn't publish the capability as part of its API and it doesn't public its source, so I cannot compile against it.

If I, in my apis source set, in the same package define structurally the same interface, and use @CapabilityInject on it, will I get the same instance of the Capability as the one in mod A? How does change when I do/don't ship the AHandler interface with my mod? What if the mod is not present at runtime, will @CapabilityInject still try to reference the missing interface and crash? (I cannot really do any programmatic checks for the presence of the mod since annotations are compile-time constants)

This is a theoretical scenario, any mod that is worth building against will have their capabilities published.

The entire point of the capability system is that it is a soft reference.

Unless you do some dirty reflection hacks specifically on that field to resolve the generic type. Then it wont crash.

As for you faking the cap with your own code. Yes its possible, the JVM doesn't care who wrote the class as long as its structurally the same.

However it is better to talk to the mod author to see if they WANT to allow others to access that cap/feature of their mod.

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

Right, because type erasure is a thing...

Of course communicating is the preferred way for humans to handle things, I was just making a point.

Thanks for clarifying!

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.