Class Item

java.lang.Object
org.geysermc.geyser.item.type.Item
Direct Known Subclasses:
ArmorItem, ArrowItem, AxolotlBucketItem, BlockItem, BoatItem, CompassItem, CrossbowItem, DyeItem, EnchantedBookItem, FireworkRocketItem, FireworkStarItem, FishingRodItem, GoatHornItem, MapItem, NonVanillaItem, OminousBottleItem, PotionItem, ShieldItem, SpawnEggItem, TropicalFishBucketItem, WolfArmorItem, WritableBookItem, WrittenBookItem

public class Item extends Object
  • Field Details

    • BEDROCK_MAX_STACK_SIZE

      public static final int BEDROCK_MAX_STACK_SIZE
      See Also:
    • javaIdentifier

      protected final net.kyori.adventure.key.Key javaIdentifier
  • Constructor Details

  • Method Details

    • javaIdentifier

      public String javaIdentifier()
    • javaKey

      public net.kyori.adventure.key.Key javaKey()
    • javaId

      public int javaId()
    • defaultMaxDamage

      public int defaultMaxDamage()
    • defaultAttackDamage

      public int defaultAttackDamage()
    • defaultMaxStackSize

      public int defaultMaxStackSize()
    • is

      public boolean is(GeyserSession session, Tag<Item> tag)
    • is

      public boolean is(GeyserSession session, org.geysermc.mcprotocollib.protocol.data.game.item.component.HolderSet set)
    • gatherComponents

      public @NonNull @UnmodifiableView org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents gatherComponents(@Nullable ComponentCache componentCache, @Nullable org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents others)
      Returns an unmodifiable DataComponents view containing known data components. Optionally, additional components can be provided to replace (or add to) the items' base components. To add data components, use GeyserItemStack.getOrCreateComponents().
    • getComponent

      public <T> @Nullable T getComponent(@Nullable ComponentCache componentCache, @NonNull org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponentType<T> type)
      Returns this items value (or null) for a specific DataComponentType. Prefer using GeyserItemStack.getComponent(DataComponentType) to also query additional components that would override the default ones.
    • translationKey

      public String translationKey()
    • translateToBedrock

      public org.cloudburstmc.protocol.bedrock.data.inventory.ItemData.Builder translateToBedrock(GeyserSession session, int count, org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents components, ItemMapping mapping, ItemMappings mappings)
    • translateToJava

      public @NonNull GeyserItemStack translateToJava(GeyserSession session, @NonNull org.cloudburstmc.protocol.bedrock.data.inventory.ItemData itemData, @NonNull ItemMapping mapping, @NonNull ItemMappings mappings)
    • toBedrockDefinition

      public ItemMapping toBedrockDefinition(org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents components, ItemMappings mappings)
    • translateComponentsToBedrock

      public void translateComponentsToBedrock(GeyserSession session, @NonNull org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents components, @NonNull TooltipOptions tooltip, @NonNull BedrockItemBuilder builder)
      Takes components from Java Edition and map them into Bedrock.
    • translateNbtToJava

      public void translateNbtToJava(GeyserSession session, @NonNull org.cloudburstmc.nbt.NbtMap bedrockTag, @NonNull org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents components, ItemMapping mapping)
      Takes NBT from Bedrock Edition and converts any value that Java parses differently.
      Do note that this method is, these days, only called in three places (as of 2023/~1.19):
      • Extra recipe loading
      • Creative menu
      • Stonecutters
      Therefore, if translation cannot be achieved for a certain item, it is not necessarily bad.
    • remapEnchantment

      protected final @Nullable org.cloudburstmc.nbt.NbtMap remapEnchantment(GeyserSession session, int enchantId, int level, BedrockItemBuilder builder)
    • translateDyedColor

      protected final void translateDyedColor(org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents components, BedrockItemBuilder builder)
    • ignoreDamage

      public boolean ignoreDamage()
      Override if the Bedrock equivalent of an item uses damage for extra data, and should not be tracked when translating an item.
    • newItemStack

      public GeyserItemStack newItemStack(GeyserSession session, int count, org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents components)
    • setJavaId

      public void setJavaId(int javaId)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • byBlock

      public static @NonNull Item byBlock(Block block)
      Returns:
      the block associated with this item, or air if nothing
    • registerBlock

      protected static void registerBlock(Block block, Item item)
    • builder

      public static Item.Builder builder()