Skip to content
cubex2 edited this page Mar 19, 2018 · 15 revisions

All Items

Some attributes are used by all types of items:

{
  "id" : "myitem",
  "model" : "mymod:myitemmodel",
  "creativeTab" : "tools",
  "information" : ["First line", "Second line"],
  "maxDamage": 9,
  "tint": "red",
  "burnTime": 100
}
  • id: This is the unique id of the item. This is used to reference the item in recipes or in the lang file. This has to be all lowercase and must not contain spaces. It only has to be unique in your mod. If your mod id is mymod and the item id is myitem, you reference the item with mymod:myitem.

  • model: This defines the model file that is being used. In the example above the file can be located in assets/mymod/models/item/myitemmodel.json or assets/mymod/blockstates/myitemmodel.json. You can also use the model of another mod or minecraft itself. Supports metadata subtypes. Default value is "[modid]:[itemid]".

  • creativeTab: This defines the creative tab that the item appears in. Omit to make it not appear in any tab. Supports metadata subtypes.

  • information: This defines additional lines of information below the name of the item in the inventory. Supports metadata subtypes.

  • maxDamage: This defines if the item is damageable and by what amount it can be damaged. If using this, you can't use metadata subtypes for this item.

  • tint: Adds a tint to the item. This is a color. Supports metadata subtypes.

  • burnTime: Defines the number of ticks that the item provides fuel for a furnace. -1 lets the furnace decide on this. Supports metadata subtypes. Default value is -1.

Metadata Subtypes

Some item types support metadata subtypes. That means the item can have different models, names or other things depending on their metadata value. For example dye is an example for this: each color is a metadata subtype of the same item. If an item type supports metadata subtypes, you can enable it by providing the subtypes attribute:

{
  "subtypes" : [ 0, 1, 5 ]
}

This will make the item have subtypes for metadata values 0, 1 and 5. You should always have a 0 in their.

You can now define attribute values for each of those metadata values provided that the attribute is supporting it:

{
  "model" : {
    "0" : "mymod:myitem_0",
    "1" : "mymod:myitem_1",
    "5" : "mymod:myitem_5"
  }
}

You can still define the attribute like this:

{
  "model" : "mymod:myitem"
}

This will set the value for all subtypes.

Lang File

The lang files are located in assets/themodid/lang.

The lang file entry for an item without subtypes looks like this:

item.themodid.theitemid.name=The Localized Name

And for an item with subtypes:

item.themodid.theitemid.0.name=Subtype 0
item.themodid.theitemid.1.name=Subtype 1
item.themodid.theitemid.5.name=Subtype 5

Simple

Type name: item:simple

This item has no special functionality, like sticks or coal. It supports metadata subtypes.

{
  "maxStack" : 32,
  "gui" : "mymod:mygui",
  "modules": [
    {
      "type": "inventory",
      "name": "inv1",
      "size": 27
    }
  ]
}
  • maxStack: This defines the maximum number of items in one stack. This has to be between 1 and 64. Supports metadata subtypes. The default value is 64.
  • gui: This is a ResourceLocation defining what gui is being opened when right-clicking with the item. Use the id of the gui together with the mod id. Supports metadata subtypes. Default is no gui.
  • modules: This is alist of item modules. These modules add functionality to the item.

Item Modules

All modules have the following attributes:

{
  "type": "inventory",
  "name": "inv1"
}
  • type: This is the type of the module. Depending on this, more attributes are available.
  • name: This is the name of the module. It has to be unique in the item only. This is used to reference the module, for example in a gui file.

Inventory

Type name: inventory

This module adds a simple inventory to the item. It has the following attributes:

{
  "size": 27
}
  • size: This defines how many slots the inventory has.

Axe, Pickaxe, Shovel, Sword

Type name: item:axe, item:pickaxe, item:shovel, item:sword

These items act like their vanilla equivalents. They do not support metadata subtypes. All of them has the same set of attributes.

