Fluid tag unification (#2194)

* eslint change

* utility scripts

* cleanup

* beaker fluid change
This commit is contained in:
Redeix 2025-11-09 12:22:17 -06:00 committed by GitHub
parent bcd423e824
commit fbc456723d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 160 additions and 76 deletions

View file

@ -21,7 +21,6 @@ export default defineConfig([
"no-var": "warn",
"prefer-template": "warn",
"no-unreachable-loop": "warn",
"no-useless-assignment": "warn",
"no-self-compare": "warn",
"no-template-curly-in-string": "error",
"no-unmodified-loop-condition": "warn",
@ -45,11 +44,9 @@ export default defineConfig([
"no-eval": "error",
"no-implied-eval": "error",
"no-lone-blocks": "warn",
"no-multi-spaces": "warn",
"no-return-assign": "warn",
"no-useless-return": "warn",
"no-with": "error",
"prefer-const": "warn",
"prefer-arrow-callback": "warn",
"no-useless-concat": "warn",
"yoda": ["warn", "never"],

View file

@ -76,13 +76,15 @@ const registerFirmaLifeFluidTags = (event) => {
event.add('c:hidden_from_recipe_viewers', 'firmalife:metal/chromium')
event.add('c:hidden_from_recipe_viewers', 'firmalife:chocolate')
// Im going to leave these, but I dont think this tag does anything(?).
event.add('firmalife:mixable', 'tfc:spring_water')
event.add('firmalife:mixable', 'tfcchannelcasting:white_chocolate')
event.add('firmalife:mixable', 'tfcchannelcasting:milk_chocolate')
event.add('firmalife:mixable', 'tfcchannelcasting:dark_chocolate')
event.add('firmalife:mixable', 'afc:maple_syrup')
event.add('firmalife:mixable', 'afc:birch_syrup')
event.add('firmalife:usable_in_mixing_bowl', 'gtceu:seed_oil')
event.add('firmalife:oils', 'gtceu:seed_oil')
event.add('firmalife:oils', 'gtceu:fish_oil')
event.add('firmalife:oils', 'tfg:triglyceride_oil')
}

View file

@ -135,5 +135,4 @@ function registerGTCEUFluidTags(event) {
event.add("c:hidden_from_recipe_viewers", "gtceu:blaze");
event.add("c:hidden_from_recipe_viewers", "gtceu:thorium");
event.add('firmalife:usable_in_mixing_bowl', 'gtceu:concrete')
}
}

View file

@ -537,57 +537,165 @@ function registerTFCFluidTags(event) {
event.add("tfc:usable_in_tool_head_mold", "gtceu:black_bronze");
event.add("tfc:usable_in_tool_head_mold", "gtceu:bronze");
/**********************************************************************************************************
*
* Utility functions to classify fluids into tags based on temperature and properties.
* * * Seperates fluids into hot, cold, neutral, and acidic fluid tags.
* * * Uses these tags to determine usability in different containers.
*
***********************************************************************************************************/
const $FluidState = Java.loadClass("com.gregtechceu.gtceu.api.fluids.FluidState")
const $FluidAttribute = Java.loadClass("com.gregtechceu.gtceu.api.fluids.attribute.FluidAttributes")
const ForgeRegistries = Java.loadClass('net.minecraftforge.registries.ForgeRegistries');
const FluidStack = Java.loadClass('net.minecraftforge.fluids.FluidStack');
forEachMaterial(material => {
if (material.hasProperty(PropertyKey.FLUID)) {
let fluid = material.getFluid();
// Ignore gases
let fluidType = fluid.getFluidType();
if (fluidType.isLighterThanAir())
return;
// Check for acids
try {
// This is in a try catch because I don't know how to check if an object is of type
// AttributedFluid or GTFluid here
if (fluid.getAttributes().contains($FluidAttribute.ACID))
return;
}
catch (exception) {
return;
}
// Check for plasmas (and gases again in case the previous check didn't work)
let fluidState = fluid.getState();
if (fluidState === $FluidState.PLASMA || fluidState === $FluidState.GAS)
return;
let fluidName = fluidType.toString();
let temperature = fluidType.getTemperature();
// 340 is the max temperature of wood pipes
// 120 is the cryogenic temperature threshold (see gtceu/FluidConstants)
if (temperature <= 340 && temperature >= 120) {
event.add("tfc:usable_in_barrel", fluidName);
event.add("tfc:usable_in_wooden_bucket", fluidName);
}
// Red steel's max temperature, can do cryo
if (temperature <= 370) {
event.add("tfc:usable_in_red_steel_bucket", fluidName);
}
// Blue steel's max temp, can't do cryo
if (temperature <= 4618 && temperature >= 120) {
event.add("tfc:usable_in_blue_steel_bucket", fluidName);
// Tags acidic fluids.
try {
if (fluid.getAttributes().contains($FluidAttribute.ACID)) {
event.add("forge:acidic", fluidName);
};
}
catch (exception) { /* empty */ }
}
})
event.add("tfc:usable_in_pot", "gtceu:ice");
ForgeRegistries.FLUIDS.getValues().forEach(fluid => {
// Determine if fluid is hot or not. (pun intended)
const hotFluids = (fluid) => {
let temp = -1;
try {
temp = fluid.getFluidType().getTemperature();
} catch (e1) {
try {
temp = fluid.getFluidType().getTemperature(new FluidStack(fluid, 1000));
} catch (e2) {
temp = -1;
}
}
const id = ForgeRegistries.FLUIDS.getKey(fluid);
if (!id) return;
// Return if fluid is hidden from recipe viewers.
const idString = id.toString();
let hiddenWrapper;
try { hiddenWrapper = event.get('c:hidden_from_recipe_viewers'); } catch (e) { /* ignore */ }
const wrapperHas = (wrapper) => {
if (!wrapper) return false;
try { return wrapper.getObjectIds().toArray().some(wid => String(wid) === idString); } catch (e) { return false; }
};
if (wrapperHas(hiddenWrapper)) return;
const idStr = id.toString();
// Temp testing.
// Not extreme temps.
if (temp <= 340 && temp >= 120) {
event.add("tfg:moderate_temperature_fluids", idStr);
}
// Red steel: can't do heat, can do cryo.
if (temp <= 370) {
event.add("tfc:usable_in_red_steel_bucket", idStr);
}
// Burns ya.
if (temp >= 370) {
event.add("tfchotornot:hot_whitelist", idStr);
}
// Blue steel: can do heat, can't do cryo.
if (temp >= 120) {
event.add("tfc:usable_in_blue_steel_bucket", idStr);
}
};
// Determine if fluid is a gas or a plasma, and tag accordingly.
const liquidTag = (fluid) => {
const id = ForgeRegistries.FLUIDS.getKey(fluid);
if (!id) return;
const idString = id.toString();
// Check against tag wrappers for gas and plasma fluids.
let gaseousWrapper, plasmaticWrapper, hiddenWrapper;
try { gaseousWrapper = event.get('forge:gaseous'); } catch (e) { /* ignore */ }
try { plasmaticWrapper = event.get('forge:plasmatic'); } catch (e) { /* ignore */ }
try { hiddenWrapper = event.get('c:hidden_from_recipe_viewers'); } catch (e) { /* ignore */ }
const wrapperHas = (wrapper) => {
if (!wrapper) return false;
try { return wrapper.getObjectIds().toArray().some(wid => String(wid) === idString); } catch (e) { return false; }
};
const isGaseous = wrapperHas(gaseousWrapper);
const isPlasmatic = wrapperHas(plasmaticWrapper);
const isHidden = wrapperHas(hiddenWrapper);
if (isGaseous || isPlasmatic || isHidden) return;
event.add('forge:liquid', idString);
};
// Determine if fluid is neutral (not gas, plasma, acidic, or extreme temp), and tag accordingly.
const neutralTag = (fluid) => {
const id = ForgeRegistries.FLUIDS.getKey(fluid);
if (!id) return;
const idString = id.toString();
// Check against tag wrappers for gas, plasma, acidic, and normal temp fluids.
let acidicWrapper, moderateTemperatureWrapper, gaseousWrapper, plasmaticWrapper, hiddenWrapper;
try { acidicWrapper = event.get('forge:acidic'); } catch (e) { /* ignore */ }
try { moderateTemperatureWrapper = event.get('tfg:moderate_temperature_fluids'); } catch (e) { /* ignore */ }
try { gaseousWrapper = event.get('forge:gaseous'); } catch (e) { /* ignore */ }
try { plasmaticWrapper = event.get('forge:plasmatic'); } catch (e) { /* ignore */ }
try { hiddenWrapper = event.get('c:hidden_from_recipe_viewers'); } catch (e) { /* ignore */ }
const wrapperHas = (wrapper) => {
if (!wrapper) return false;
try { return wrapper.getObjectIds().toArray().some(wid => String(wid) === idString); } catch (e) { return false; }
};
const isAcidic = wrapperHas(acidicWrapper);
const isExtreme = !wrapperHas(moderateTemperatureWrapper);
const isGaseous = wrapperHas(gaseousWrapper);
const isPlasmatic = wrapperHas(plasmaticWrapper);
const isHidden = wrapperHas(hiddenWrapper);
if (isGaseous || isPlasmatic || isAcidic || isExtreme || isHidden) return;
event.add('forge:neutral_fluids', idString);
};
// Execute tagging functions.
hotFluids(fluid);
liquidTag(fluid);
neutralTag(fluid);
});
// Can use any liquid.
event.add('tfc:usable_in_pot', '#forge:liquid')
event.add('firmalife:usable_in_vat', '#forge:liquid')
// Can use only neutral fluids.
event.add('tfc:usable_in_barrel', '#forge:neutral_fluids');
event.add('tfc:usable_in_wooden_bucket', '#forge:neutral_fluids');
event.add('firmalife:usable_in_mixing_bowl', '#forge:neutral_fluids');
// All fluids are given the '#tfg:not_solid' tag incase we have a use for them regardless of state.
event.add('tfg:not_solid', '#forge:liquid')
event.add('tfg:not_solid', '#forge:gaseous')
event.add('tfg:not_solid', '#forge:plasmatic')
/***********************************************************************************************************/
event.add("tfc:ingredients", "tfc:spring_water");
event.add("tfc:alcohols", "tfcagedalcohol:aged_beer");

View file

@ -480,7 +480,7 @@ const registerTFGBlockTags = (event) => {
event.add('ae2:blacklisted/spatial', 'tfg:geyser_source_small')
//#region Fision Components
var COMPONENTS = 'deafission:components';
let COMPONENTS = 'deafission:components';
// Max Heating
event.add(COMPONENTS, 'tfg:glacian_wool_frame'); // Max Heat 2
@ -665,44 +665,22 @@ const registerTFGBlockTags = (event) => {
//#region Fluids
const registerTFGFluidTags = (event) => {
event.add('tfc:usable_in_pot', 'tfg:latex')
event.add('tfc:usable_in_barrel', 'tfg:latex')
event.add('tfc:usable_in_wooden_bucket', 'tfg:latex')
event.add('tfc:usable_in_red_steel_bucket', 'tfg:latex')
event.add('tfc:usable_in_blue_steel_bucket', 'tfg:latex')
event.add('tfc:usable_in_pot', 'tfg:vulcanized_latex')
event.add('tfc:usable_in_barrel', 'tfg:vulcanized_latex')
event.add('tfc:usable_in_wooden_bucket', 'tfg:vulcanized_latex')
event.add('tfc:usable_in_red_steel_bucket', 'tfg:vulcanized_latex')
event.add('tfc:usable_in_blue_steel_bucket', 'tfg:vulcanized_latex')
event.add('tfc:usable_in_pot', 'tfg:conifer_pitch')
event.add('tfc:usable_in_barrel', 'tfg:conifer_pitch')
event.add('tfc:usable_in_wooden_bucket', 'tfg:conifer_pitch')
event.add('tfc:usable_in_red_steel_bucket', 'tfg:conifer_pitch')
event.add('tfc:usable_in_blue_steel_bucket', 'tfg:conifer_pitch')
event.add('tfg:clean_water', 'minecraft:water')
event.add('tfg:clean_water', 'tfc:river_water')
event.add('tfg:clean_water', 'tfc:spring_water')
event.add('tfc:usable_in_barrel', 'gtceu:seed_oil')
event.add('forge:liquid', 'tfg:semiheavy_ammoniacal_water')
event.add('tfc:any_water', 'tfg:semiheavy_ammoniacal_water')
event.add('tfc:hydrating', 'tfg:semiheavy_ammoniacal_water')
event.add('tfc:drinkables', 'tfg:semiheavy_ammoniacal_water')
event.add('tfc:any_drinkables', 'tfg:semiheavy_ammoniacal_water')
event.add('tfc:ingredients', 'tfg:semiheavy_ammoniacal_water')
event.add('tfc:usable_in_pot', 'tfg:semiheavy_ammoniacal_water')
event.add('tfc:usable_in_wooden_bucket', 'tfg:semiheavy_ammoniacal_water')
event.add('tfc:usable_in_barrel', 'tfg:semiheavy_ammoniacal_water')
event.add('firmalife:usable_in_mixing_bowl', 'tfg:semiheavy_ammoniacal_water')
event.add('firmalife:mixable', 'tfg:semiheavy_ammoniacal_water')
event.add('firmalife:usable_in_vat', 'tfg:semiheavy_ammoniacal_water')
event.add('minecraft:water', 'tfg:semiheavy_ammoniacal_water')
event.add('tfc:drinkables', 'tfg:proto_growth_medium')
event.add('tfc:any_drinkables', 'tfg:proto_growth_medium')
global.BREATHABLE_COMPRESSED_AIRS.forEach(x => {
event.add('tfg:breathable_compressed_air', x)
})

View file

@ -132,7 +132,7 @@ const registerTFGItems = (event) => {
'slowness',
'speed',
'water_breathing',
'weakness',
'weakness'
]
const pill_names = [
'Haste',
@ -142,7 +142,7 @@ const registerTFGItems = (event) => {
'Slowness',
'Speed',
'Water Breathing',
'Weakness',
'Weakness'
]
pill.forEach((pill_array, index) => {
@ -172,14 +172,14 @@ const registerTFGItems = (event) => {
'fire_resistance',
'invisibility',
'luck',
'resistance',
'resistance'
]
const salvo_names = [
'Absorption',
'Fire Resistance',
'Invisibility',
'Luck',
'Resistance',
'Resistance'
]
salvo.forEach((salvo_array, index) => {
@ -473,7 +473,7 @@ const registerTFGItems = (event) => {
global.LAB_EQUIPMENT_CONTAINERS.forEach((item) => {
event.create(`tfg:${item.type}`, 'tfc:glass_bottle')
.fluidTagAccept('tfc:usable_in_blue_steel_bucket')
.fluidTagAccept('tfg:not_solid')
.capacity(item.capacity)
.translationKey(`item.tfg.lab_equipment.${item.type}`)
.tag('tfg:lab_equipment_containers')