Repository navigation
Item
###addShapedRecipe
function Item.addShapedRecipe(id, count, damage, [topSquare, middleSquare, bottomSquare], [letter, itemId, itemDamage,...])
- Adds a SHAPED crafting recipe.
- If you need your crafting recipe to be in a specific shape, use this function.
-
id: The result of the recipe. -
count: The result of the recipe's count. -
damage: The result of the recipe's damage. -
[top, middle, bottom]: The rows in the crafting grid, uses letters you specified inkey. -
[letter, id, damage, ...]: The key sequence. Example:
Item.addShapedRecipe(1, 64, 0, [
" x ",
"x x",
" x "
], ["x", 2, 0])This makes a recipe which gives you 64 stone from 4 pieces of grass shaped in a diamond in the crafting grid.
If you think this looks stupid, it's actually how crafting is implemented in the game, so if you added recipes using an addon, you would have to do the same thing, but differently. (That isn't explained in the scope of this documentation.)
Anyways, the three strings that have Xes in them are like a map. They tell where the blocks should be. But what does "x" mean? Well, the game looks at the parameter key, which is the last one. According to the key, "x" means grass, with a damage of zero. Well, what if you wanted more letters than just x?
You would have to use this pattern:
["x", 2, 0, "z", 1, 0, /* ID OF SOMETHING, COUNT OF SOMETHING, DAMAGE OF SOMETHING */]
###addCraftRecipe
function Item.addCraftRecipe(id, count, damage, ingredients);
- Adds a crafting recipe.
-
id: the resulting item you get from the recipe -
count: how much of that item -
damage: the damage of that item -
ingredients: the recipe itself ([inputid, inputcount, inputdamage, ...])
Example:
Item.addCraftRecipe(256 /* id for shovel */, 1 /* only one */, 0 /* damage is zero */, [1, 1]); //gives iron shovel from stone ;)Ingredients too hard? Here is how it works. You specify this in order, repeating it again for more items.
[id, count, damage]So if you wanted the recipe to consist of one stone, you would put:
[1, 1, 0]But if you wanted the recipe to consist of one stone, one iron shove, you would put:
[1 /* id (stone) */, 1 /* how much we want */, 0 /* stone has no damage */, 256 /* id of the item (shovel) */, 1 /* how much of id we need */, 0 /* damage */]###addFurnaceRecipe
function Item.addFurnaceRecipe(inputId, outputId, outputDamage);
- Creates a furnace recipe.
-
inputId: What we put in -
outputId: What we get -
outputDamage: What we get's damage.
###getName
function Item.getName(id, damage, raw);
- No information available
###setCategory
function Item.setCategory(id, category, whatever);
- No information available
###setMaxDamage
function Item.setMaxDamage(id, maxDamage);
- No information available
###setEnchantType
function Item.setEnchantType(id, type, value)
- Allows custom items to be enchanted in the enchantment table
- id: the item ID
- type: the type of enchantments supported; one of the EnchantType.* constants
- value: how valuable are the enchantments; usually 1 (a negative or zero value disables enchantment)
- Note: this only works for custom items and blocks.
List of EnchantTypes:
- EnchantType.weapon
- EnchantType.bow
- EnchantType.hoe
- EnchantType.shears
- EnchantType.flintAndSteel
- EnchantType.axe
- EnchantType.pickaxe
- EnchantType.shovel
- EnchantType.fishingRod
- EnchantType.book
Example:
Item.setEnchantType(1200, EnchantType.weapon, 1);
Item.addCraftRecipe(id, count, damage, ingredients);
Item.addFurnaceRecipe(inputId, outputId, outputDamage);
Item.getName(id, damage, raw);
Item.setCategory(id, category, whatever);
Item.setMaxDamage(id, maxDamage);