向游戏添加新物品
自定义物品在启动脚本中创建。它们不能在不重新启动游戏的情况下重新加载。事件不可取消。
有效的物品类型:
basic(这是默认值)
sword
pickaxe
axe
shovel
shears
hoe
helmet
chestplate
leggings
boots
物品构建器支持的其他方法(您可以在 create() 之后链式调用这些方法):
maxStackSize(size)
unstackable() 与 maxStackSize(1) 相同
maxDamage(damage)
burnTime(ticks)
fireResistant(true/false)
rarity(rarity)
glow(true/false)
tooltip(text...)
color(index, colorHex)
color((itemstack, tintIndex) => ...)
displayName(name)
name(itemstack => ...)
translationKey(key)
textureJson(json)
modelJson(json)
parentModel(customParentModelLocation)
texture(customTextureLocation)
texture(key, customTextureLocation)
barColor(itemstack => ...)
barWidth(itemstack => ...)
useAnimation(animation)
useDuration(itemstack => ...)
use((level, player, hand) => ...)
finishUsing((itemstack, level, entity) => ...)
releaseUsing((itemstack, level, entity, tick) => ...)
tag(resourceLocation)
modifyAttribute(attribute, identifier, d, operation)
group(groupId)
containerItem(itemId)
subtypes(itemstack => ...)
food(foodBuilder => ...) 完整语法见下方
已删除的旧方法:
type(type) - 1.16 和 1.18
tool(type, level) - 1.16
如果您使用工具类型(sword、pickaxe、axe、shovel 或 hoe),可用方法:
tier(toolTier)
modifyTier(tier => ...) 语法与自定义工具等级相同,见 自定义等级
attackDamageBaseline(damage) 只有在创建自定义武器(如长矛、战斧等)时才需要修改此值
attackDamageBonus(damage)
speedBaseline(speed) 与 attackDamageBaseline 相同,仅用于自定义武器类型
speed(speed)
默认可用的工具等级:
wood
stone
iron
gold
diamond
netherite
如果您使用护甲类型('helmet'、'chestplate'、'leggings' 或 'boots'),可用方法:
tier(armorTier)
modifyTier(tier => ...) 语法与自定义护甲等级相同,见 自定义等级
默认可用的护甲等级:
leather
chainmail
iron
gold
diamond
turtle
netherite
原版物品组/创造模式标签ID:
search
buildingBlocks
decorations
redstone
transportation
misc
food
tools
combat
brewing
1.21.1 1.20 - 1.19
脚本文件夹:startup_scripts/