{
  "material" : "iron",
  "damage" : 3.5,
  "attackSpeed" : 4.7,
  "durability" : 750
}
  • material: This defines the material of the tool, which is responsible for mining speed, durability, damage and attack speed. Minecraft materials are wood, stone, iron, diamond and gold.
  • damage: This defines the damage against entities. If omitted, the materials damage will be used.
  • attackSpeed: This defines the attack speed. If omitted, the materials attack speed will be used.
  • durability: This defines the number of uses before the tool breaks. If omitted, the materials durability will be used.

Food

Type name: item:food

As the name suggests, this item type is for food. It supports metadata subtypes.

{
  "maxStack" : 32,
  "healAmount": 4,
  "saturation" : 1.2,
  "alwaysEdible": true,
  "potionEffect" : {
    "id" : "minecraft:speed",
    "duration" : 120
  },
  "potionEffectProbability" : 0.5,
  "isWolfFood" : false,
  "result": "minecraft:glass_bottle",
  "useAction": "eat"
}
  • maxStack: This defines the maximum number of items in one stack. This has to be between 1 and 64. Supports metadata subtypes. The default value is 64.
  • healAmount: The amount the item heals the player. Supports metadata subtypes. The default value is 2.
  • saturation: The amount of saturation that this food provides. The default value is 0.6. Supports metadata subtypes.
  • alwaysEdible: This defines whether the food can be eaten even if the player has a filled food bar. The default value is false. Supports metadata subtypes.
  • potionEffect: This is a PotionEffect that defines what effect is being added to the player. Omit if no effect should be added. Supports metadata subtypes.
  • potionEffectProbability: This defines the probability that the potion effect is being added to the player. 0.5 means a 50% chance, 1.0 means it is being added everytime. The default value is 1.0. Supports metadata subtypes.
  • isWolfFood: This defines whether wolves like this food. The default value is false.
  • result: This is a ItemStack that, if defined, sets the item that is returned to the inventory when the food has been eaten. Supports metadata subtypes.
  • useAction: This is either eat or drink and defines whether the player eats or drinks this food. Supports metadata subtypes.

Fluid Container

Type name: item:fluidContainer

This will create a container that can hold any fluid. It does not support metadata subtypes. It has one additional attribute:

{
  "capacity" : 1000
}
  • capacity: The capacity of the container. Default value is 1000.

To correctly use the model that dynamically uses the fluid texture, put the following model file to the blockstates folder:

{
  "forge_marker": 1,
  "variants": {
    "inventory": {
      "model": "forge:forgebucket",
      "textures": {
        "base": "cs4examplemod:items/fluid_container_base",
        "fluid": "cs4examplemod:items/fluid_container_fluid",
        "cover": "cs4examplemod:items/fluid_container_cover"
      },
      "transform": "forge:default-item",
      "custom": {
        "fluid": "water",
        "flipGas": true
      }
    }
  }
}

You only need to modify the textures. The model has 3 layers: base, fluid and cover. Base is the background. Fluid is a white-only texture where the white part is replaced with the fluid texture. Cover is rendered on top of the base and fluid.

Shears

Type name: item:shears

This will create a shears item just like the vanilla one. It does not support metadata subtypes. It has one additional attribute:

{
  "durability" : 750
}
  • durability: This defines the number of uses before the shears breaks. If omitted, the vanilla shears durability (238) will be used.

Seeds

Type name: item:seeds

This will create an item that can place crops onto soil. It does not support metadata subtypes. It has one additional attribute:

{
  "plant" : {"block": "cs4examplemod:crops"}
}
  • plant: This is a BlockState defining the plant that is placed by the item.

Helmet, Chest, Legs, Boots

Type names: item:helmet, item:chest, item:legs, item:boots

These item types allows you to create custom armor. They do not support metadata subtypes. The following additional attributes are available:

{
  "material": "iron",
  "armorTexture": "minecraft:textures/models/armor/gold_layer_1.png"
}
  • material: The armor's material. This defines the texture, durability, damage reduction, enchantability, toughness and equip sound. This is either leather, chain, iron, gold, diamond or the id of a custom armor material (see Armor Materials). Default value is leather.
  • armorTexture: If specified, this will override the armor texture provided by material.

Clone this wiki locally