Files

64 lines
1.8 KiB
Markdown

# IScriptFactory.vector4
[← IScriptFactory](index.md) · [← Master](../../wiki.md)
Parça 2/11 · [önceki](vector4.md) · [sonraki](vector4-3.md)
BEWARE: when converting JS object to NBT keep in mind some limitations of the NBT format:
NBT supports multiple number storage formats (byte, short, int, long, float, double) so the converter will only be able to
convert numbers to either integer or double NBT tags, depending on how did you got the number, 42 being an integer,
and 42.0 being a double.
NBT lists support only storage of a single type at once, so if you provide an JS array like [0, 1, 2, "test", {a:1,b:2}, 4,
[0, 0, 0], 5.5] then only the the first element's type will be taken in account, and the resulted NBT list will turn out
like [0.0d, 1.0d, 2.0d, 4.0d, 5.5d]. In case with numbers if you had first integers, and somewhere in the middle in the
list you got a double, then the integer type will get converted to double!
var tag = mappet.createCompoundFromJS({id:"minecraft:diamond_hoe",Count:1});
var item = mappet.createItemNBT(tag);
// {id:"minecraft:diamond_hoe",Count:1b,Damage:0s}
c.send(item.serialize());
createList
default INBTList createList()
Create an empty NBT list.
var list = mappet.createList();
list.addInt(1);
list.addInt(2);
list.addInt(3);
list.addInt(4);
list.addInt(5);
list.addInt(6);
// [1,2,3,4,5,6]
c.send(list.stringify());
createList
INBTList createList(java.lang.String nbt)
Parse an NBT list data out of given string, if string NBT was invalid then an empty list will be returned.
var list = mappet.createList("[1, 2, 3, 4, 5, 6]");
// [1,2,3,4,5,6]
c.send(list.stringify());
createListFromJS
INBTList createListFromJS(java.lang.Object jsObject)
Turn a JS object into an NBT compound.