Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • (1.16.2) Making a new capability
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 0
e2rifia

(1.16.2) Making a new capability

By e2rifia, Thursday at 01:12 PM in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

e2rifia    0

e2rifia

e2rifia    0

  • Tree Puncher
  • e2rifia
  • Members
  • 0
  • 23 posts
Posted Thursday at 01:12 PM (edited)

I tried to follow this page to create a capability.

https://mcforge.readthedocs.io/en/latest/datastorage/capabilities/

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> {
    @CapabilityInject(IState.class)
    public static final Capability<IState> STATE_CAPABILITY = null;

    private IState instance = STATE_CAPABILITY.getDefaultInstance();

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

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

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

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

Edited Thursday at 01:13 PM by e2rifia
  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7592

diesieben07

diesieben07    7592

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7592
  • 55027 posts
Posted Thursday at 01:14 PM

EnumFacing is Direction now.

NBTBase would be INBT.

  • Like 1
  • Quote

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 0
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • Huntpor
      1.16.5 Loot Tables

      By Huntpor · Posted 1 minute ago

      I am able to Generate new Blocks and Items into my very simple mod ( just has Copper Ore ) while I learn. When it comes to those items I am able to generate the texture just fine, but I get a little stuck how how to allow the new blocks to generate their own item. Is Loot tables the correct thing? or should I be looking for something else? Don't even know where to begin, so details would be helpful.    Thank you in advice.   
    • diesieben07
      Some Obj models not working

      By diesieben07 · Posted 7 minutes ago

      I don't know enough about the OBJ format and models in general to know if this is a wrongly formatted model or an issue with the loader, sorry.
    • diesieben07
      [1.14.3] Where to put Item.getItemFromBlock

      By diesieben07 · Posted 13 minutes ago

      1.14 is no longer supported. If you have an issue with a modern version, make your own thread.
    • LEXISMILES
      lexi

      By LEXISMILES · Posted 16 minutes ago

      fkwefwwefewklfjewuhfeufhuih4u74u34y43urhewrur4yy4ryw4rwruwerhywertryryewtryetwgretwtewyreyrewhewfhyefytire
    • Draco18s
      [1.14.3] Where to put Item.getItemFromBlock

      By Draco18s · Posted 25 minutes ago

      Linked resources are not in your src folder, they're stored elsewhere and referenced in your Project Explorer tab of your IDE.
  • Topics

    • Huntpor
      0
      1.16.5 Loot Tables

      By Huntpor
      Started 1 minute ago

    • Alexalien
      8
      Some Obj models not working

      By Alexalien
      Started 3 hours ago

    • VGLyen
      6
      [1.14.3] Where to put Item.getItemFromBlock

      By VGLyen
      Started July 24, 2019

    • LEXISMILES
      0
      lexi

      By LEXISMILES
      Started 17 minutes ago

    • GenElectrovise
      3
      [ForgeGradle] Publish project to GitHub Packages

      By GenElectrovise
      Started Friday at 10:04 PM

  • Who's Online (See full list)

    • Godis_apan
    • Huntpor
    • CookieLukas
    • laryr
    • diesieben07
    • Jesus Sandals
    • Alexalien
    • Lucie
    • S-Spirit
    • KillsBoostMyEgo
    • Luis_ST
    • LEXISMILES
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • (1.16.2) Making a new capability
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community