Class RuntimeItemMapping

java.lang.Object
cn.nukkit.item.RuntimeItemMapping

public class RuntimeItemMapping extends Object
这个类用于将旧版本物品以id:damage形式转换到新版本物品无damage值(0)的形式,以及提供StartGamePacket中item Palette的作用

例如在1.19.70中,不同颜色的羊毛由wool:color damage变成了minecraft:white_wool,minecraft:orange_wool这类字面量形式。

  • Constructor Details

  • Method Details

    • fromRuntime

      public RuntimeItemMapping.LegacyEntry fromRuntime(int runtimeId)
      From runtimeId to get legacy item entry.
      Parameters:
      runtimeId - the runtime id
      Returns:
      the legacy entry
    • toRuntime

      public RuntimeItemMapping.RuntimeEntry toRuntime(int id, int meta)
      from legacy item id and meta value to get runtimeId
      Parameters:
      id - the id
      meta - the meta
      Returns:
      the runtime entry
    • fromIdentifier

      public RuntimeItemMapping.LegacyEntry fromIdentifier(String identifier)
      From identifier to get legacy entry.According to item_mappings.json
      Parameters:
      identifier - the identifier
      Returns:
      the legacy entry
    • getItemPalette

      public byte[] getItemPalette()
      Get item palette byte [ ].
      Returns:
      the byte [ ]
    • registerCustomItem

      @PowerNukkitXOnly @Since("1.6.0.0-PNX") public void registerCustomItem(CustomItem customItem, Supplier<Item> constructor)
    • deleteCustomItem

      @PowerNukkitXOnly @Since("1.6.0.0-PNX") public void deleteCustomItem(CustomItem customItem)
    • registerCustomBlock

      @PowerNukkitXOnly @Since("1.6.0.0-PNX") public void registerCustomBlock(List<CustomBlock> blocks)
    • deleteCustomBlock

      @PowerNukkitXOnly @Since("1.6.0.0-PNX") public void deleteCustomBlock(List<CustomBlock> blocks)
    • getNetworkId

      @PowerNukkitOnly @Since("1.4.0.0-PN") public int getNetworkId(Item item)
      Returns the network id based on the full id of the given item.
      Parameters:
      item - Given item
      Returns:
      The network id
      Throws:
      IllegalArgumentException - If the mapping of the full id to the network id is unknown
    • getLegacyFullId

      @PowerNukkitOnly @Since("1.4.0.0-PN") public int getLegacyFullId(int networkId)
      Returns the full id of a given network id.
      Parameters:
      networkId - The given network id
      Returns:
      The full id
      Throws:
      IllegalArgumentException - If the mapping of the full id to the network id is unknown
    • getItemDataPalette

      @PowerNukkitOnly @Since("1.4.0.0-PN") public byte[] getItemDataPalette()
    • getNamespacedIdByNetworkId

      @PowerNukkitOnly @Since("1.4.0.0-PN") @Nullable public String getNamespacedIdByNetworkId(int networkId)
      Returns the namespaced id of a given network id.
      Parameters:
      networkId - The given network id
      Returns:
      The namespace id or null if it is unknown
    • getNetworkIdByNamespaceId

      @PowerNukkitOnly @Since("1.4.0.0-PN") @NotNull public OptionalInt getNetworkIdByNamespaceId(@NotNull String namespaceId)
      Returns the network id of a given namespaced id.
      Parameters:
      namespaceId - The given namespaced id
      Returns:
      A network id wrapped in OptionalInt or an empty OptionalInt if it is unknown
    • getItemByNamespaceId

      @PowerNukkitOnly @Since("1.4.0.0-PN") @NotNull public Item getItemByNamespaceId(@NotNull String namespaceId, int amount)
      Creates a new instance of the respective Item by the namespaced id.
      Parameters:
      namespaceId - The namespaced id
      amount - How many items will be in the stack.
      Returns:
      The correct Item instance with the write item id and item damage values.
      Throws:
      IllegalArgumentException - If there are unknown mappings in the process.
    • registerNamespacedIdItem

      @PowerNukkitXOnly @Since("1.19.70-r2") public void registerNamespacedIdItem(@NotNull Class<? extends StringItem> item)
    • registerNamespacedIdItem

      @PowerNukkitOnly public void registerNamespacedIdItem(@NotNull String namespacedId, @NotNull Constructor<? extends Item> constructor)
    • registerNamespacedIdItem

      @PowerNukkitOnly public void registerNamespacedIdItem(@NotNull String namespacedId, @NotNull Supplier<Item> constructor)
    • getBlockMapping

      @DoNotModify @Since("1.19.80-r1") @PowerNukkitXOnly public static com.google.common.collect.BiMap<Integer,String> getBlockMapping()