80LK (обсуждение | вклад) м |
80LK (обсуждение | вклад) м |
||
(не показано 20 промежуточных версий этого же участника) | |||
Строка 1: | Строка 1: | ||
<div class="mw-parser-output"><div class="mw-parser-output">'''RecipeTELib''''' ''- библиотека, упрощающая создание верстаков и печей.</div> <div class="mw-parser-output"> | <div class="mw-parser-output"><div class="mw-parser-output">'''RecipeTELib''''' ''- библиотека, упрощающая создание верстаков и печей.</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"> | ||
+ | <div class="mw-parser-output"><div class="mw-parser-output"> | ||
== Загрузка == | == Загрузка == | ||
Строка 10: | Строка 12: | ||
|- | |- | ||
| style="text-align: center; width: 63px;" | '''1''' | | style="text-align: center; width: 63px;" | '''1''' | ||
− | | style="text-align: center; width: 57px;" | Скачать | + | | style="text-align: center; width: 57px;" | [https://vk.com/wolf___team?w=wall-80513593_2247 Скачать] |
| style="width: 362px;" | | | style="width: 362px;" | | ||
Первая версия | Первая версия | ||
+ | |- | ||
+ | | 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;" | | ||
|} | |} | ||
− | + | </div> </div> | |
− | |||
− | </div> | ||
== Условия использования == | == Условия использования == | ||
Строка 27: | Строка 31: | ||
Используя данный продукт вы автоматически соглашаетесь с этими правилами | Используя данный продукт вы автоматически соглашаетесь с этими правилами | ||
+ | <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"> | ||
+ | === Инициализация === | ||
+ | |||
+ | Импортируйте библиотеку. | ||
+ | <syntaxhighlight lang="JavaScript">IMPORT("RecipeTileEntityLib")</syntaxhighlight> | ||
</div> </div> | </div> </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"><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"> | ||
+ | ==== Создание верстака ==== | ||
+ | |||
+ | Для начала создаем блок: | ||
+ | <syntaxhighlight lang="JavaScript">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 | ||
+ | }]);</syntaxhighlight> | ||
+ | |||
+ | Затем создаем наш интерфейс: | ||
+ | <blockquote> | ||
+ | <span style="font-size:small;">'''!ВАЖНО!: '''Слоты, в которые нужно ложить предмет нужна ОБЯЗАТЕЛЬНО называть "'''''inputSlot'''''"+ '''порядковое число''' слота, начиная с нуля. Слот результата должен иметь название "'''''outputSlot'''''", так же стоит задавть '''''isValid''''' для outputSlot как '''''RecipeTE.outputSlotValid'''''</span> | ||
+ | </blockquote> <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);''''' | ||
+ | <syntaxhighlight lang="JavaScript">RecipeTE.registerGridCraftTable({ | ||
+ | name:"Workbench_Grid", | ||
+ | rows:4, | ||
+ | cols:4 | ||
+ | });</syntaxhighlight> | ||
+ | |||
+ | *'''''RecipeTE.registerGridCraftTable(name, columns, rows);''''' | ||
+ | <syntaxhighlight lang="JavaScript">RecipeTE.registerGridCraftTable("Workbench_Grid", 4, 4);</syntaxhighlight> | ||
+ | |||
+ | Теперь нам следует зарегистрировать TileEntity. В getGuiScreen мы возвращаем наше окно. В методе тика мы вызываем '''''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> | ||
+ | </div> | ||
+ | |||
+ | <div class="mw-parser-output"> | ||
+ | <div class="mw-parser-output"> | ||
+ | ==== Создание рецептов для верстака ==== | ||
+ | |||
+ | Создание рецептов для верстака с сеткой происходит через метод '''''RecipeTE.addGridRecipe(name_workbench, result, recipe, ingredients)''''', где: | ||
+ | |||
+ | *name_workbench - имя верстака | ||
+ | *result - объект результата | ||
+ | **id - ID предмета | ||
+ | **count - Кол-во предмета | ||
+ | **data - Дата предмета | ||
+ | *recipe - Массив строк крафта | ||
+ | *ingredients - объект ингредиентов | ||
+ | |||
+ | | ||
+ | <syntaxhighlight lang="JavaScript">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 | ||
+ | } | ||
+ | }); | ||
+ | </syntaxhighlight> | ||
+ | </div> | ||
+ | |||
+ | === Электрическая(редстоун сигнал) печь === | ||
+ | |||
+ | <div class="mw-parser-output"> | ||
+ | <div class="mw-parser-output"> | ||
+ | ==== Создание печи ==== | ||
+ | |||
+ | Для начала создаем блок: | ||
+ | <syntaxhighlight lang="JavaScript">IDRegistry.genBlockID("Furnace"); | ||
+ | Block.createBlockWithRotation("Furnace", [{ | ||
+ | name: "Furnace", | ||
+ | texture: [ | ||
+ | ["iron_furnace_bottom", 0], // bottom | ||
+ | ["iron_furnace_top", 0], // top | ||
+ | ["iron_furnace_side", 0], // back | ||
+ | ["iron_furnace_front", 0], // front | ||
+ | ["iron_furnace_side", 0], // left | ||
+ | ["iron_furnace_side", 0] // right | ||
+ | ], | ||
+ | inCreative: true | ||
+ | }]);</syntaxhighlight> | ||
+ | |||
+ | Затем создаем наш интерфейс: | ||
+ | <blockquote> | ||
+ | <span style="font-size:small;">'''!ВАЖНО!:''' Слоты, в которые нужно ложить предмет нужна ОБЯЗАТЕЛЬНО называть ''"'''inputSlot'''"''+ '''порядковое число '''слота, начиная с нуля. Слот результата должен иметь название "'''''outputSlot'''''", так же стоит задавть '''''isValid'''''для outputSlot как '''''RecipeTE.outputSlotValid'''''</span> | ||
+ | </blockquote> <syntaxhighlight lang="JavaScript">var Furnace = new UI.StandartWindow({ | ||
+ | standart: { | ||
+ | header: {text: {text: "Furnace"}}, | ||
+ | inventory: {standart:true}, | ||
+ | background: {standart: true} | ||
+ | }, | ||
+ | drawing: [{ | ||
+ | type: "bitmap", | ||
+ | bitmap: "arrow", | ||
+ | x: 600, | ||
+ | y: 170, | ||
+ | scale: 4 | ||
+ | }], | ||
+ | elements:{ | ||
+ | "inputSlot0":{x:530, y:170, type:"slot"}, | ||
+ | |||
+ | "outputSlot":{x:698, y:170, type:"slot", isValid:RecipeTE.outputSlotValid }, | ||
+ | |||
+ | "timerScale":{ | ||
+ | type: "scale", | ||
+ | x: 600, | ||
+ | y: 170, | ||
+ | direction:0, | ||
+ | value: .5, | ||
+ | bitmap: "arrow_scale", | ||
+ | scale: 4 | ||
+ | } | ||
+ | } | ||
+ | });</syntaxhighlight> | ||
+ | |||
+ | Затем регистрируем наш верстак(печь), есть два способа: | ||
+ | |||
+ | *'''RecipeTE.registerTimerCraftTable(description);''' | ||
+ | <syntaxhighlight lang="JavaScript">RecipeTE.registerTimerCraftTable({ | ||
+ | name:"Furnace", | ||
+ | cols:1, | ||
+ | timer:5*20 | ||
+ | }); | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | *'''RecipeTE.registerTimerCraftTable(name, columns, timer);''' | ||
+ | <syntaxhighlight lang="JavaScript">RecipeTE.registerTimerCraftTable("Furnace", 1, 5*20);</syntaxhighlight> | ||
+ | |||
+ | Теперь нам следует зарегистрировать TileEntity. В getGuiScreen мы возвращаем наше окно. В методе ''redstone ''мы будем проверять, сльный ли редстоун-сигнал и включать машину. В методе тика мы вызываем '''''RecipeTE.getTickResipes(name, TileEntity, condition)''''' с нашим условием: | ||
+ | <syntaxhighlight lang="JavaScript">TileEntity.registerPrototype(BlockID["Furnace"], { | ||
+ | getGuiScreen: function(){ | ||
+ | return Furnace; | ||
+ | }, | ||
+ | redstone: function(params){ | ||
+ | if(params.power < 10) | ||
+ | this.data.power = false; | ||
+ | else | ||
+ | this.data.power = true; | ||
+ | }, | ||
+ | tick:function(){ | ||
+ | RecipeTE.getTickResipes("Furnace", this, function(TE){ | ||
+ | return TE.data.power; | ||
+ | }); | ||
+ | } | ||
+ | });</syntaxhighlight> | ||
+ | <div class="mw-parser-output"><div class="mw-parser-output"> </div> </div> </div> | ||
+ | |||
+ | ==== Создание рецептов для печи ==== | ||
+ | |||
+ | Создание рецептов для верстака(печи) без сетки происходит через метод '''''RecipeTE.addRecipe(name_workbench, result, recipe, ingredients)''''', где: | ||
+ | |||
+ | *name_workbench - имя верстака | ||
+ | *result - объект результата | ||
+ | **id - ID предмета | ||
+ | **count - Кол-во предмета | ||
+ | **data - Дата предмета | ||
+ | *recipe - Строка крафта | ||
+ | *ingredients - объект ингредиентов | ||
+ | <syntaxhighlight lang="JavaScript">RecipeTE.addRecipe("Furnace", {id:280, count:1}, "a", {a:{id:5}}); | ||
+ | </syntaxhighlight> | ||
+ | </div> | ||
+ | |||
+ | <div class="mw-parser-output"> | ||
+ | == Полная документация == | ||
+ | |||
+ | {| border="1" cellpadding="1" cellspacing="1" style="width: 100%;" | ||
+ | |- | ||
+ | | style="width: 61px; text-align: center;" | '''Версия''' | ||
+ | | style="width: 385px; text-align: center;" | '''Метод''' | ||
+ | | style="text-align: center; width: 379px;" | '''Аргументы''' | ||
+ | | style="text-align: center; width: 200px;" | '''Описание''' | ||
+ | |- | ||
+ | | style="width: 61px; text-align: center;" | '''1''' | ||
+ | | style="width: 385px;" | RecipeTE.registerGridCraftTable(object description) | ||
+ | | style="text-align: center; width: 379px;" | | ||
+ | *description- Описание верстака | ||
+ | **name - Идентификатор/имя верстака | ||
+ | **columns/cols - Кол-во колонок | ||
+ | **rows - Кол-во строк | ||
+ | |||
+ | | colspan="1" rowspan="2" style="width: 200px;" | Регистрация верстака с сеткой | ||
+ | |- | ||
+ | | style="width: 61px; text-align: center;" | '''1''' | ||
+ | | style="width: 385px;" | RecipeTE.registerGridCraftTable(string name, int columns, int rows) | ||
+ | | style="width: 379px;" | | ||
+ | *name - Идентификатор/имя верстака | ||
+ | *columns - Кол-во колонок | ||
+ | *rows - Кол-во строк | ||
+ | |||
+ | |- | ||
+ | | style="width: 61px; text-align: center;" | '''1''' | ||
+ | | style="width: 385px;" | RecipeTE.registerCraftTable(object description) | ||
+ | | style="width: 379px;" | | ||
+ | *description- Описание верстака | ||
+ | **name - Идентификатор/имя верстака | ||
+ | **columns/cols - Кол-во слотов | ||
+ | |||
+ | | colspan="1" rowspan="2" style="width: 200px;" | Регистрация верстака без сетки | ||
+ | |- | ||
+ | | style="width: 61px; text-align: center;" | '''1''' | ||
+ | | style="width: 385px;" | RecipeTE.registerCraftTable(string name, int slots) | ||
+ | | style="width: 379px;" | | ||
+ | *name - Идентификатор/имя верстака | ||
+ | *slots - Кол-во слотов | ||
+ | |||
+ | |- | ||
+ | | style="width: 61px; text-align: center;" | '''1''' | ||
+ | | style="width: 385px;" | RecipeTE.registerTimerGridCraftTable(object description) | ||
+ | | style="width: 379px;" | | ||
+ | *description- Описание верстака | ||
+ | **name - Идентификатор/имя верстака | ||
+ | **columns/cols - Кол-во колонок | ||
+ | **rows - Кол-во строк | ||
+ | **timer - Время производства в тиках | ||
+ | |||
+ | | colspan="1" rowspan="2" style="width: 200px;" | Регистрация верстака с сеткой, требующий время на производство | ||
+ | |- | ||
+ | | style="width: 61px; text-align: center;" | '''1''' | ||
+ | | style="width: 385px;" | RecipeTE.registerTimerGridCraftTable(string name, int columns, int rows, int timer) | ||
+ | | style="width: 379px;" | | ||
+ | *name - Идентификатор/имя верстака | ||
+ | *columns - Кол-во колонок | ||
+ | *rows - Кол-во строк | ||
+ | *timer - Время производства в тиках | ||
+ | |||
+ | |- | ||
+ | | style="width: 61px; text-align: center;" | '''1''' | ||
+ | | style="width: 385px;" | RecipeTE.registerTimerCraftTable(object description) | ||
+ | | style="width: 379px;" | | ||
+ | *description- Описание верстака | ||
+ | **name - Идентификатор/имя верстака | ||
+ | **columns/cols - Кол-во слотов | ||
+ | **timer - Время производства в тиках | ||
+ | |||
+ | | colspan="1" rowspan="2" style="width: 200px;" | Регистрация верстака без сетки, требующий время на производство | ||
+ | |- | ||
+ | | style="width: 61px; text-align: center;" | '''1''' | ||
+ | | style="width: 385px;" | RecipeTE.registerTimerCraftTable(string name, int slots, int timer) | ||
+ | | style="width: 379px;" | | ||
+ | *name - Идентификатор/имя верстака | ||
+ | *slots - Кол-во слотов | ||
+ | *timer - Время производства в тиках | ||
+ | |||
+ | |- | ||
+ | | style="width: 61px; text-align: center;" | '''1''' | ||
+ | | style="width: 385px;" | RecipeTE.isRegistered(string name) | ||
+ | | style="width: 379px;" | | ||
+ | *name - Идентификатор/имя верстака | ||
+ | |||
+ | | style="width: 200px;" | Вернет true, если верстак зарегистрирован, иначе false | ||
+ | |- | ||
+ | | style="width: 61px; text-align: center;" | '''1''' | ||
+ | | style="width: 385px;" | RecipeTE.getMechanism(string name) | ||
+ | | style="width: 379px;" | | ||
+ | *name - Идентификатор/имя верстака | ||
+ | |||
+ | | style="width: 200px;" | Вернет описание верстака если он сущечтвует, иначе false | ||
+ | |- | ||
+ | | style="width: 61px; text-align: center;" | '''1''' | ||
+ | | style="width: 385px;" | RecipeTE.addRecipe(string name, object result, string recipe, object ingridients, function craft) | ||
+ | | style="width: 379px;" | | ||
+ | *name - Идентификатор/имя верстака | ||
+ | *result - Результат крафта | ||
+ | **int id - ID предмета | ||
+ | **int count - Кол-во | ||
+ | **int data - Дата предмета | ||
+ | *recipe - Строка, образующая рецепт | ||
+ | *ingridients - Объект ингридиентов | ||
+ | *craft - функция крафта(Не обязательный) | ||
+ | |||
+ | | style="width: 200px;" | Добавить крафт для верстака ''name'' | ||
+ | |- | ||
+ | | style="width: 61px; text-align: center;" | '''1''' | ||
+ | | style="width: 385px;" | RecipeTE.addGridRecipe(string name, object result, string[] recipe, object ingridients, function craft) | ||
+ | | style="width: 379px;" | | ||
+ | *name - Идентификатор/имя верстака | ||
+ | *result - Результат крафта | ||
+ | **int id - ID предмета | ||
+ | **int count - Кол-во | ||
+ | **int data - Дата предмета | ||
+ | *recipe - Массив строк, образующие рецепт | ||
+ | *ingridients - Объект ингридиентов | ||
+ | *craft - Функция крафта (Не обязательный) | ||
+ | |||
+ | | style="width: 200px;" | Добавить крафт для верстака с сеткой ''name'' | ||
+ | |- | ||
+ | | style="width: 61px; text-align: center;" | '''1''' | ||
+ | | style="width: 385px;" | RecipeTE.getTickResipes(string name, TileEntity TE, function condition) | ||
+ | | style="width: 379px;" | | ||
+ | *name - Идентификатор/имя верстака | ||
+ | *TE - TileEntity | ||
+ | *condition - Функция условия (Не обязательный) | ||
+ | |||
+ | | style="width: 200px;" | Обработчик тика для TileEntity | ||
+ | |- | ||
+ | | style="width: 61px; text-align: center;" | '''1''' | ||
+ | | colspan="2" rowspan="1" style="width: 385px;" | RecipeTE.outputSlotValid() | ||
+ | | style="width: 200px;" | Функция проверки слота результата | ||
+ | |- | ||
+ | | style="width: 61px; text-align: center;" | '''1''' | ||
+ | | style="width: 385px;" | RecipeTE.defaultCraftEvent(TileEntity TE, object workbench) | ||
+ | | style="width: 379px;" | | ||
+ | *TE - TileEntity | ||
+ | *workbench - Объект описания верстака | ||
+ | |||
+ | | style="width: 200px;" | Стандартная функция крафта (Для методов RecipeTE.addRecipe и RecipeTE.addGridRecipe) | ||
+ | |} | ||
+ | |||
+ | | ||
+ | </div> |
Используя данный продукт вы автоматически соглашаетесь с этими правилами
Импортируйте библиотеку.
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({
name:"Workbench_Grid",
rows:4,
cols:4
});
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), где:
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
}
});
Для начала создаем блок:
IDRegistry.genBlockID("Furnace");
Block.createBlockWithRotation("Furnace", [{
name: "Furnace",
texture: [
["iron_furnace_bottom", 0], // bottom
["iron_furnace_top", 0], // top
["iron_furnace_side", 0], // back
["iron_furnace_front", 0], // front
["iron_furnace_side", 0], // left
["iron_furnace_side", 0] // right
],
inCreative: true
}]);
Затем создаем наш интерфейс:
!ВАЖНО!: Слоты, в которые нужно ложить предмет нужна ОБЯЗАТЕЛЬНО называть "inputSlot"+ порядковое число слота, начиная с нуля. Слот результата должен иметь название "outputSlot", так же стоит задавть isValidдля outputSlot как RecipeTE.outputSlotValid
var Furnace = new UI.StandartWindow({
standart: {
header: {text: {text: "Furnace"}},
inventory: {standart:true},
background: {standart: true}
},
drawing: [{
type: "bitmap",
bitmap: "arrow",
x: 600,
y: 170,
scale: 4
}],
elements:{
"inputSlot0":{x:530, y:170, type:"slot"},
"outputSlot":{x:698, y:170, type:"slot", isValid:RecipeTE.outputSlotValid },
"timerScale":{
type: "scale",
x: 600,
y: 170,
direction:0,
value: .5,
bitmap: "arrow_scale",
scale: 4
}
}
});
Затем регистрируем наш верстак(печь), есть два способа:
RecipeTE.registerTimerCraftTable({
name:"Furnace",
cols:1,
timer:5*20
});
RecipeTE.registerTimerCraftTable("Furnace", 1, 5*20);
Теперь нам следует зарегистрировать TileEntity. В getGuiScreen мы возвращаем наше окно. В методе redstone мы будем проверять, сльный ли редстоун-сигнал и включать машину. В методе тика мы вызываем RecipeTE.getTickResipes(name, TileEntity, condition) с нашим условием:
TileEntity.registerPrototype(BlockID["Furnace"], {
getGuiScreen: function(){
return Furnace;
},
redstone: function(params){
if(params.power < 10)
this.data.power = false;
else
this.data.power = true;
},
tick:function(){
RecipeTE.getTickResipes("Furnace", this, function(TE){
return TE.data.power;
});
}
});
Создание рецептов для верстака(печи) без сетки происходит через метод RecipeTE.addRecipe(name_workbench, result, recipe, ingredients), где:
RecipeTE.addRecipe("Furnace", {id:280, count:1}, "a", {a:{id:5}});
Версия | Метод | Аргументы | Описание |
1 | RecipeTE.registerGridCraftTable(object description) |
|
Регистрация верстака с сеткой |
1 | RecipeTE.registerGridCraftTable(string name, int columns, int rows) |
| |
1 | RecipeTE.registerCraftTable(object description) |
|
Регистрация верстака без сетки |
1 | RecipeTE.registerCraftTable(string name, int slots) |
| |
1 | RecipeTE.registerTimerGridCraftTable(object description) |
|
Регистрация верстака с сеткой, требующий время на производство |
1 | RecipeTE.registerTimerGridCraftTable(string name, int columns, int rows, int timer) |
| |
1 | RecipeTE.registerTimerCraftTable(object description) |
|
Регистрация верстака без сетки, требующий время на производство |
1 | RecipeTE.registerTimerCraftTable(string name, int slots, int timer) |
| |
1 | RecipeTE.isRegistered(string name) |
|
Вернет true, если верстак зарегистрирован, иначе false |
1 | RecipeTE.getMechanism(string name) |
|
Вернет описание верстака если он сущечтвует, иначе false |
1 | RecipeTE.addRecipe(string name, object result, string recipe, object ingridients, function craft) |
|
Добавить крафт для верстака name |
1 | RecipeTE.addGridRecipe(string name, object result, string[] recipe, object ingridients, function craft) |
|
Добавить крафт для верстака с сеткой name |
1 | RecipeTE.getTickResipes(string name, TileEntity TE, function condition) |
|
Обработчик тика для TileEntity |
1 | RecipeTE.outputSlotValid() | Функция проверки слота результата | |
1 | RecipeTE.defaultCraftEvent(TileEntity TE, object workbench) |
|
Стандартная функция крафта (Для методов RecipeTE.addRecipe и RecipeTE.addGridRecipe) |