User Tools

Site Tools


zh_cn:tutorial:items

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
zh_cn:tutorial:items [2025/04/01 07:50] – [添加物品模型、纹理和模型映射] solidblockzh_cn:tutorial:items [2025/04/01 08:00] (current) – [下一步] solidblock
Line 147: Line 147:
  
 该物品模型映射将指定物品使用对应的物品模型。 该物品模型映射将指定物品使用对应的物品模型。
 +
 +> :!: 手动创建这些文件显然会很累。了解数据生成可看看 [[datagen_model]] 页面。
 +
  
 ===== 创建物品类 ===== ===== 创建物品类 =====
Line 205: Line 208:
 这个例子中,物品默认不可破坏,并隐藏关于这一点的物品提示: 这个例子中,物品默认不可破坏,并隐藏关于这一点的物品提示:
 <yarncode java> <yarncode java>
-    // For versions below 1.21.2:+    // 对于 1.21.2 之前的版本:
     public static final CustomItem CUSTOM_ITEM = register("custom_item", new CustomItem(new class_1792.class_1793()     public static final CustomItem CUSTOM_ITEM = register("custom_item", new CustomItem(new class_1792.class_1793()
         .component(DataComponentTypes.UNBREAKABLE, new UnbreakableComponent(true))));         .component(DataComponentTypes.UNBREAKABLE, new UnbreakableComponent(true))));
-    // For versions since 1.21.2:+         
 +    // 对于从 1.21.2 及以后、1.21.4 之前的版本:
     public static final Item CUSTOM_ITEM = register("custom_item", CustomItem::new, new Item.Settings()     public static final Item CUSTOM_ITEM = register("custom_item", CustomItem::new, new Item.Settings()
         .component(DataComponentTypes.UNBREAKABLE, new UnbreakableComponent(true)));         .component(DataComponentTypes.UNBREAKABLE, new UnbreakableComponent(true)));
 +        
 +    // 对于从 1.21.4 及以后:
 +    public static final Item CUSTOM_ITEM = register("custom_item", CustomItem::new, new Item.Settings()
 +        .component(DataComponentTypes.UNBREAKABLE, Unit.INSTANCE));
 </yarncode> </yarncode>
  
Line 219: Line 227:
     // 我们新物品的实例,最大堆叠数为 16     // 我们新物品的实例,最大堆叠数为 16
          
-    // For versions below 1.21.2:+    // 对于 1.21.2 之前的版本:
     public static final CustomItem CUSTOM_ITEM = register("custom_item", new CustomItem(new class_1792.class_1793().maxCount(16)));     public static final CustomItem CUSTOM_ITEM = register("custom_item", new CustomItem(new class_1792.class_1793().maxCount(16)));
-    // For versions since 1.21.2:+     
 +    // 自从 1.21.2 开始:
     public static final Item CUSTOM_ITEM = register("custom_item", CustomItem::new, new Item.Settings().maxCount(16));     public static final Item CUSTOM_ITEM = register("custom_item", CustomItem::new, new Item.Settings().maxCount(16));
     [...]     [...]
Line 288: Line 297:
 类似地,你也可以使用 ''CompostingChanceRegistry'' 来让物品可以在堆肥桶中堆肥。 类似地,你也可以使用 ''CompostingChanceRegistry'' 来让物品可以在堆肥桶中堆肥。
 ===== 下一步 ===== ===== 下一步 =====
-试着[[zh_cn:tutorial:itemgroup|将你的物品添加到一个物品组中]]。+试着[[itemgroup|将你的物品添加到一个物品组中]]。你的物品还没有名字,所以还可以看看[[lang|如何创建语言文件]]。
zh_cn/tutorial/items.1743493827.txt.gz · Last modified: 2025/04/01 07:50 by solidblock