72 lines
1.8 KiB
JavaScript
Executable File
72 lines
1.8 KiB
JavaScript
Executable File
// priority: 0
|
|
function Metal(name) {
|
|
this.name = name;
|
|
}
|
|
|
|
Metal.of = function(name) {
|
|
return new Metal(name);
|
|
}
|
|
|
|
Metal.prototype.formOf = function(form) {
|
|
let itemType = AlmostUnified.getPreferredItemForTag(`forge:${form}/${this.name}`);
|
|
if (itemType.id == 'minecraft:air') {
|
|
console.warn(`metals: #forge:${form}/${this.name} is not supported by AlmostUnified! Trying a vanilla hack...`);
|
|
itemType = Ingredient.of(`#forge:${form}/${this.name}`).getFirst();
|
|
}
|
|
if (itemType.id == 'minecraft:air') {
|
|
console.warn(`metals: No metal items found in #forge:${form}/${this.name}`)
|
|
} else {
|
|
console.log(`metals: Found ${itemType.id} for #forge:${form}/${this.name}`);
|
|
}
|
|
return itemType;
|
|
}
|
|
|
|
// Format is [property name, tag name]
|
|
const forms = [
|
|
['ingot', 'ingots'],
|
|
['gear', 'gears'],
|
|
['rod', 'rods'],
|
|
['nugget', 'nuggets'],
|
|
['plate', 'plates'],
|
|
['dust', 'dusts']
|
|
];
|
|
|
|
for (const [prop_name, form_tag] of forms) {
|
|
Metal.prototype[prop_name] = function() {
|
|
return this.formOf(form_tag);
|
|
}
|
|
}
|
|
|
|
global.metalForm = (metal, tag) => {
|
|
return (new Metal(metal)).formOf(tag);
|
|
}
|
|
|
|
global.dustItem = (material) => {
|
|
return global.metalForm(material, 'dusts');
|
|
}
|
|
|
|
global.ingotItem = (material) => {
|
|
return global.metalForm(material, 'ingots');
|
|
}
|
|
|
|
global.plateItem = (material) => {
|
|
return global.metalForm(material, 'plates');
|
|
}
|
|
|
|
global.gearItem = (material) => {
|
|
return global.metalForm(material, 'gears');
|
|
}
|
|
|
|
global.nuggetItem = (material) => {
|
|
return global.metalForm(material, 'nuggets');
|
|
}
|
|
|
|
global.replaceInputs = (evt, filter, replaceMap) => {
|
|
replaceMap.forEach(mapped => {
|
|
evt.replaceInput(
|
|
filter,
|
|
mapped[0],
|
|
mapped[1]
|
|
);
|
|
})
|
|
} |