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

м
м
Строка 45: Строка 45:
 
<div class="mw-parser-output">
 
<div class="mw-parser-output">
 
<div class="mw-parser-output"><div class="mw-parser-output">
 
<div class="mw-parser-output"><div class="mw-parser-output">
 +
<div class="mw-parser-output">
 
<div class="mw-parser-output">
 
<div class="mw-parser-output">
 
<div class="mw-parser-output">
 
<div class="mw-parser-output">
Строка 105: Строка 106:
  
 
*'''''RecipeTE.registerGridCraftTable(description);'''''  
 
*'''''RecipeTE.registerGridCraftTable(description);'''''  
 
&nbsp;
 
 
<syntaxhighlight lang="JavaScript">RecipeTE.registerGridCraftTable({
 
<syntaxhighlight lang="JavaScript">RecipeTE.registerGridCraftTable({
 
    name:"Workbench_Grid",
 
    name:"Workbench_Grid",
Строка 115: Строка 114:
 
*​​'''''RecipeTE.registerGridCraftTable(name, columns, rows);'''''  
 
*​​'''''RecipeTE.registerGridCraftTable(name, columns, rows);'''''  
 
<syntaxhighlight lang="JavaScript">RecipeTE.registerGridCraftTable("Workbench_Grid", 4, 4);</syntaxhighlight>
 
<syntaxhighlight lang="JavaScript">RecipeTE.registerGridCraftTable("Workbench_Grid", 4, 4);</syntaxhighlight>
Что-то</div>
+
 
 +
Теперь нам следует зарегистрировать TileEntity. В getGuiScreen мы возвращаем наше окно. В методе тика мы вызываем&nbsp;'''''RecipeTE.getTickResipes(name, TileEntity);'''''
 +
<syntaxhighlight lang="JavaScript">TileEntity.registerPrototype(BlockID["Workbench_Grid"], {
 +
    getGuiScreen: function(){
 +
        return Workbench_Grid;
 +
    },
 +
    
 +
    tick:function(){
 +
        RecipeTE.getTickResipes("Workbench_Grid", this);
 +
    }  
 +
});</syntaxhighlight>
 +
 
 +
&nbsp;
 +
</div>
  
 
==== Создание рецептов для верстака ====
 
==== Создание рецептов для верстака ====

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

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

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

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

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

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

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

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

IMPORT("RecipeTileEntityLib")

Верстак

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

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

IDRegistry.genBlockID("Workbench_Grid");
Block.createBlock("Workbench_Grid", [{
    name: "Workbench Grid", 
    texture: [
        ["work_table_bottom", 0], // bottom
        ["work_table_top", 0], // top
        ["work_table_side", 0], // back
        ["work_table_side", 1], // front
        ["work_table_side", 0], // left
        ["work_table_side", 0]  // right
    ], 
    inCreative: true 
}]);

Затем создаем наш интерфейс.
!ВАЖНО!: Слоты, в которые нужно ложить предмет нужна ОБЯЗАТЕЛЬНО называть "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);
RecipeTE.registerGridCraftTable({
    name:"Workbench_Grid",
    rows:4,
    cols:4
});
  • ​​RecipeTE.registerGridCraftTable(name, columns, rows);
RecipeTE.registerGridCraftTable("Workbench_Grid", 4, 4);

Теперь нам следует зарегистрировать TileEntity. В getGuiScreen мы возвращаем наше окно. В методе тика мы вызываем RecipeTE.getTickResipes(name, TileEntity);

TileEntity.registerPrototype(BlockID["Workbench_Grid"], {
    getGuiScreen: function(){
        return Workbench_Grid;
    },
    
    tick:function(){
        RecipeTE.getTickResipes("Workbench_Grid", this);
    }  
});

 

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

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

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

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