Jump to content
  • Home
  • Files
  • Docs
  • Merch
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.12.2] Capabilities Vs. NBT: Use-Cases/Performance
1.13 Update Notes for Mod Creators
Sign in to follow this  
Followers 1
SerpentDagger

[1.12.2] Capabilities Vs. NBT: Use-Cases/Performance

By SerpentDagger, October 5 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

SerpentDagger    16

SerpentDagger

SerpentDagger    16

  • Creeper Killer
  • SerpentDagger
  • Members
  • 16
  • 127 posts
Posted October 5

What are the specific differences between Capabilities and NBT data?

For example...

Under what circumstances should I use each?

Which is quicker to access?

How do they store data?

I know from the documentation that Capabilities, particularly the ones already provided by Forge, are very useful in compatibility, so it's clear that they should be used accordingly. It's less clear, however, which to choose for less universal or less openly visible/utilized concepts.

If there's other information that might be interesting or useful that you'd like to share about them, that would also be appreciated.

Thanks in advance.

  • Quote

Share this post


Link to post
Share on other sites

Animefan8888    677

Animefan8888

Animefan8888    677

  • Reality Controller
  • Animefan8888
  • Forge Modder
  • 677
  • 5746 posts
Posted October 5
7 minutes ago, SerpentDagger said:

Under what circumstances should I use each?

In an ideal world, everyone would use Capabilities and not mess with the ItemStacks NBTTagCompound at all. So basically always use Capabilities.

8 minutes ago, SerpentDagger said:

Which is quicker to access?

If we are talking computer performance, I think NBTTagCompound just boils down to a HashMap and a Capability is also stored in a HashMap. Capability are easier to read and NBT is sloppy. If we are talking the amount of time to write the code, it comes down to how much information, for small amounts NBT is faster to implement but larger amounts it's typically faster to create a Capability.

11 minutes ago, SerpentDagger said:

How do they store data?

In RAM NBT is a HashMap<String, INBT> where INBT is a single NBT attribute a Compound/HashMap, List/ArrayList, NBTInt/int, etc. Where as in a Capability you define your own object that is attached to a Object(Entity, ItemStack, World, etc) and you store it there in whatever manner you want(not NBT).

On disk everything is converted to NBT and written in Minecraft's custom file format.

  • Thanks 1
  • Quote

Share this post


Link to post
Share on other sites

SerpentDagger    16

SerpentDagger

SerpentDagger    16

  • Creeper Killer
  • SerpentDagger
  • Members
  • 16
  • 127 posts
Posted October 5

