Package cn.nukkit.item
Class RuntimeItemMapping
java.lang.Object
cn.nukkit.item.RuntimeItemMapping
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final record
static final record
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
deleteCustomBlock
(List<CustomBlock> blocks) void
deleteCustomItem
(CustomItem customItem) fromIdentifier
(String identifier) fromRuntime
(int runtimeId) getItemByNamespaceId
(String namespaceId, int amount) Creates a new instance of the respectiveItem
by the namespaced id.byte[]
byte[]
int
getLegacyFullId
(int networkId) Returns the full id of a given network id.getNamespacedIdByNetworkId
(int networkId) Returns the namespaced id of a given network id.int
getNetworkId
(Item item) Returns the network id based on the full id of the given item.getNetworkIdByNamespaceId
(String namespaceId) Returns the network id of a given namespaced id.void
registerCustomBlock
(List<CustomBlock> blocks) void
registerCustomItem
(CustomItem customItem, Supplier<Item> constructor) void
registerNamespacedIdItem
(Class<? extends StringItem> item) void
registerNamespacedIdItem
(String namespacedId, Constructor<? extends Item> constructor) void
registerNamespacedIdItem
(String namespacedId, Supplier<Item> constructor) toRuntime
(int id, int meta)
-
Constructor Details
-
RuntimeItemMapping
-
-
Method Details
-
fromRuntime
-
toRuntime
-
fromIdentifier
-
getItemPalette
public byte[] getItemPalette() -
registerCustomItem
@PowerNukkitXOnly @Since("1.6.0.0-PNX") public void registerCustomItem(CustomItem customItem, Supplier<Item> constructor) -
deleteCustomItem
-
registerCustomBlock
-
deleteCustomBlock
-
getNetworkId
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
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
-
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 emptyOptionalInt
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 respectiveItem
by the namespaced id.- Parameters:
namespaceId
- The namespaced idamount
- 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)
-