Нихеровый рефакторинг

This commit is contained in:
SpeeeDCraft 2023-11-15 18:11:34 +07:00
parent 08a0cf6aa8
commit 0b518eeffd
5 changed files with 127 additions and 124 deletions

View file

@ -1,15 +0,0 @@
{
"__comment__": "This file was automatically created by mcresources",
"type": "tfc:blast_furnace",
"fluid": {
"ingredient": "gtceu:iron",
"amount": 1
},
"result": {
"fluid": "tfc:metal/pig_iron",
"amount": 1
},
"catalyst": {
"tag": "tfc:flux"
}
}

View file

@ -1,15 +0,0 @@
{
"__comment__": "This file was automatically created by mcresources",
"type": "tfc:bloomery",
"result": {
"item": "tfc:raw_iron_bloom"
},
"fluid": {
"ingredient": "gtceu:iron",
"amount": 144
},
"catalyst": {
"item": "minecraft:charcoal"
},
"duration": 15000
}

View file

@ -2,6 +2,23 @@
const registerTFCData = (event) => {
registerTFCItemHeats(event)
registerTFCHeatingRecipes(event)
registerTFCCastingRecipes(event)
addBloomeryRecipe(event,
'tfc:recipes/bloomery/raw_iron_bloom',
{ item: "tfc:raw_iron_bloom" },
{ ingredient: "gtceu:iron", amount: 144 },
{ item: "minecraft:charcoal" },
15000
)
addTFCBlastFurnaceRecipe(event,
'tfc:recipes/blast_furnace/pig_iron',
{ ingredient: "gtceu:iron", amount: 1 },
{ fluid: "tfc:metal/pig_iron", amount: 1 },
{ tag: "tfc:flux" }
)
}
const registerTFCItemHeats = (event) => {
@ -23,3 +40,58 @@ const registerTFCItemHeats = (event) => {
}
}
const registerTFCHeatingRecipes = (event) => {
for (const [tfcMetalName, metalSpecifications] of Object.entries(Metals)) {
metalSpecifications.props.forEach(propertyName => {
let jsonRecipePath = `tfc:recipes/heating/tfg/${tfcMetalName}_${propertyName}`
let itemTypeSpecifications = ItemHeats[propertyName]
if (itemTypeSpecifications.heat_capacity != null) {
let ingredientInput = itemTypeSpecifications.input(tfcMetalName)
let json
if (typeof(itemTypeSpecifications.metal_amount) == "object")
{
if (itemTypeSpecifications.metal_amount[tfcMetalName] != undefined)
{
addHeatingItemToFluidRecipe(
event,
jsonRecipePath,
ingredientInput,
{ fluid: metalSpecifications.fluidName, amount: itemTypeSpecifications.metal_amount[tfcMetalName] },
metalSpecifications.melt_temp,
(itemTypeSpecifications.hasDur != undefined) ? itemTypeSpecifications.hasDur : false
)
}
else
{
addHeatingItemToFluidRecipe(
event,
jsonRecipePath,
ingredientInput,
{ fluid: metalSpecifications.fluidName, amount: itemTypeSpecifications.metal_amount["default"] },
metalSpecifications.melt_temp,
(itemTypeSpecifications.hasDur != undefined) ? itemTypeSpecifications.hasDur : false
)
}
}
else {
addHeatingItemToFluidRecipe(
event,
jsonRecipePath,
ingredientInput,
{ fluid: metalSpecifications.fluidName, amount: itemTypeSpecifications.metal_amount },
metalSpecifications.melt_temp,
(itemTypeSpecifications.hasDur != undefined) ? itemTypeSpecifications.hasDur : false
)
}
}
})
}
}
const registerTFCCastingRecipes = (event) => {
}

View file

@ -7,9 +7,6 @@ const registerTFCRecipes = (event) => {
event.remove({ id: /tfc:heating\/metal.*/ })
event.remove({ id: /tfc:heating\/ore.*/ })
registerTFCHeatingRecipes(event)
registerTFCCastingRecipes(event)
event.remove({ id: 'tfc:crafting/vanilla/lapis_block' })
event.remove({ id: 'tfc:quern/amethyst' })
@ -345,75 +342,4 @@ const registerTFCRecipes = (event) => {
{ tag: "forge:rich_raw_materials/borax" },
{ item: "tfc:powder/flux", count: 6 }
)
}
const registerTFCHeatingRecipes = (event) => {
for (const [tfcMetalName, metalSpecifications] of Object.entries(Metals)) {
metalSpecifications.props.forEach(propertyName => {
let jsonRecipePath = `tfc:recipes/metal/${tfcMetalName}_${propertyName}`
let itemTypeSpecifications = ItemHeats[propertyName]
if (itemTypeSpecifications.heat_capacity != null) {
let ingredientInput = itemTypeSpecifications.input(tfcMetalName)
let json
if (typeof(itemTypeSpecifications.metal_amount) == "object")
{
if (itemTypeSpecifications.metal_amount[tfcMetalName] != undefined)
{
json = {
id: jsonRecipePath,
type: "tfc:heating",
ingredient: ingredientInput,
result_fluid: {
fluid: metalSpecifications.fluidName,
amount: itemTypeSpecifications.metal_amount[tfcMetalName]
},
temperature: metalSpecifications.melt_temp,
use_durability: (itemTypeSpecifications.hasDur != undefined) ? itemTypeSpecifications.hasDur : false
}
}
else
{
json = {
id: jsonRecipePath,
type: "tfc:heating",
ingredient: ingredientInput,
result_fluid: {
fluid: metalSpecifications.fluidName,
amount: itemTypeSpecifications.metal_amount["default"]
},
temperature: metalSpecifications.melt_temp,
use_durability: (itemTypeSpecifications.hasDur != undefined) ? itemTypeSpecifications.hasDur : false
}
}
}
else {
json = {
id: jsonRecipePath,
type: "tfc:heating",
ingredient: ingredientInput,
result_fluid: {
fluid: metalSpecifications.fluidName,
amount: itemTypeSpecifications.metal_amount
},
temperature: metalSpecifications.melt_temp,
use_durability: (itemTypeSpecifications.hasDur != undefined) ? itemTypeSpecifications.hasDur : false
}
}
event.custom(json)
}
})
}
}
const registerTFCCastingRecipes = (event) => {
}

