User Tools

Site Tools


zh_cn:tutorial:items_docs

Differences

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

Link to this comparison view

Next revision
Previous revision
zh_cn:tutorial:items_docs [2020/10/31 15:27] – part one [WIP] leocth2zh_cn:tutorial:items_docs [2023/11/18 08:00] (current) solidblock
Line 1: Line 1:
 +:!: 此页面已存档。
 ====== 物品 ====== ====== 物品 ======
-Items are the pieces of content that appear in your inventory. They can perform actions when you click, act as food, or spawn entities. The following documentation will give you a rundown of the entire ''Item'' class and everything related to it. For a tutorial you can follow along, visit [[tutorial:items|Practical Example: Adding an Item]].+物品是你物品栏中占据一个一个格子的内容。它们可以在右击的时候执行操作,食用,或生成实体。以下是整个''Item''(物品)类与其相关部件的简介。如果你需要一个可以边做边学的例子,请见我们[[zh_cn:tutorial:items|添加物品的教程]]
  
 ===== 物品设置 ===== ===== 物品设置 =====
  
-''Item''(物品类)的构造方法(constructor)需要一个''Item.Settings''(物品设置类)的实例。该建造者(builder class)定义物品的诸多行为,例如堆叠数量、耐久度、是否可食用等等。以下是所有可用的建造者方法:+''Item'' 的构造方法需要一个 ''Item.Settings'' 的实例,这个类定义物品的诸多行为,例如堆叠数量、耐久度、是否可食用等等。以下是所有可用的方法:
  
 ^ 方法      ^ 参数类型         ^ 简介          ^ ^ 方法      ^ 参数类型         ^ 简介          ^
Line 11: Line 12:
 | maxDamageIfAbsent | ''int'' | 若该物品未设置最大耐久度以及堆叠数量不大于1,则设置最大耐久度为参数值。| | maxDamageIfAbsent | ''int'' | 若该物品未设置最大耐久度以及堆叠数量不大于1,则设置最大耐久度为参数值。|
 | maxDamage | ''int'' | 设置该物品的最大耐久度。(与大于1的最大堆叠数量冲突,**并且会在注册时报错!**)| | maxDamage | ''int'' | 设置该物品的最大耐久度。(与大于1的最大堆叠数量冲突,**并且会在注册时报错!**)|
-| recipeRemainder | ''Item'' | 设置该物品的合成后偿还给玩家的物品(如牛奶桶偿还的物品则是空桶)。| +| recipeRemainder | ''Item'' | 设置该物品的合成剩余物(即合成后偿还给玩家的物品)。|
-| group | ''ItemGroup'' | 设置该物品的物品组(即创造物品栏中的标签页)。 |+
 | rarity | ''Rarity'' | 设置该物品的稀有度,而其也决定了物品名称的默认显示颜色。| | rarity | ''Rarity'' | 设置该物品的稀有度,而其也决定了物品名称的默认显示颜色。|
 +| fireproof | None | 使物品防火,不被熔岩和火破坏。|
 +
 +===== Fabric物品设置 =====
 +Fabric的物品API提供了一些额外的方法来设置一些其他属性。要使用这些新方法,只需要将''new Item.Settings()''替换成''new FabricItemSettings()''即可。
 +下列是所有''FabricItemSettings''提供的额外功能:
 +
 +^ 方法      ^ 参数类型         ^ 简介          ^
 +| equipmentSlot | ''EquipmentSlotProvider'' | 设置物品如何提供并指定装备槽。 |
 +| customDamage | ''CustomDamageHandler'' | 设置物品如何自定义处理伤害变化。 |
  
 ---- ----
  
-==== Food ====+==== 食物 ====
 <code java> <code java>
 public Item.Settings food(FoodComponent foodComponent) public Item.Settings food(FoodComponent foodComponent)
 </code> </code>
-''foodComponent''instance of'FoodComponent. When set, the Item will be edible based on the settings provided by the FoodComponent builder. For an in-depth explanation of the available options, view the FoodComponent Overview page.+''foodComponent''一个''FoodComponent''对象。设置时物品的可食属性会根据''FoodComponent''的值而变化。更深一步的讲解请见FoodComponent的简介页。
  
 ---- ----
  
-==== Max Stack Count ====+==== 最大堆叠数量 ====
 <code java> <code java>
 public Item.Settings maxCount(int maxCount) public Item.Settings maxCount(int maxCount)
 </code> </code>
