Interface NBTComponent<C extends NBTComponent<C>>

Type Parameters:
C - component type
All Superinterfaces:
Component, ComponentBuilderApplicable, ComponentLike, HoverEventSource<Component>, StyleGetter, StyleSetter<Component>
All Known Subinterfaces:
BlockNBTComponent, EntityNBTComponent, StorageNBTComponent

public sealed interface NBTComponent<C extends NBTComponent<C>> extends Component permits BlockNBTComponent, EntityNBTComponent, StorageNBTComponent
A component that can display NBT fetched from different locations, optionally trying to interpret the NBT as JSON using the net.kyori.adventure.text.serializer.gson.GsonComponentSerializer to convert the JSON to a Component. Sending interpreted NBT to the chat would be similar to using /tellraw.

This component consists of:

nbtPath
a path to specify which parts of the nbt you want displayed(examples).
interpret
a boolean telling adventure if the fetched NBT value should be parsed as JSON
plain
a boolean telling adventure if the fetched NBT value should be pretty-printed without styling

This component is rendered serverside and can therefore receive platform-defined context. See the documentation for your respective platform for more info

Since:
4.0.0
Since Minecraft:
1.14
  • Field Details

  • Method Details

    • nbtPath

      String nbtPath()
      Gets the NBT path.
      Returns:
      the NBT path
      Since:
      4.0.0
    • nbtPath

      @Contract(pure=true) C nbtPath(String nbtPath)
      Sets the NBT path.
      Parameters:
      nbtPath - the NBT path
      Returns:
      an NBT component
      Since:
      4.0.0
    • interpret

      boolean interpret()
      Gets if we should be interpreting.

      This cannot be true if plain() is also true.

      Returns:
      if we should be interpreting
      Since:
      4.0.0
    • interpret

      @Contract(pure=true) C interpret(boolean interpret)
      Sets if we should be interpreting.

      This cannot be true if plain() is also true.

      Parameters:
      interpret - if we should be interpreting.
      Returns:
      an NBT component
      Throws:
      IllegalArgumentException - if set to true and plain() is also true
      Since:
      4.0.0
    • separator

      @Nullable Component separator()
      Gets the separator.
      Returns:
      the separator
      Since:
      4.8.0
    • separator

      C separator(@Nullable ComponentLike separator)
      Sets the separator.
      Parameters:
      separator - the separator
      Returns:
      an NBT component
      Since:
      4.8.0
    • plain

      boolean plain()
      Gets if styling should be removed from pretty-printed NBT.

      This cannot be true if interpret() is also true.

      Returns:
      if styling should be removed when pretty-printed
      Since:
      5.0.0
      Since Minecraft:
      26.1
    • plain

      C plain(boolean plain)
      Sets if styling should be removed from pretty-printed NBT.

      This cannot be true if interpret() is also true.

      Parameters:
      plain - if styling should be removed when pretty-printed
      Returns:
      an NBT component
      Throws:
      IllegalArgumentException - if set to true and interpret() is also true
      Since:
      5.0.0
      Since Minecraft:
      26.1
    • toBuilder

      NBTComponentBuilder<C, ? extends NBTComponentBuilder<C,?>> toBuilder()
      Description copied from interface: Component
      Returns a builder for this component.
      Specified by:
      toBuilder in interface Component
      Returns:
      the builder