Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ export default [
OpV: 'readonly',
MAX: 'readonly',
T: 'writable',
fluidTag: 'writable',
},
},
rules: {
Expand Down
126 changes: 50 additions & 76 deletions kubejs/server_scripts/modifications/thermal.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,61 +106,50 @@ ServerEvents.recipes((event) => {

event.remove({ mod: 'systeams' });

event.custom({
// So prior worlds dont crash
type: 'systeams:steam',
ingredient: {
fluid: 'systeams:steamietest',
amount: 1000,
},
energy: 1000,
});
/** @typedef FluidBasicIngredient
* @property {string} fluid
* @property {number} amount
*/

event.custom({
type: 'systeams:steam',
ingredient: {
// eslint-disable-next-line id-match, camelcase
fluid_tag: 'forge:steam',
amount: 1000,
},
energy: 1000,
});
/** @typedef FluidTagBasicIngredient
* @property {string} fluid_tag
* @property {number} amount
*/

event.custom({
type: 'systeams:boiling',
ingredient: {
fluid: 'minecraft:water',
amount: 100,
},
result: {
fluid: 'systeams:steam',
amount: 400,
},
});
/** @typedef {FluidBasicIngredient | FluidTagBasicIngredient} FluidOrTagIngredient */

event.custom({
type: 'systeams:boiling',
ingredient: {
// eslint-disable-next-line id-match, camelcase
fluid_tag: 'forge:steam',
amount: 50,
},
result: {
fluid: 'systeams:steamier',
amount: 100,
},
});
/** @type {(fluid: string, amount: number) => FluidOrTagIngredient} */
const fluidIngredient = (fluid, amount) => {
/* eslint-disable id-match, camelcase */
let ingredient = fluid.startsWith('forge')
? { fluid_tag: fluid, amount: amount }
: { fluid: fluid, amount: amount };
/* eslint-enable id-match, camelcase */
return ingredient;
};

let steamToIer = new JSONObject();
steamToIer.add('amount', 500);
steamToIer.add('value', { tag: 'forge:steam' });
/** @type {(fluid: string, energy: number) => void} */
const steamDynamo = (fluid, energy) => {
event.custom({
type: 'systeams:steam',
ingredient: fluidIngredient(fluid, 1000),
energy: energy,
});
};

event.recipes.gtceu
.fluid_heater(id('steam_tag'))
.inputFluids(FluidIngredientJS.of(steamToIer))
.outputFluids('systeams:steamier 1000')
.duration(20)
.EUt(30);
/** @type {(fluidIn: string, fluidInAmount: number, fluidOut: string, fluidOutAmount: number) => void} */
const steamBoiler = (fluidIn, fluidInAmount, fluidOut, fluidOutAmount) => {
event.custom({
type: 'systeams:boiling',
ingredient: fluidIngredient(fluidIn, fluidInAmount),
result: fluidIngredient(fluidOut, fluidOutAmount),
});
};

// backwards compatibility
steamDynamo('systeams:steamietest', 1000);
steamDynamo('forge:steam', 1000);
steamBoiler('minecraft:water', 100, 'gtceu:steam', 400);

/**
* @param {string} type
Expand All @@ -170,43 +159,28 @@ ServerEvents.recipes((event) => {
const systeamSteams = (type, prior, scale) => {
event.recipes.gtceu
.steam_turbine(id(`${type}`))
.inputFluids(`systeams:${type} 640`)
.inputFluids(type.startsWith('forge') ? fluidTag(type, 640) : `${type} 640`)
.outputFluids(`gtceu:distilled_water ${4 - scale}`)
.duration(10 + 2 * scale)
.EUt(-32);

event.custom({
type: 'systeams:steam',
ingredient: {
fluid: `systeams:${type}`,
amount: 1000,
},
energy: 1000 + 200 * scale,
});
steamDynamo(type, 1000 + 200 * scale);

if (type !== 'steamier') {
event.custom({
type: 'systeams:boiling',
ingredient: {
fluid: `systeams:${prior}`,
amount: 50,
},
result: {
fluid: `systeams:${type}`,
amount: 100,
},
});
steamBoiler(prior, 50, type, 100);
event.recipes.gtceu
.fluid_heater(id(`${type}`))
.inputFluids(`systeams:${prior} 500`)
.outputFluids(`systeams:${type} 1000`)
.fluid_heater(id(type))
.inputFluids(type.startsWith('forge') ? fluidTag(type, 500) : `${prior} 500`)
.outputFluids(`${type} 1000`)
.duration(20)
.EUt(30);
}
};
systeamSteams('steamier', 'steam', 1);
systeamSteams('steamiest', 'steamier', 2);
systeamSteams('steamiester', 'steamiest', 3);
systeamSteams('start_core:warm_steam', 'forge:steam', 1);
systeamSteams('start_core:hot_steam', 'systeams:steamier', 2);
systeamSteams('start_core:hot_steam', 'start_core:warm_steam', 2);
systeamSteams('start_core:extremely_hot_steam', 'systeams:steamiest', 3);
systeamSteams('start_core:extremely_hot_steam', 'start_core:hot_steam', 3);

event.recipes.gtceu
.mixer(id('diatron_dust'))
Expand Down
11 changes: 11 additions & 0 deletions kubejs/server_scripts/utils/helpers/recipe_helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,3 +230,14 @@ global.ingredientArrayToItemArray = ingredientArrayToItemArray;
global.itemArrayToIngredientArray = itemArrayToIngredientArray;
global.zipIngredientArrays = zipIngredientArrays;
global.zipItemArrays = zipItemArrays;

/** @type {(tag: string, amount: number) => internal.com.gregtechceu.gtceu.integration.kjs.recipe.components.GTRecipeComponents$FluidIngredientJS} */
const fluidTag = (tag, amount) => {
let ingredient = new JSONObject();
ingredient.add('amount', amount);
ingredient.add('value', { tag: tag });

return FluidIngredientJS.of(ingredient);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't .of({ amount: amount, value: { tag: tag }) work? If it's a typecheck problem, change FluidIngredientJS.of method argument from JSONObject to $wrapped<JSONObject> or just add another overload for the correctly typed object I guess

};

global.fluidTag = fluidTag;
Loading