Jump to content

[1.12.2] Capabilities boggling mind


FrostBytes

Recommended Posts

I didn't really understand the Forge Capabilities docs and I was asking if someone could help me digest the information.
Things I understand:
Capabilities provide a way to save data, like energy or inventories.
How am I supposed to change data about a tile entity using capabilities? I understand how to create a custom capability, but after that I was lost.

Epic Website

Link to comment
Share on other sites

5 hours ago, diesieben07 said:

What kind of data do you want to change? It would help if you could explain what you are actually trying to achieve.

I’m not trying to achieve anything atm. I just want to know what I can do with it and how. I just want someone to break down some of the information provided in the documents because I don’t really understand it. But, because it will be a complete waste of time rewording everything, lets just say I want to make power levels for an item. This item carrys only a single integer that cannot be higher than 20. How would I implement the capability system to do such thing?

Edited by FrostBytes
very vague comment
  • Like 1

Epic Website

Link to comment
Share on other sites

Capabilities are a better way of achieving the same thing as Interfaces.

Interface way:

if (tileEntity instanceof IThing)

Capability way

if (tileEntity.hasCapability(ThingCapability))

Interface way:

((IThing)tileEntity).doThing();

Capability way

tileEntity.getCapability(ThingCapability).doThing();

 

Interfaces make your tile be something while Capabilities let your tile provide something. Capabilities follow the OOP concept of "Composition over Inheritance".

  • Thanks 3

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

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.