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

м
м
Строка 1: Строка 1:
 
<div class="mw-parser-output"><div class="mw-parser-output">'''RecipeTELib'''''&nbsp;''- библиотека, упрощающая создание верстаков и печей.</div> <div class="mw-parser-output">
 
<div class="mw-parser-output"><div class="mw-parser-output">'''RecipeTELib'''''&nbsp;''- библиотека, упрощающая создание верстаков и печей.</div> <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">
 
== Загрузка ==
 
== Загрузка ==
  
Строка 14: Строка 15:
 
Первая версия
 
Первая версия
  
 +
|-
 +
| style="text-align: center; width: 63px;" | '''GitHub'''
 +
| style="text-align: center; width: 57px;" | [https://github.com/Wolf-Team/Libraries/blob/master/RecipeTileEntityLib.js GitHub]
 +
| style="width: 362px;" | &nbsp;
 
|}
 
|}
 
+
</div> </div>
&nbsp;
 
</div>
 
  
 
== Условия использования ==
 
== Условия использования ==

Версия 23:03, 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);
    }  
});

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

Создание рецептов для верстака с сеткой происходит через метод RecipeTE.addGridRecipe(name_workbench, result, recipe, ingredients), где:

  • name_workbench - имя верстака
  • result - объект результата
    • id - ID предмета
    • count - Кол-во предмета
    • data - Дата предмета
  • recipe - Массив строк крафта
  • ingredients - объект ингредиентов
RecipeTE.addGridRecipe("Workbench_Grid", {
    id:280,
    count:1
},
[   "aa",
    "aa"
], {
    a:{
        id:5
    }
});

RecipeTE.addGridRecipe("Workbench_Grid", {
    id: 281,
    count: 1
},
[   "aaaa",
    "a  a",
    "a  a",
    "aaaa"
], {
    a: {
        id: 1,
        data:0
    }
});

 

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

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

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