-''maxCount''the maximum count of an ItemStack for the given Item. If ''maxDamage()'' has already been called, a RuntimeException is thrown, as an Item cannot have both damage and count. Keeping the max count at or below 64 is recommended, as any value above that can lead to various issues.+''maxCount''物品在物品堆中可堆叠的最大数量。如果之前已经调用过''maxDamage()'',游戏会抛出一个''RuntimeException''(运行时异常),因为一个物品无法同时拥有数量与耐久度。推荐将最大堆叠数量设为64以下的值,更高的值可能会引发许多问题。
  
 ---- ----
  
-==== Max Damage if Absent ====+==== 若未设置则设置最大耐久度 ====
 <code java> <code java>
 public Item.Settings maxDamageIfAbsent(int maxDamage) public Item.Settings maxDamageIfAbsent(int maxDamage)
 </code> </code>
-''maxDamage''max durability of the given ''Item'' when in ''ItemStack'' form. +''maxDamage''物品在物品堆中的最大耐久度。
  
-If ''maxDamage()'' has not been called yet, the max durability of the Item is set to the value passed in. This is used for cases such as tools and armor, where the Item's durability is only set to the ToolMaterial's durability //if// it has not been set yet.+如果之前还没有调用过''maxDamage()'',则会将最大耐久度设成参数的值。工具和盔甲//在没有设置耐久度时//会使用此方法来将物品的最大耐久度设置为工具材料(''ToolMaterial'')的最大耐久度。
  
 ---- ----
  
-==== Max Damage ====+==== 最大耐久度 ====
 <code java> <code java>
 public Item.Settings maxDamage(int maxDamage) public Item.Settings maxDamage(int maxDamage)
 </code> </code>
-''maxDamage''max durability of the given Item when in ItemStack form. +''maxDamage''物品在物品堆中的最大耐久度。
  
 ---- ----
  
-==== Recipe Remainder ====+==== 合成剩余物 ====
 <code java> <code java>
 public Item.Settings recipeRemainder(Item recipeRemainder) public Item.Settings recipeRemainder(Item recipeRemainder)
 </code> </code>
-''recipeRemainder''Item to return as a remainder when the base Item is used in a crafting recipe.+''recipeRemainder''原物品在合成完成之后返回的物品
  
-When a recipe remainder is set on an Item, any recipe using that Item will return the remainder on craft. This is used for buckets (Water, Lava, Milk) and bottles (Dragon Breath, Honey) returning their respective empty items when used in recipes.+有设置了合成剩余物的物品在合成后会将剩余物返回给玩家。设置了该属性的物品有桶(熔岩、水、牛奶)和瓶子(龙息、蜂蜜),合成过后则会返回对应的空物品。
  
 ---- ----
  
-==== Group ====+ 
 +==== 稀有度 ====
 <code java> <code java>
-public Item.Settings group(ItemGroup group)+public Item.Settings rarity(Rarity rarity)
 </code> </code>
-''group''ItemGroup to add Item in.+''rarity''该物品的稀有度。(默认为常见)
  
-Each ItemGroup appears as a tab in the creative inventory. Adding an Item to this group will add it to the tab. The order of the group is based on registry order. For more information on creating a group, see the [[tutorial:itemgroup|ItemGroups page]].+有自定义的稀有度的物品名称会变成不同的颜色。 
 +^ 稀有度 ^ 字体颜色 ^ 
 +| 常见 | 白色 | 
 +| 少见 | 黄色 | 
 +| 稀有 | 青色 | 
 +| 史诗 | 淡紫色 |
  
----- +==== 防火 ====
- +
-==== Rarity ====+
 <code java> <code java>
-public Item.Settings rarity(Rarity rarity)+public Item.Settings fireproof()
 </code> </code>
-''rarity'' - Rarity of the given Item. 
  
-If Rarity is set, the given Item will have a custom name color. An Item's Rarity defaults to common. +使物品防火,包含此物品的物品实体不被火和熔岩烧毁。
-^ Rarity ^ Color ^ +
-| Common | White | +
-| Uncommon | Yellow | +
-| Rare | Aqua | +
-| Epic | Light Purple |+
zh_cn/tutorial/items_docs.1604158058.txt.gz · Last modified: 2020/10/31 15:27 by leocth2