73 lines
1.8 KiB
Markdown
73 lines
1.8 KiB
Markdown
# IScriptFactory.vector4
|
|
|
|
[← IScriptFactory](index.md) · [← Master](../../wiki.md)
|
|
|
|
Parça 3/11 · [önceki](vector4-2.md) · [sonraki](vector4-4.md)
|
|
|
|
Read carefully the description of createCompoundFromJS(Object) for information about JS to NBT object conversion limitations!
|
|
|
|
var list = mappet.createListFromJS([1, 2, 3, 4, 5, 6]);
|
|
|
|
// [1,2,3,4,5,6]
|
|
c.send(list.stringify());
|
|
|
|
|
|
createItemNBT
|
|
|
|
default IScriptItemStack createItemNBT(java.lang.String nbt)
|
|
|
|
Create an item stack out of string NBT.
|
|
|
|
var item = mappet.createItemNBT("{id:\"minecraft:enchanted_book\",Count:1b,tag:{StoredEnchantments:[{lvl:4s,id:4s}]},Damage:0s}");
|
|
|
|
// It will output "minecraft:enchanted_book"
|
|
c.send(item.getItem().getId());
|
|
|
|
|
|
Returns:
|
|
an item stack from the string NBT data, or an empty item stack if the data doesn't have a valid reference to an existing
|
|
item
|
|
|
|
createItem
|
|
|
|
IScriptItemStack createItem(INBTCompound compound)
|
|
|
|
Create an item stack out of string NBT.
|
|
|
|
var tag = mappet.createCompound("{id:\"minecraft:diamond_hoe\",Count:1b}");
|
|
var item = mappet.createItemNBT(tag);
|
|
|
|
// {id:"minecraft:diamond_hoe",Count:1b,Damage:0s}
|
|
c.send(item.serialize());
|
|
|
|
|
|
Returns:
|
|
an item stack from the NBT data, or an empty item stack if the data doesn't have a valid reference to an existing item
|
|
|
|
createItem
|
|
|
|
default IScriptItemStack createItem(java.lang.String itemId)
|
|
|
|
Create an item stack with item ID.
|
|
|
|
var item = mappet.createItem("minecraft:diamond");
|
|
|
|
// {id:"minecraft:diamond",Count:1b,Damage:0s}
|
|
c.send(item.serialize());
|
|
|
|
|
|
Returns:
|
|
an item stack with an item specified by ID, or an empty item stack if the block doesn't exist
|
|
|
|
createItem
|
|
|
|
default IScriptItemStack createItem(java.lang.String itemId,
|
|
int count)
|
|
|
|
Create an item stack with item ID, count
|
|
|
|
var item = mappet.createItem("minecraft:diamond", 64);
|
|
|
|
|
|
|