Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Для Скриптового Блока: Добавляет/изменяет подписи, теги, атрибуты на предмете
- // For Script Block: adds/changes signatures, tags, attributes on the item
- // количество переменных можно увеличивать последовательно до 100 штук.
- var name = 'Test item', // Новое имя предемета
- // Подпись (текст в каждой строке) : Примеры - text_1 = '§f§oОбычный, §f§oУровень 10§r', text_2 = '§b§oКвестовый предмет§r'
- // При этом удаляет старые подписи!
- text_1 = '§f§oCommon, §f§oLevel 10§r',
- text_2 = '§b§oQuest item§r',
- text_3 = '',
- text_4 = '',
- text_6 = '',
- text_7 = '',
- text_8 = '',
- text_9 = '',
- // Атрибуты (name:имя, slot:слот, value:значение): Пример - atrb_1 = {name:'generic.attackDamage', slot:'0', value:1}
- // слоты: (-1)-все, 0-правая рука, 1-левая рука, 2-обувь, 3-штаны, 4-нагрудник, 5-голова
- atrb_1 = {name:'generic.attackDamage', slot:-1, value:7},
- atrb_2 = {name:'generic.movementSpeed', slot:3, value:15},
- atrb_3 = '',
- atrb_4 = '',
- atrb_5 = '',
- // Теги {type:тип, name:имя, value:значение}: Пример - tag_1 = {type:'Byte',name:'quest',value:1}
- tag_1 = {type:'Byte',name:'quest',value:1},
- tag_2 = {type:'Short',name:'test',value:1025},
- tag_3 = '',
- tag_4 = '',
- tag_5 = '',
- // урон или мета:
- dam = 1, // -1 если не менять метадату
- enchanted = true, // будет ли зачарован? false = нет; true = да (hide при этом будет установлен!)
- hide=false, // скрыть описание атрибутов и чар
- lang='en'; // язык вывода сообщений
- function init(event) {
- event.block.setModel("variedcommodities:book");
- event.block.setScale(0.75, 0.75, 0.75)
- event.block.setRotation( 0, 180, 0)
- }
- function tick(event) {
- var temp=[0.2,0.3,0.2];
- if (Math.random()<0.5) {temp[0]=temp[0]*Math.random()} else {temp[0]=temp[0]*Math.random()*(-1)}
- if (Math.random()<0.5) {temp[1]=temp[1]*Math.random()} else {temp[1]=temp[1]*Math.random()*(-1)}
- if (Math.random()<0.5) {temp[2]=temp[2]*Math.random()} else {temp[2]=temp[2]*Math.random()*(-1)}
- event.block.executeCommand('/particle enchantmenttable '+event.block.getX()+' '+event.block.getY()+' '+event.block.getZ()+' '+temp[0]+' '+temp[1]+' '+temp[2]+' 0.35 5');
- }
- function interact(event) {
- var playerID=event.player, itemPlayer, loreArray=[], text='', temp=1, act=true;
- playerID.message("-------------------------------");
- if (playerID.getMainhandItem() !== null) { // правая рука
- itemPlayer = playerID.getMainhandItem();
- } else if (playerID.getOffhandItem() !== null) { // левая рука
- itemPlayer = playerID.getOffhandItem();
- } else {
- if (lang=='en') {
- 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..");
- playerID.message("§7Adjust this Scripted block, then RMB on me with an item in the right or left hand.");
- } else {
- playerID.message("§eЯ подписываю предмет в вашей правой руке. А так же могу имзменить/добавить теги, атрибуты, метадату и эффект зачареного предмета.");
- playerID.message("§7Настройте этот Скриптовый блок, после чего ПКМ на меня с предметом в правой или левой руке.");
- }
- return;
- }
- if (name) { // смена имяни
- itemPlayer.setCustomName(name);
- if (lang=='en') {
- playerID.message("§6Change item name to: §r"+itemPlayer.getDisplayName());
- } else {
- playerID.message("§6Изменяю имя предмета на: §r"+itemPlayer.getDisplayName());
- }
- }
- if (dam>=0) { // мета-данные
- act=false;
- itemPlayer.setItemDamage(dam);
- if (lang=='en') {
- playerID.message("§6I change the breakdown/metadate of an item on: §r"+dam);
- } else {
- playerID.message("§6Изменяю поломку/метадату предмета на: §r"+dam);
- }
- }
- if (text_1) { // если есть подписи
- act=false;
- if (lang=='en') {
- playerID.message("§6Adding the following captions:");
- } else {
- playerID.message("§6Добавляю следующие подписи:");
- }
- for (var n=1; n<100;n++) {
- try {
- if (eval('text_'+n) !== '') {temp++}
- } catch (err) {break}
- }
- for (var s = 1; s<temp; s++) { // создать массив подписей
- playerID.message(' '+s+': "'+eval('text_'+s)+'"')
- if (loreArray.length) {loreArray.push(eval('text_'+s))} else {loreArray=[eval('text_'+s)]}
- }
- itemPlayer.setLore(loreArray); // подписать
- temp=1;
- }
- if (atrb_1) {
- act=false;
- if (lang=='en') {
- playerID.message("§6Adding the following attributes:");
- } else {
- playerID.message("§6Добавляю следующие аттрибуты:");
- }
- for (var n=1; n<100;n++) {
- try {
- if (eval('atrb_'+n) !== '') {temp++}
- } catch (err) {break}
- }
- for (var a = 1; a<temp; a++) {
- itemPlayer.setAttribute(eval('atrb_'+a).name, eval('atrb_'+a).value, eval('atrb_'+a).slot);
- if (lang=='en') {
- if (eval('atrb_'+a).slot==0) {
- text='Main Hand';
- } else if (eval('atrb_'+a).slot==1) {
- text='Off Hand';
- } else if (eval('atrb_'+a).slot==2) {
- text='Feet';
- } else if (eval('atrb_'+a).slot==3) {
- text='Legs';
- } else if (eval('atrb_'+a).slot==4) {
- text='Chest';
- } else if (eval('atrb_'+a).slot==5) {
- text='Head';
- } else {
- text='All';
- }
- playerID.message(' §6attribute: §r'+eval('atrb_'+a).name+'§6, its value: §r'+eval('atrb_'+a).value+'§6, slot (§r'+text+'§6)');
- } else {
- if (eval('atrb_'+a).slot==0) {
- text='Правя рука';
- } else if (eval('atrb_'+a).slot==1) {
- text='Левая рука';
- } else if (eval('atrb_'+a).slot==2) {
- text='Обувь';
- } else if (eval('atrb_'+a).slot==3) {
- text='Штаны';
- } else if (eval('atrb_'+a).slot==4) {
- text='Нагрудник';
- } else if (eval('atrb_'+a).slot==5) {
- text='Голова';
- } else {
- text='Любой';
- }
- playerID.message(' §6аттрибута: §r'+eval('atrb_'+a).name+'§6, его значение: §r'+eval('atrb_'+a).value+'§6, слот (§r'+text+'§6)');
- }
- }
- temp=1;
- }
- if (tag_1) {
- act=false;
- if (lang=='en') {
- playerID.message("§6Adding the following tags:");
- } else {
- playerID.message("§6Добавляю следующие теги:");
- }
- for (var n=1; n<100;n++) {
- try {
- if (eval('tag_'+n) !== '') {temp++}
- } catch (err) {break}
- }
- for (var t = 1; t<temp; t++) {
- eval('itemPlayer.getItemNbt().getCompound("tag").set'+eval('tag_'+t).type+'("'+eval('tag_'+t).name+'",'+eval('tag_'+t).value+')');
- if (lang=='en') {
- 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+'")'));
- } else {
- 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+'")'));
- }
- }
- temp=1;
- }
- if (enchanted) {
- act=false;
- if (lang=='en') {
- playerID.message("§6Add an enchantment effect..");
- playerID.message("§7In fact, the item is enchanted for durability 1, and all enchant will be hidden!");
- } else {
- playerID.message("§6Добавляю эффект зачарованности.");
- playerID.message("§7На самом деле предмет зачарован на прочность 1, и все чары будут скрыты!");
- }
- itemPlayer.addEnchantment("unbreaking",1); // зачаровать копию
- hide=true;
- }
- if (hide) {
- act=false;
- itemPlayer.getNbt().setByte("HideFlags", 1); // скрыть чары в описании
- if (!enchanted) {
- if (lang=='en') {
- playerID.message('§7Hiding a inscription about enchantments.');
- } else {
- playerID.message('§7Скрываю запись о зачарованиях.');
- }
- }
- }
- if (act) {
- if (lang=='en') {
- 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..");
- playerID.message("§7Adjust this Scripted block, then RMB on me with an item in the right or left hand.");
- } else {
- playerID.message("§eЯ подписываю предмет в вашей правой руке. А так же могу имзменить/добавить теги, атрибуты, метадату и эффект зачареного предмета.");
- playerID.message("§7Настройте этот Скриптовый блок, после чего ПКМ на меня с предметом в правой или левой руке.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement