Skip to content

Instantly share code, notes, and snippets.

@PolyacovYury
Last active September 27, 2020 21:05
Show Gist options
  • Save PolyacovYury/baa030fad571088e04301c654a2348ec to your computer and use it in GitHub Desktop.
Save PolyacovYury/baa030fad571088e04301c654a2348ec to your computer and use it in GitHub Desktop.
Replaces explicit vanilla chest ingredients with oreDict wildcards. Didn't work as intended, kept here for history
import crafttweaker.item.IIngredient;
val offending_items as IItemStack[] = [
<harvestcraft:groundtrap>, # 2 total recipes
<cfm:wall_cabinet> # 65 total recipes
];
val chest = <minecraft:chest>;
val trap_chest = <minecraft:trapped_chest>;
val chest_ore = <ore:chestWood>;
val trap_chest_ore = <ore:chestTrapped>;
var ingrs1D as IIngredient[] = [];
var ingrs2D as IIngredient[][] = [[]];
var name as string = "";
var needs_replace as bool = false;
for target in offending_items {
for recipe in recipes.getRecipesFor(target) {
needs_replace = false;
name = recipe.name;
if (recipe.shaped) {
ingrs2D = recipe.ingredients2D;
for i, ingrs in ingrs2D {
for j, ingr in ingrs {
if (ingr.matchesExact(chest)) {
ingrs2D[i][j] = chest_ore;
needs_replace = true;
} else if (ingr.matchesExact(trap_chest)) {
ingrs2D[i][j] = trap_chest_ore;
needs_replace = true;
}
}
}
} else {
ingrs1D = recipe.ingredients1D;
for i, ingr in ingrs1D {
if (ingr.matchesExact(chest)) {
ingrs1D[i] = chest_ore;
needs_replace = true;
} else if (ingr.matchesExact(trap_chest)) {
ingrs1D[i] = trap_chest_ore;
needs_replace = true;
}
}
}
if (needs_replace) {
recipes.removeByRecipeName(name);
if (recipe.shaped) {
recipes.addShaped(name, target, ingrs2D);
} else {
recipes.addShapeless(name, target, ingrs1D);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment