Jump to content

(1.16.2) Making a new capability


Recommended Posts

I tried to follow this page to create a capability.


This is what I have so far. NBTBase and EnumFacing are not found to be imported. If they are out of date, what should I use instead?


import com.e2rifia.chants.util.IState;

import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.CapabilityInject;
import net.minecraftforge.common.capabilities.ICapabilitySerializable;


public class IHaveMana implements ICapabilitySerializable<NBTBase> {
    public static final Capability<IState> STATE_CAPABILITY = null;

    private IState instance = STATE_CAPABILITY.getDefaultInstance();

    public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
        return capability == STATE_CAPABILITY;

    public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
        return capability == STATE_CAPABILITY ? STATE_CAPABILITY.<T>cast(this.instance) : null;

    public NBTBase serializeNBT() {
        return STATE_CAPABILITY.getStorage().writeNBT(STATE_CAPABILITY, this.instance, null);

    public void deserializeNBT(NBTBase nbt) {
        STATE_CAPABILITY.getStorage().readNBT(STATE_CAPABILITY, this.instance, null, nbt);

Edited by e2rifia
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.

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.


  • Create New...

Important Information

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