Thanks, that's exactly what I was looking for. I'll convert my NBT things over to Capabilities, then, since it seems there's no real advantage in using NBT data instead.

  • 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 1
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • TomPlayzs
      [ solved ] - HUD images (exp bar, health, hunger, etc.) glitching out.

      By TomPlayzs · Posted 22 minutes ago

      I have this problem too! How do i fix it?
    • Oliviafrostpaw
      [1.14.4] Injecting into Existing Loot Tables, Blocks

      By Oliviafrostpaw · Posted 33 minutes ago

      Making it easier for showing the code, please see GitHub repository that I ideally should have set up to begin with so that I would have known when exactly all of this broke Github Link
    • DragonITA
      [1.14.4] How to get Minecraft Horse model/texture to make a custom unicorn?

      By DragonITA · Posted 1 hour ago

      i think whoever's bugging me in the HorseEntity Class is, here: private static final String[] HORSE_TEXTURES = new String[]{"textures/entity/horse/horse_white.png", "textures/entity/horse/horse_creamy.png", "textures/entity/horse/horse_chestnut.png", "textures/entity/horse/horse_brown.png", "textures/entity/horse/horse_black.png", "textures/entity/horse/horse_gray.png", "textures/entity/horse/horse_darkbrown.png"};  
    • DragonITA
      [1.14.4] How to get Minecraft Horse model/texture to make a custom unicorn?

      By DragonITA · Posted 1 hour ago

      package net.batonfack.fantasymod.client.models; import net.minecraft.client.renderer.entity.model.EntityModel; import net.minecraft.client.renderer.entity.model.RendererModel; import net.minecraft.client.renderer.model.ModelBox; import net.minecraft.entity.LivingEntity; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @OnlyIn(Dist.CLIENT) public class ModelUnicornWitoutAbstracHorse<T extends LivingEntity> extends EntityModel<T> { protected final RendererModel field_217127_a; protected final RendererModel field_217128_b; private final RendererModel CornGroup; private final RendererModel Corn1; private final RendererModel Corn2; private final RendererModel Corn3; public ModelUnicornWitoutAbstracHorse(float p_i51065_1_) { this.field_217127_a = null; this.field_217128_b = null; this.textureWidth = 128; this.textureHeight = 64; CornGroup = new RendererModel(this); CornGroup.setRotationPoint(0.0F, 0.0F, 0.0F); Corn1 = new RendererModel(this, 64, 0); Corn1.setRotationPoint(1.5F, -5.0F, -15.0F); this.Corn1.setRotationPoint(0.5409F, 0.0F, 0.0F); CornGroup.addChild(Corn1); Corn1.cubeList.add(new ModelBox(Corn1, 52, 57, -3.0F, -3.0F, -4.0F, 3, 4, 3, 0.0F, true)); Corn2 = new RendererModel(this, 64, 28); Corn2.setRotationPoint(1.5F, -5.0F, -15.0F); this.Corn2.setRotationPoint(0.5409F, 0.0F, 0.0F); CornGroup.addChild(Corn2); Corn2.cubeList.add(new ModelBox(Corn2, 0, 0, -2.4F, -5.3F, -3.6F, 2, 3, 2, 0.0F, true)); Corn3 = new RendererModel(this, 96, 32); Corn3.setRotationPoint(1.5F, -5.0F, -15.0F); this.Corn3.setRotationPoint(0.5409F, 0.0F, 0.0F); CornGroup.addChild(Corn3); Corn3.cubeList.add(new ModelBox(Corn3, 0, 0, -1.8F, -8.1F, -3.2F, 1, 3, 1, 0.0F, true)); } protected void func_199047_a(RendererModel p_199047_1_) { RendererModel renderermodel = new RendererModel(this, 19, 16); renderermodel.addBox(0.55F, -13.0F, 4.0F, 2, 3, 1, -0.001F); RendererModel renderermodel1 = new RendererModel(this, 19, 16); renderermodel1.addBox(-2.55F, -13.0F, 4.0F, 2, 3, 1, -0.001F); p_199047_1_.addChild(renderermodel); p_199047_1_.addChild(renderermodel1); } }  
    • DragonITA
      [1.14.4] How to get Minecraft Horse model/texture to make a custom unicorn?

      By DragonITA · Posted 1 hour ago

      package net.batonfack.fantasymod.entities; import net.batonfack.fantasymod.init.FantasyModEntities; import net.minecraft.entity.EntityType; import net.minecraft.entity.passive.horse.HorseEntity; import net.minecraft.world.World; public class UnicornEntity extends HorseEntity { @SuppressWarnings("unchecked") public UnicornEntity(EntityType<? extends HorseEntity> type, World worldIn) { super((EntityType<? extends HorseEntity>) FantasyModEntities.UNICORN_ENTITY, worldIn); } }  
  • Topics

    • WinneonSword
      2
      [ solved ] - HUD images (exp bar, health, hunger, etc.) glitching out.

      By WinneonSword
      Started August 31, 2013

    • Oliviafrostpaw
      8
      [1.14.4] Injecting into Existing Loot Tables, Blocks

      By Oliviafrostpaw
      Started December 8

    • DragonITA
      40
      [1.14.4] How to get Minecraft Horse model/texture to make a custom unicorn?

      By DragonITA
      Started Monday at 10:06 AM

    • DarkZapato
      2
      Optifine 1.14.4 U HD F4 crash froge

      By DarkZapato
      Started Thursday at 04:09 PM

    • troyvs
      0
      [1.12.2]help me to attach capability to player

      By troyvs
      Started 1 hour ago

  • Who's Online (See full list)

    • TolgacanM
    • Choonster
    • Misterboy64
    • Yanny7
    • ricoc90
    • Oliviafrostpaw
    • TomPlayzs
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.12.2] Capabilities Vs. NBT: Use-Cases/Performance
  • Theme
  • Contact Us
  • Discord

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