Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function createMobTag(tag_json){
- var isListTag = Array.isArray(tag_json);
- var tag = isListTag ? new NBT.ListTag() : new NBT.CompoundTag();
- for (var key in tag_json) {
- if(isListTag) key = Number(key);
- var _data = tag_json[key];
- switch (_data.type) {
- case 1:
- tag.putByte(key, _data.value);
- Logger.Log(key + " : " + _data.type + " : " + JSON.stringify(_data.value));
- break;
- case 2:
- tag.putShort(key, _data.value);
- Logger.Log(key + " : " + _data.type + " : " + JSON.stringify(_data.value));
- break;
- case 3:
- tag.putInt(key, _data.value);
- Logger.Log(key + " : " + _data.type + " : " + JSON.stringify(_data.value));
- break;
- case 4:
- tag.putInt64(key, _data.value);
- Logger.Log(key + " : " + _data.type + " : " + JSON.stringify(_data.value));
- break;
- case 5:
- tag.putFloat(key, _data.value);
- Logger.Log(key + " : " + _data.type + " : " + JSON.stringify(_data.value));
- break;
- case 6:
- tag.putDouble(key, _data.value);
- Logger.Log(key + " : " + _data.type + " : " + JSON.stringify(_data.value));
- break;
- case 8:
- tag.putString(key, _data.value);
- Logger.Log(key + " : " + _data.type + " : " + JSON.stringify(_data.value));
- break;
- case 9:
- var newTag = createMobTag(_data.value);
- Logger.Log(key + " : " + _data.type + " : " + JSON.stringify(newTag.toScriptable()));
- tag.putListTag(key, newTag);
- break;
- case 10:
- var newTag = createMobTag(_data.value);
- Logger.Log(key + " : " + _data.type + " : " + JSON.stringify(newTag.toScriptable()));
- tag.putCompoundTag(key, newTag);
- break;
- }
- }
- return tag;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement