Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Occultism Crushing Fix #47

Merged
Merged
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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#### 🦟 Bugs Fixed

- Fixed issue with quest reward Scraper not accepting enchants [\#41](https://github.com/EnigmaticaModpacks/Enigmatica10/pull/41)
- Fix issue with Occultism crushing [\#47](https://github.com/EnigmaticaModpacks/Enigmatica10/pull/47)

---

Expand Down
4 changes: 4 additions & 0 deletions kubejs/server_scripts/constants/mod_priorities.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//priority: 1001

// priority of which mod output should come from, if applicable
const mod_priorities = ['minecraft', 'mekanism', 'modern_industrialization', 'occultism'];
21 changes: 21 additions & 0 deletions kubejs/server_scripts/functions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//priority: 1005

function getPreferredItemInTag(tag) {
return (
Ingredient.of(tag)
.stacks.toArray()
.sort(({ mod: a }, { mod: b }) => compareIndices(a, b, tag))[0] || Item.of(air)
);
}

function compareIndices(a, b, tag) {
if (a == b) return 0; // iff a == b, they'll be found at the same position in modPriorities

for (let mod of mod_priorities) {
if (mod == a) return -1; // if a comes before b, then idx(a) < idx(b), so -1
if (mod == b) return 1; // if a comes after b, then idx(a) > idx(b), so 1
}

console.error('[' + a + ', ' + b + '] were both unaccounted for in mod unification' + (tag ? ' for ' + tag : '!'));
return 0;
}
37 changes: 32 additions & 5 deletions kubejs/server_scripts/recipes/occultism/crushing.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,52 @@ ServerEvents.recipes((event) => {
ingredient: { item: 'justdirethings:coal_t2' },
ignore_crushing_multiplier: true,
result: {
type: 'occultism:tag',
tag: 'c:dusts/blaze',
type: 'occultism:item',
id: 'minecraft:blaze_powder',
count: 6
},
id: `${id_prefix}blaze_powder_from_coal_t2`
},
{
ingredient: { tag: 'c:rods/blaze' },
ignore_crushing_multiplier: true,

result: {
type: 'occultism:tag',
tag: 'c:dusts/blaze',
type: 'occultism:item',
id: 'minecraft:blaze_powder',
count: 4
},
id: `occultism:crushing/blaze_powder_from_rod`
},
{
ingredient: { tag: 'c:ores/uraninite' },
ignore_crushing_multiplier: false,
result: {
type: 'occultism:item',
id: 'powah:uraninite_raw',
count: 4
},
id: `${id_prefix}uraninite_raw`
}
];

event.forEachRecipe({ type: 'occultism:crushing' }, (r) => {
let recipe = JSON.parse(r.json);
let recipe_id = r.getId();

if (recipe.result.type == 'occultism:tag') {
// console.log(`Found a tagged output: ${recipe.result.tag}`);
// console.log(`Preferred output: ${getPreferredItemInTag(`#${recipe.result.tag}`).getId()}`);

recipe.result.type = 'occultism:item';
recipe.result.id = getPreferredItemInTag(`#${recipe.result.tag}`).getId();
recipe.id = recipe_id;

delete recipe.result.tag;

recipes.push(recipe);
}
});

recipes.forEach((recipe) => {
recipe.type = 'occultism:crushing';
event.custom(recipe).id(recipe.id);
Expand Down