Custom Items
This is a startup_scripts/ event
// Listen to item registry event
onEvent('item.registry', event => {
// The texture for this item has to be placed in kubejs/assets/kubejs/textures/item/test_item.png
// If you want a custom item model, you can create one in Blockbench and put it in kubejs/assets/kubejs/models/item/test_item.json
event.create('test_item')
// You can chain builder methods as much as you like
event.create('test_item_2').maxStackSize(16).glow(true)
// You can specify item type as 2nd argument in create(), some types have different available methods
event.create('custom_sword', 'sword').tier('diamond').attackDamageBaseline(10.0)
})
Valid item types:
- basic (default)
- sword
- pickaxe
- axe
- shovel
- hoe
- helmet
- chestplate
- leggings
- boots
Other methods item builder supports: [you can chain these methods after create()]
- maxStackSize(size)
- displayName(name)
- unstackable()
- maxDamage(damage)
- burnTime(ticks)
- containerItem(item_id)
- rarity('rarity')
- tool(type, level)
- glow(true/false)
- tooltip(text...)
- group('group_id')
- color(index, colorHex)
- texture(customTexturePath)
- parentModel(customParentModel)
- food(foodBuilder => ...)
Methods available if you use 'sword', 'pickaxe', 'axe', 'shovel' or 'hoe' type:
- tier('toolTier')
- modifyTier(tier => ...) // Same syntax as custom tool tier, see below
- attackDamageBaseline(damage) // You only want to modify this if you are creating a custom weapon such as Spear, Battleaxe, etc.
- attackDamageBonus(damage)
- speedBaseline(speed) // Same as attackDamageBaseline, only modify for custom weapon types
- speed(speed)
Valid tool tiers:
- wood
- stone
- iron
- gold
- diamond
- netherite
Methods available if you use 'helmet', 'chestplate', 'leggings' or 'boots' type:
- tier('armorTier')
- modifyTier(tier => ...) // Same syntax as custom armor tier, see below
Valid armor tiers:
- leather
- chainmail
- iron
- gold
- diamond
- turtle
- netherite
Valid group/creative tab IDs:
- search
- buildingBlocks
- decorations
- redstone
- transportation
- misc
- food
- tools
- combat
- brewing
Creating custom tool and armor tiers
All values are optional and by default are based on iron tier
onEvent('item.registry.tool_tiers', event => {
event.add('tier_id', tier => {
tier.uses = 250
tier.speed = 6.0
tier.attackDamageBonus = 2.0
tier.level = 2
tier.enchantmentValue = 14
tier.repairIngredient = '#forge:ingots/iron'
})
})
onEvent('item.registry.armor_tiers', event => {
// Slot indicies are [FEET, LEGS, BODY, HEAD]
event.add('tier_id', tier => {
tier.durabilityMultiplier = 15 // Each slot will be multiplied with [13, 15, 16, 11]
tier.slotProtections = [2, 5, 6, 2]
tier.enchantmentValue = 9
tier.equipSound = 'minecraft:item.armor.equip_iron'
tier.repairIngredient = '#forge:ingots/iron'
tier.toughness = 0.0 // diamond has 2.0, netherite 3.0
tier.knockbackResistance = 0.0
})
})
Custom Foods
TheThese valuesmethods are each optional, and you may include as many or as few as you like.
onEvent('item.registry', event => {
event.create('magic_steak').food(food => {
food
.hunger(6)
.saturation(6)//This value does not directly translate to saturationssaturation points gained
//The real value can be assumed to be:
//min(hunger * saturation * 2 + saturation, foodAmountAfterEating)
.effect('speed', 600, 0, 1)
.removeEffect('poison')
.alwaysEdible()//Like golden apples
.fastToEat()//Like dried kelp
.meat()//Dogs are willing to eat it
.eaten(ctx => {//runs code aponupon consumtionconsumption
ctx.player.tell('Yummy Yummy!')
//If you want to modify this code then you need to restart the game.
//HoweverHowever, if you make this code call a global startup function
//and place the function *outside* of an 'onEvent'
//then you may use the command:
// /kubejs reload startup_scripts
//to reload the function instantlyinstantly.
})
})
})