RecipeTELib — различия между версиями

м
м
Строка 40: Строка 40:
 
=== Верстак ===
 
=== Верстак ===
  
 +
<div class="mw-parser-output">
 
==== Создание верстака ====
 
==== Создание верстака ====
 +
 +
Для начала создаем блок
 +
<pre><font style="font-family:Consolas, monospace; font-size:9,828pt; line-height:15px"><font class="fctbStyle5">IDRegistry</font><font class="fctbStyle5Style7">.</font><font class="fctbStyle7">genBlockID</font><font class="fctbStyle5Style7">(</font><font class="fctbStyle2Style5">"</font><font class="fctbStyle2">Workbench_Grid</font><font class="fctbStyle2Style5">"</font><font class="fctbStyle5">);
 +
Block</font><font class="fctbStyle5Style7">.</font><font class="fctbStyle7">createBlock</font><font class="fctbStyle5Style7">(</font><font class="fctbStyle2Style5">"</font><font class="fctbStyle2">Workbench_Grid</font><font class="fctbStyle2Style5">"</font><font class="fctbStyle5">, [{
 +
  </font> <font class="fctbStyle7">name</font><font class="fctbStyle5Style7">:</font> <font class="fctbStyle2Style5">"</font><font class="fctbStyle2">Workbench</font> <font class="fctbStyle2">Grid</font><font class="fctbStyle2Style5">"</font><font class="fctbStyle5"><syntaxhighlight lang="JavaScript">,
 +
    </syntaxhighlight></font><font class="fctbNone">texture</font><font class="fctbStyle5">: [
 +
        [</font><font class="fctbStyle2Style5">"</font><font class="fctbStyle2">work_table_bottom</font><font class="fctbStyle2Style5">"</font><font class="fctbStyle5">, </font><font class="fctbStyle3">0</font><font class="fctbStyle5">], </font><font class="fctbStyle1Style5">// </font><font class="fctbStyle1">bottom</font><font class="fctbStyle5">
 +
        [</font><font class="fctbStyle2Style5">"</font><font class="fctbStyle2">work_table_top</font><font class="fctbStyle2Style5">"</font><font class="fctbStyle5">, </font><font class="fctbStyle3">0</font><font class="fctbStyle5">], </font><font class="fctbStyle1Style5">// </font><font class="fctbStyle1">top</font><font class="fctbStyle5">
 +
        [</font><font class="fctbStyle2Style5">"</font><font class="fctbStyle2">work_table_side</font><font class="fctbStyle2Style5">"</font><font class="fctbStyle5">, </font><font class="fctbStyle3">0</font><font class="fctbStyle5">], </font><font class="fctbStyle1Style5">// </font><font class="fctbStyle1">back</font><font class="fctbStyle5">
 +
        [</font><font class="fctbStyle2Style5">"</font><font class="fctbStyle2">work_table_side</font><font class="fctbStyle2Style5">"</font><font class="fctbStyle5">,</font> <font class="fctbStyle3Style7">1</font><font class="fctbStyle5Style7">]</font><font class="fctbStyle5">, </font><font class="fctbStyle1Style5">// </font><font class="fctbStyle1">front</font><font class="fctbStyle5">
 +
        [</font><font class="fctbStyle2Style5">"</font><font class="fctbStyle2">work_table_side</font><font class="fctbStyle2Style5">"</font><font class="fctbStyle5">, </font><font class="fctbStyle3">0</font><font class="fctbStyle5">], </font><font class="fctbStyle1Style5">// </font><font class="fctbStyle1">left</font><font class="fctbStyle5">
 +
        [</font><font class="fctbStyle2Style5">"</font><font class="fctbStyle2">work_table_side</font><font class="fctbStyle2Style5">"</font><font class="fctbStyle5">, </font><font class="fctbStyle3">0</font><font class="fctbStyle5">]  </font><font class="fctbStyle1Style5">// </font><font class="fctbStyle1">right</font><font class="fctbStyle5">
 +
    ],
 +
    </font><font class="fctbNone">inCreative</font><font class="fctbStyle5">: </font><font class="fctbStyle4">true</font><font class="fctbStyle5">
 +
}]);</font></font>
 +
