Advertisement
BetaZavr

scripted_block _item_editor

Apr 5th, 2019
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Для Скриптового Блока: Добавляет/изменяет подписи, теги, атрибуты на предмете
  2. // For Script Block: adds/changes signatures, tags, attributes on the item
  3. // количество переменных можно увеличивать последовательно до 100 штук.
  4. var name = 'Test item', // Новое имя предемета
  5. // Подпись (текст в каждой строке) : Примеры - text_1 = '§f§oОбычный, §f§oУровень 10§r', text_2 = '§b§oКвестовый предмет§r'
  6. // При этом удаляет старые подписи!
  7. text_1 = '§f§oCommon, §f§oLevel 10§r',
  8. text_2 = '§b§oQuest item§r',
  9. text_3 = '',
  10. text_4 = '',
  11. text_6 = '',
  12. text_7 = '',
  13. text_8 = '',
  14. text_9 = '',
  15. // Атрибуты (name:имя, slot:слот, value:значение): Пример - atrb_1 = {name:'generic.attackDamage', slot:'0', value:1}
  16. // слоты: (-1)-все, 0-правая рука, 1-левая рука, 2-обувь, 3-штаны, 4-нагрудник, 5-голова
  17. atrb_1 = {name:'generic.attackDamage', slot:-1, value:7},
  18. atrb_2 = {name:'generic.movementSpeed', slot:3, value:15},
  19. atrb_3 = '',
  20. atrb_4 = '',
  21. atrb_5 = '',
  22. // Теги {type:тип, name:имя, value:значение}: Пример - tag_1 = {type:'Byte',name:'quest',value:1}
  23. tag_1 = {type:'Byte',name:'quest',value:1},
  24. tag_2 = {type:'Short',name:'test',value:1025},
  25. tag_3 = '',
  26. tag_4 = '',
  27. tag_5 = '',
  28. // урон или мета:
  29. dam = 1, // -1 если не менять метадату
  30. enchanted = true, // будет ли зачарован? false = нет; true = да (hide при этом будет установлен!)
  31. hide=false, // скрыть описание атрибутов и чар
  32. lang='en'; // язык вывода сообщений
  33. function init(event) {
  34.     event.block.setModel("variedcommodities:book");
  35.     event.block.setScale(0.75, 0.75, 0.75)
  36.     event.block.setRotation( 0, 180, 0)
  37. }
  38. function tick(event) {
  39.     var temp=[0.2,0.3,0.2];
  40.     if (Math.random()<0.5) {temp[0]=temp[0]*Math.random()} else {temp[0]=temp[0]*Math.random()*(-1)}
  41.     if (Math.random()<0.5) {temp[1]=temp[1]*Math.random()} else {temp[1]=temp[1]*Math.random()*(-1)}
  42.     if (Math.random()<0.5) {temp[2]=temp[2]*Math.random()} else {temp[2]=temp[2]*Math.random()*(-1)}
  43.     event.block.executeCommand('/particle enchantmenttable '+event.block.getX()+' '+event.block.getY()+' '+event.block.getZ()+' '+temp[0]+' '+temp[1]+' '+temp[2]+' 0.35 5');
  44. }
  45. function interact(event) {
  46.     var playerID=event.player, itemPlayer, loreArray=[], text='', temp=1, act=true;
  47.     playerID.message("-------------------------------");
  48.     if (playerID.getMainhandItem() !== null) { // правая рука
  49.         itemPlayer = playerID.getMainhandItem();
  50.     } else if (playerID.getOffhandItem() !== null) { // левая рука
  51.         itemPlayer = playerID.getOffhandItem();
  52.     } else {
  53.         if (lang=='en') {
  54.             playerID.message("§eI sign the item in your right hand. And I can also change/add tags, attributes, metadata and the effect of an enchanted item..");
  55.             playerID.message("§7Adjust this Scripted block, then RMB on me with an item in the right or left hand.");
  56.         } else {
  57.             playerID.message("§eЯ подписываю предмет в вашей правой руке. А так же могу имзменить/добавить теги, атрибуты, метадату и эффект зачареного предмета.");
  58.             playerID.message("§7Настройте этот Скриптовый блок, после чего ПКМ на меня с предметом в правой или левой руке.");
  59.         }
  60.         return;
  61.     }
  62.     if (name) { // смена имяни
  63.         itemPlayer.setCustomName(name);
  64.         if (lang=='en') {
  65.             playerID.message("§6Change item name to: §r"+itemPlayer.getDisplayName());
  66.         } else {
  67.             playerID.message("§6Изменяю имя предмета на: §r"+itemPlayer.getDisplayName());
  68.         }
  69.     }
  70.     if (dam>=0) { // мета-данные
  71.         act=false;
  72.         itemPlayer.setItemDamage(dam);
  73.         if (lang=='en') {
  74.             playerID.message("§6I change the breakdown/metadate of an item on: §r"+dam);
  75.         } else {
  76.             playerID.message("§6Изменяю поломку/метадату предмета на: §r"+dam);
  77.         }
  78.     }
  79.     if (text_1) { // если есть подписи
  80.         act=false;
  81.         if (lang=='en') {
  82.             playerID.message("§6Adding the following captions:");
  83.         } else {
  84.             playerID.message("§6Добавляю следующие подписи:");
  85.         }
  86.         for (var n=1; n<100;n++) {
  87.             try {
  88.                 if (eval('text_'+n) !== '') {temp++}
  89.             } catch (err) {break}
  90.         }
  91.         for (var s = 1; s<temp; s++) { // создать массив подписей
  92.             playerID.message('    '+s+': "'+eval('text_'+s)+'"')
  93.             if (loreArray.length) {loreArray.push(eval('text_'+s))} else {loreArray=[eval('text_'+s)]}
  94.         }
  95.         itemPlayer.setLore(loreArray); // подписать
  96.         temp=1;
  97.     }
  98.     if (atrb_1) {
  99.         act=false;
  100.         if (lang=='en') {
  101.             playerID.message("§6Adding the following attributes:");
  102.         } else {
  103.             playerID.message("§6Добавляю следующие аттрибуты:");
  104.         }
  105.         for (var n=1; n<100;n++) {
  106.             try {
  107.                 if (eval('atrb_'+n) !== '') {temp++}
  108.             } catch (err) {break}
  109.         }
  110.         for (var a = 1; a<temp; a++) {
  111.             itemPlayer.setAttribute(eval('atrb_'+a).name, eval('atrb_'+a).value, eval('atrb_'+a).slot);
  112.             if (lang=='en') {
  113.                 if (eval('atrb_'+a).slot==0) {
  114.                     text='Main Hand';
  115.                 } else if (eval('atrb_'+a).slot==1) {
  116.                     text='Off  Hand';
  117.                 } else if (eval('atrb_'+a).slot==2) {
  118.                     text='Feet';
  119.                 } else if (eval('atrb_'+a).slot==3) {
  120.                     text='Legs';
  121.                 } else if (eval('atrb_'+a).slot==4) {
  122.                     text='Chest';
  123.                 } else if (eval('atrb_'+a).slot==5) {
  124.                     text='Head';
  125.                 } else {
  126.                     text='All';
  127.                 }
  128.                 playerID.message('    §6attribute: §r'+eval('atrb_'+a).name+'§6, its value: §r'+eval('atrb_'+a).value+'§6, slot (§r'+text+'§6)');
  129.             } else {
  130.                 if (eval('atrb_'+a).slot==0) {
  131.                     text='Правя рука';
  132.                 } else if (eval('atrb_'+a).slot==1) {
  133.                     text='Левая рука';
  134.                 } else if (eval('atrb_'+a).slot==2) {
  135.                     text='Обувь';
  136.                 } else if (eval('atrb_'+a).slot==3) {
  137.                     text='Штаны';
  138.                 } else if (eval('atrb_'+a).slot==4) {
  139.                     text='Нагрудник';
  140.                 } else if (eval('atrb_'+a).slot==5) {
  141.                     text='Голова';
  142.                 } else {
  143.                     text='Любой';
  144.                 }
  145.                 playerID.message('    §6аттрибута: §r'+eval('atrb_'+a).name+'§6, его значение: §r'+eval('atrb_'+a).value+'§6, слот (§r'+text+'§6)');
  146.             }
  147.         }
  148.         temp=1;
  149.     }
  150.     if (tag_1) {
  151.         act=false;
  152.         if (lang=='en') {
  153.             playerID.message("§6Adding the following tags:");
  154.         } else {
  155.             playerID.message("§6Добавляю следующие теги:");
  156.         }
  157.         for (var n=1; n<100;n++) {
  158.             try {
  159.                 if (eval('tag_'+n) !== '') {temp++}
  160.             } catch (err) {break}
  161.         }
  162.         for (var t = 1; t<temp; t++) {
  163.             eval('itemPlayer.getItemNbt().getCompound("tag").set'+eval('tag_'+t).type+'("'+eval('tag_'+t).name+'",'+eval('tag_'+t).value+')');
  164.             if (lang=='en') {
  165.                 playerID.message('   '+eval('tag_'+t).type+' §6tag: §r'+eval('tag_'+t).name+'§6, its value: §r'+eval('itemPlayer.getItemNbt().getCompound("tag").get'+eval('tag_'+t).type+'("'+eval('tag_'+t).name+'")'));
  166.             } else {
  167.                 playerID.message('   '+eval('tag_'+t).type+' §6тег: §r'+eval('tag_'+t).name+'§6, его значение: §r'+eval('itemPlayer.getItemNbt().getCompound("tag").get'+eval('tag_'+t).type+'("'+eval('tag_'+t).name+'")'));
  168.             }
  169.         }
  170.         temp=1;
  171.     }
  172.     if (enchanted) {
  173.         act=false;
  174.         if (lang=='en') {
  175.             playerID.message("§6Add an enchantment effect..");
  176.             playerID.message("§7In fact, the item is enchanted for durability 1, and all enchant will be hidden!");
  177.         } else {
  178.             playerID.message("§6Добавляю эффект зачарованности.");
  179.             playerID.message("§7На самом деле предмет зачарован на прочность 1, и все чары будут скрыты!");
  180.         }
  181.         itemPlayer.addEnchantment("unbreaking",1); // зачаровать копию
  182.         hide=true;
  183.     }
  184.     if (hide) {
  185.         act=false;
  186.         itemPlayer.getNbt().setByte("HideFlags", 1); // скрыть чары в описании
  187.         if (!enchanted) {
  188.             if (lang=='en') {
  189.                 playerID.message('§7Hiding a inscription about enchantments.');
  190.             } else {
  191.                 playerID.message('§7Скрываю запись о зачарованиях.');
  192.             }
  193.         }
  194.     }
  195.     if (act) {
  196.         if (lang=='en') {
  197.             playerID.message("§eI sign the item in your right hand. And I can also change/add tags, attributes, metadata and the effect of an enchanted item..");
  198.             playerID.message("§7Adjust this Scripted block, then RMB on me with an item in the right or left hand.");
  199.         } else {
  200.             playerID.message("§eЯ подписываю предмет в вашей правой руке. А так же могу имзменить/добавить теги, атрибуты, метадату и эффект зачареного предмета.");
  201.             playerID.message("§7Настройте этот Скриптовый блок, после чего ПКМ на меня с предметом в правой или левой руке.");
  202.         }
  203.     }
  204. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement