如题~
一直想不明白什么是元数据...
一直想不明白什么是元数据...
ItemStack
-Represents a stack of items.
-代表一堆物品
ItemMeta
-This type represents the storage mechanism for auxiliary item data.
-An implementation will handle the creation and application for ItemMeta. This class should not be implemented by a plugin in a live environment.
-此类型表示辅助项数据的存储机制。
-一个实现将处理 ItemMeta 的创建和应用。此类不应由实时环境中的插件实现。
就是说你背包里一个位置放了附魔稿子,这稿子是一个ItemStack对象
而要修改稿子的附魔就需要得到这个ItemStack的ItemMeta ,修改后再设置回去
-Represents a stack of items.
-代表一堆物品
ItemMeta
-This type represents the storage mechanism for auxiliary item data.
-An implementation will handle the creation and application for ItemMeta. This class should not be implemented by a plugin in a live environment.
-此类型表示辅助项数据的存储机制。
-一个实现将处理 ItemMeta 的创建和应用。此类不应由实时环境中的插件实现。
就是说你背包里一个位置放了附魔稿子,这稿子是一个ItemStack对象
而要修改稿子的附魔就需要得到这个ItemStack的ItemMeta ,修改后再设置回去
牧野又白给了 发表于 2021-10-31 16:44
谢谢大佬,能再说一下什么是NBT吗
给你评分啦
不知道你是否熟悉指令
举个例子,给予20亿级锋利的下界合金剑
/give @s minecraft:netherite_sword{Enchantments:[{id:"minecraft:sharpness", lvl:2000000000}]} 1
蓝色部分是物品的种类,用Material表示
红色部分是物品的数量,用int表示
绿色部分是物品的NBT,用ItemMeta表示
整个染色部分就是一个物品堆,用ItemStack表示