</pre>
 +
 +
Затем создаем наш интерфейс.<br/> '''!ВАЖНО!:&nbsp;'''Слоты, в которые нужно ложить предмет нужна ОБЯЗАТЕЛЬНО называть "'''''inputSlot'''''"+ '''порядковое число''' слота, начиная с нуля. Слот результата должен иметь название "'''''outputSlot'''''", так же стоит задавть '''''isValid''''' для outputSlot как&nbsp;'''''RecipeTE.outputSlotValid'''''
 +
<syntaxhighlight lang="JavaScript">var Workbench_Grid = new UI.StandartWindow({
 +
    standart: {
 +
        header: {text: {text: "Workbench Grid 4x4"}},
 +
        inventory: {standart:true},
 +
        background: {standart: true}
 +
    },
 +
    drawing: [{
 +
        type: "bitmap",
 +
        bitmap: "arrow",
 +
        x: 600,
 +
        y: 170, scale: 4
 +
    }],
 +
    elements:{
 +
        "inputSlot0":{x:350, y:80, type:"slot"},
 +
        "inputSlot1":{x:410, y:80, type:"slot"},
 +
        "inputSlot2":{x:470, y:80, type:"slot"},
 +
        "inputSlot3":{x:530, y:80, type:"slot"},
 +
 +
        "inputSlot4":{x:350, y:140, type:"slot"},
 +
        "inputSlot5":{x:410, y:140, type:"slot"},
 +
        "inputSlot6":{x:470, y:140, type:"slot"},
 +
        "inputSlot7":{x:530, y:140, type:"slot"},
 +
 +
        "inputSlot8":{x:350, y:200, type:"slot"},
 +
        "inputSlot9":{x:410, y:200, type:"slot"},
 +
        "inputSlot10":{x:470, y:200, type:"slot"},
 +
        "inputSlot11":{x:530, y:200, type:"slot"},
 +
 +
        "inputSlot12":{x:350, y:260, type:"slot"},
 +
        "inputSlot13":{x:410, y:260, type:"slot"},
 +
        "inputSlot14":{x:470, y:260, type:"slot"},
 +
        "inputSlot15":{x:530, y:260, type:"slot"},
 +
 +
        "outputSlot":{x:698, y:170, type:"slot", isValid:RecipeTE.outputSlotValid }
 +
    }
 +
});</syntaxhighlight>
 +
 +
Затем регистрируем наш верстак, есть два способа:
 +
 +
*'''''RecipeTE.registerGridCraftTable(description);'''''
 +
<pre><font style="font-family:Consolas, monospace; font-size:9,828pt; line-height:15px"><font class="fctbNone">RecipeTE</font><font class="fctbStyle5">.</font><font class="fctbNone">registerGridCraftTable</font><font class="fctbStyle5">({
 +
  </font> <font class="fctbStyle7">name</font><font class="fctbStyle5Style7">:</font><font class="fctbStyle2Style5">"</font><font class="fctbStyle2">Workbench_Grid</font><font class="fctbStyle2Style5">"</font><font class="fctbStyle5">,
 +
    </font><font class="fctbNone">rows</font><font class="fctbStyle5Style7">:</font><font class="fctbStyle3Style7">4</font><font class="fctbStyle5Style7">,
 +
&nbsp;  </font> <font class="fctbNone">cols</font><font class="fctbStyle5Style7">:</font><font class="fctbStyle3Style7">4</font><font class="fctbStyle5"><syntaxhighlight lang="JavaScript">
 +
});</syntaxhighlight></font></font></pre>
 +
 +
*​​'''''RecipeTE.registerGridCraftTable(name, columns, rows);'''''<i>'''​​​​​​​'''</i>
 +
<syntaxhighlight lang="JavaScript">RecipeTE.registerGridCraftTable("Workbench_Grid", 4, 4);</syntaxhighlight>
 +
 +
&nbsp;
 +
</div>
  
 
==== Создание рецептов для верстака ====
 
==== Создание рецептов для верстака ====

Версия 22:37, 21 июня 2019

RecipeTELib - библиотека, упрощающая создание верстаков и печей.

Условия использования

  • Запрещено распространение на сторонних источниках без указания ссылки на официальное сообщество
  • Запрещено изменение кода библиотеки
  • Запрещено явное копирование кода в другие библиотеки или моды 

Используя данный продукт вы автоматически соглашаетесь с этими правилами

Документация

Инициализация

Импортируйте библиотеку.

IMPORT("RecipeTileEntityLib")

Верстак

Создание верстака

Для начала создаем блок

<font style="font-family:Consolas, monospace; font-size:9,828pt; line-height:15px"><font class="fctbStyle5">IDRegistry</font><font class="fctbStyle5Style7">.</font><font class="fctbStyle7">genBlockID</font><font class="fctbStyle5Style7">(</font><font class="fctbStyle2Style5">"</font><font class="fctbStyle2">Workbench_Grid</font><font class="fctbStyle2Style5">"</font><font class="fctbStyle5">);
Block</font><font class="fctbStyle5Style7">.</font><font class="fctbStyle7">createBlock</font><font class="fctbStyle5Style7">(</font><font class="fctbStyle2Style5">"</font><font class="fctbStyle2">Workbench_Grid</font><font class="fctbStyle2Style5">"</font><font class="fctbStyle5">, [{
   </font> <font class="fctbStyle7">name</font><font class="fctbStyle5Style7">:</font> <font class="fctbStyle2Style5">"</font><font class="fctbStyle2">Workbench</font> <font class="fctbStyle2">Grid</font><font class="fctbStyle2Style5">"</font><font class="fctbStyle5"><syntaxhighlight lang="JavaScript">, 
    </syntaxhighlight></font><font class="fctbNone">texture</font><font class="fctbStyle5">: [
        [</font><font class="fctbStyle2Style5">"</font><font class="fctbStyle2">work_table_bottom</font><font class="fctbStyle2Style5">"</font><font class="fctbStyle5">, </font><font class="fctbStyle3">0</font><font class="fctbStyle5">], </font><font class="fctbStyle1Style5">// </font><font class="fctbStyle1">bottom</font><font class="fctbStyle5">
        [</font><font class="fctbStyle2Style5">"</font><font class="fctbStyle2">work_table_top</font><font class="fctbStyle2Style5">"</font><font class="fctbStyle5">, </font><font class="fctbStyle3">0</font><font class="fctbStyle5">], </font><font class="fctbStyle1Style5">// </font><font class="fctbStyle1">top</font><font class="fctbStyle5">
        [</font><font class="fctbStyle2Style5">"</font><font class="fctbStyle2">work_table_side</font><font class="fctbStyle2Style5">"</font><font class="fctbStyle5">, </font><font class="fctbStyle3">0</font><font class="fctbStyle5">], </font><font class="fctbStyle1Style5">// </font><font class="fctbStyle1">back</font><font class="fctbStyle5">
        [</font><font class="fctbStyle2Style5">"</font><font class="fctbStyle2">work_table_side</font><font class="fctbStyle2Style5">"</font><font class="fctbStyle5">,</font> <font class="fctbStyle3Style7">1</font><font class="fctbStyle5Style7">]</font><font class="fctbStyle5">, </font><font class="fctbStyle1Style5">// </font><font class="fctbStyle1">front</font><font class="fctbStyle5">
        [</font><font class="fctbStyle2Style5">"</font><font class="fctbStyle2">work_table_side</font><font class="fctbStyle2Style5">"</font><font class="fctbStyle5">, </font><font class="fctbStyle3">0</font><font class="fctbStyle5">], </font><font class="fctbStyle1Style5">// </font><font class="fctbStyle1">left</font><font class="fctbStyle5">
        [</font><font class="fctbStyle2Style5">"</font><font class="fctbStyle2">work_table_side</font><font class="fctbStyle2Style5">"</font><font class="fctbStyle5">, </font><font class="fctbStyle3">0</font><font class="fctbStyle5">]  </font><font class="fctbStyle1Style5">// </font><font class="fctbStyle1">right</font><font class="fctbStyle5">
    ], 
    </font><font class="fctbNone">inCreative</font><font class="fctbStyle5">: </font><font class="fctbStyle4">true</font><font class="fctbStyle5"> 
}]);</font></font>

