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    7589

diesieben07

diesieben07    7589

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7589
  • 54951 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

    • bleep_blops
      Forge Installation Problem

      By bleep_blops · Posted 8 minutes ago

      TYSM  
    • T1ps
      GUI Documentation

      By T1ps · Posted 24 minutes ago

      @Draco18s Ok... That's weird lmao umm is there any completed documentation for it or am I just gonna need to mess around?
    • _HungTeen_
      [1.15.2] Invalid criterion trigger

      By _HungTeen_ · Posted 38 minutes ago

      I am making a new Criterion trigger called SunAmountTrigger. First I create SunAmountTrigger class like the default did : https://github.com/HungTeen/pvzmod/blob/dev/src/main/java/com/hungteen/pvz/advancement/SunAmountTrigger.java And then I register it in AdvancementHandler : https://github.com/HungTeen/pvzmod/blob/dev/src/main/java/com/hungteen/pvz/advancement/AdvancementHandler.java Here is the json file of the custom advancement : https://github.com/HungTeen/pvzmod/blob/dev/src/main/resources/data/pvz/advancements/sunny_days.json But When I run mc, I didn't see the advancements and got log like this: [m[1;31m[11:11:47] [Server thread/ERROR] [minecraft/AdvancementManager]: Parsing error loading custom advancement pvz:sunny_days: Invalid criterion trigger: minecraft:sun_amount   I don't know why it's Invalid, tysm if someone can help me figure out.
    • monkeysHK
      [1.16] Transparent Picture Render in GUI

      By monkeysHK · Posted 40 minutes ago

      It was a really good reference to look at. I am trying to define a RenderState and use their constructor and their setup and clear functions. But it still wouldn't work. I don't know where the problem is. private static final RenderState.AlphaState HALF_ALPHA = new RenderState.AlphaState(0.5F); minecraft.getTextureManager().bindTexture(new ResourceLocation("minecraft", "textures/gui/widgets.png")); matrixStack.push(); HALF_ALPHA.setupRenderState(); { matrixStack.translate(instru_pos[currentNbo.ordinal()][0], instru_pos[currentNbo.ordinal()][1], 0); matrixStack.scale((255/20f)*scale, (255/20f)*scale, (255/20f)*scale); this.blit(matrixStack, 0, 0, 0, 146, 20, 20); } HALF_ALPHA.clearRenderState(); matrixStack.pop();  
    • DaemonUmbra
      Mods work in singleplayer but not in multiplayer

      By DaemonUmbra · Posted 45 minutes ago

      1.12 is no longer supported on this forum. Please update to a modern version of Minecraft to receive support.
  • Topics

    • bleep_blops
      2
      Forge Installation Problem

      By bleep_blops
      Started 4 hours ago

    • T1ps
      2
      GUI Documentation

      By T1ps
      Started Tuesday at 10:14 PM

    • _HungTeen_
      0
      [1.15.2] Invalid criterion trigger

      By _HungTeen_
      Started 38 minutes ago

    • monkeysHK
      2
      [1.16] Transparent Picture Render in GUI

      By monkeysHK
      Started Yesterday at 12:19 AM

    • __SmolMight__
      1
      Mods work in singleplayer but not in multiplayer

      By __SmolMight__
      Started 3 hours ago

  • Who's Online (See full list)

    • nicolas14101
    • IsaiahjRamsay
    • ToastyBoi87
    • _HungTeen_
    • DaemonUmbra
    • c_o_w
    • Teedledee
    • Azaka7
    • AurenX
  • 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