View file

@ -38,7 +38,7 @@ const addEmptyJson = (event, path) => {
}
/**
* Метод создает нагревательную спецификации для предмета.
* Метод создает нагревательную спецификацию json для предмета.
* Используется только в событии генерации датапаков, не является рецептом.
* @param { ServerEvents.highPriorityData } event Событие в котором вызывается.
* @param { String } customPath Путь, начинается с [tfc:tfc/item_heats/], если указан customPath,
@ -61,38 +61,73 @@ const addItemHeat = (event, customPath, input, heat_capacity, forging_temperatur
}
/**
* Создает рецепт нагрева, предмет -> жидкость, в основном используется для металлов.
* @param { ServerEvents.recipes } event Событие в котором вызывается.
* @param { String } id Название рецепта, если не указать сгенерируется автоматически, рекомендуется задать вручную.
* Создает json рецепта нагрева, предмет -> жидкость, в основном используется для металлов.
* @param { ServerEvents.highPriorityData } event Событие в котором вызывается.
* @param { String } recipeId Название рецепта.
* @param { Object } input Объект входа, может принимать объект с тэгом или предметом.
* @param { Object } result_fluid Результирующая жидкость после расплава предмета.
* @param { Number } temperature Температура при которой произойдет рецепт.
*/
const addHeatingItemToFluidRecipe = (event, id, input, result_fluid, temperature) => {
event.custom({
id: id,
const addHeatingItemToFluidRecipe = (event, recipeId, input, result_fluid, temperature, useDurab) => {
event.addJson(recipeId, {
type: "tfc:heating",
ingredient: input,
result_fluid: result_fluid,
temperature: temperature,
use_durability: useDurab
})
}
/**
* Создает json рецепт нагрева, предмет -> предмет, в основном используется для обычных предметов.
* @param { ServerEvents.highPriorityData } event Событие в котором вызывается.
* @param { String } recipeId Название рецепта.
* @param { Object } input Объект входа, может принимать объект с тэгом или предметом.
* @param { Object } result_fluid Результирующий предмет после достижения требуемой температуры.
* @param { Number } temperature Температура при которой произойдет рецепт.
*/
const addHeatingItemToItemRecipe = (event, recipeId, input, result_item, temperature) => {
event.addJson(recipeId, {
type: "tfc:heating",
ingredient: input,
result_item: result_item,
temperature: temperature
})
}
/**
* Создает рецепт нагрева, предмет -> предмет, в основном используется для обычных предметов.
* @param { ServerEvents.recipes } event Событие в котором вызывается.
* @param { String } id Название рецепта, если не указать сгенерируется автоматически, рекомендуется задать вручную.
* @param { Object } input Объект входа, может принимать объект с тэгом или предметом.
* @param { Object } result_fluid Результирующий предмет после достижения требуемой температуры.
* @param { Number } temperature Температура при которой произойдет рецепт.
* Создает json рецепт для доменной печки лоу тира.
* @param { ServerEvents.highPriorityData } event Событие в котором вызывается.
* @param { String } recipeId Название рецепта.
* @param { Object } result Объект выхода, может принимать объект с тэгом или предметом.
* @param { Object } fluid Объект жидкости, может принимать объект с жидкостью и ее кол-вом.
* @param { Object } catalyst Объект катализатора, может принимать объект с тэгом или предметом.
* @param { number } duration Длительность рецепта.
*/
const addHeatingItemToItemRecipe = (event, id, input, result_item, temperature) => {
event.custom({
id: id,
type: "tfc:heating",
ingredient: input,
result_item: result_item,
temperature: temperature
const addBloomeryRecipe = (event, recipeId, result, fluid, catalyst, duration) => {
event.addJson(recipeId, {
type: "tfc:bloomery",
result: result,
fluid: fluid,
catalyst: catalyst,
duration: duration
})
}
/**
* Создает json рецепт для доменной печки нормал тира.
* @param { ServerEvents.highPriorityData } event Событие в котором вызывается.
* @param { String } recipeId Название рецепта.
* @param { Object } fluid Объект жидкости, может принимать объект с жидкостью и ее кол-вом.
* @param { Object } result Объект выхода, может принимать объект с тэгом или предметом.
* @param { Object } catalyst Объект катализатора, может принимать объект с тэгом или предметом.
*/
const addTFCBlastFurnaceRecipe = (event, recipeId, fluid, result, catalyst) => {
event.addJson(recipeId, {
type: "tfc:blast_furnace",
fluid: fluid,
result: result,
catalyst: catalyst
})
}