Затем создаем наш интерфейс.
!ВАЖНО!: Слоты, в которые нужно ложить предмет нужна ОБЯЗАТЕЛЬНО называть "inputSlot"+ порядковое число слота, начиная с нуля. Слот результата должен иметь название "outputSlot", так же стоит задавть isValid для outputSlot как RecipeTE.outputSlotValid

var Workbench_Grid = new UI.StandartWindow({
    standart: {
        header: {text: {text: "Workbench Grid 4x4"}},
        inventory: {standart:true},
        background: {standart: true}
    },
    drawing: [{
        type: "bitmap",
        bitmap: "arrow",
        x: 600,
        y: 170, scale: 4
    }],
    elements:{
        "inputSlot0":{x:350, y:80, type:"slot"},
        "inputSlot1":{x:410, y:80, type:"slot"},
        "inputSlot2":{x:470, y:80, type:"slot"},
        "inputSlot3":{x:530, y:80, type:"slot"},

        "inputSlot4":{x:350, y:140, type:"slot"},
        "inputSlot5":{x:410, y:140, type:"slot"},
        "inputSlot6":{x:470, y:140, type:"slot"},
        "inputSlot7":{x:530, y:140, type:"slot"},

        "inputSlot8":{x:350, y:200, type:"slot"},
        "inputSlot9":{x:410, y:200, type:"slot"},
        "inputSlot10":{x:470, y:200, type:"slot"},
        "inputSlot11":{x:530, y:200, type:"slot"},

        "inputSlot12":{x:350, y:260, type:"slot"},
        "inputSlot13":{x:410, y:260, type:"slot"},
        "inputSlot14":{x:470, y:260, type:"slot"},
        "inputSlot15":{x:530, y:260, type:"slot"},

        "outputSlot":{x:698, y:170, type:"slot", isValid:RecipeTE.outputSlotValid }
    }
});

Затем регистрируем наш верстак, есть два способа:

  • RecipeTE.registerGridCraftTable(description);
<font style="font-family:Consolas, monospace; font-size:9,828pt; line-height:15px"><font class="fctbNone">RecipeTE</font><font class="fctbStyle5">.</font><font class="fctbNone">registerGridCraftTable</font><font class="fctbStyle5">({
   </font> <font class="fctbStyle7">name</font><font class="fctbStyle5Style7">:</font><font class="fctbStyle2Style5">"</font><font class="fctbStyle2">Workbench_Grid</font><font class="fctbStyle2Style5">"</font><font class="fctbStyle5">,
    </font><font class="fctbNone">rows</font><font class="fctbStyle5Style7">:</font><font class="fctbStyle3Style7">4</font><font class="fctbStyle5Style7">,
   </font> <font class="fctbNone">cols</font><font class="fctbStyle5Style7">:</font><font class="fctbStyle3Style7">4</font><font class="fctbStyle5"><syntaxhighlight lang="JavaScript">
});</syntaxhighlight></font></font>
  • ​​RecipeTE.registerGridCraftTable(name, columns, rows);​​​​​​​
RecipeTE.registerGridCraftTable("Workbench_Grid", 4, 4);

 

Создание рецептов для верстака

Электрическая(редстоун сигнал) печь

Создание печи

Создание рецептов для печи