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

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)

Doing stuff n' things

  • Author

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!

Doing stuff n' things

  • Author

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();
}

ย 

Doing stuff n' things

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.

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.

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.

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

Do I need ICResearch to extend a custom provider?

If so, what's a valid capability provider?

Doing stuff n' things

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.

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.

  • Author

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

Doing stuff n' things

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.

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.

  • Author

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

Doing stuff n' things

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

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.

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.