CraftTweaker

CraftTweaker

151M Downloads

Trying to replace empty slots in crafting table recibe

menguele opened this issue · 2 comments

commented

Issue description

I'm trying to replace the empty slots in the Thermal Machines recipe with Osmium Ingot from Mekanism. Tried many times already and I'm simply lost at this point.

Steps to reproduce

Replace <minecraft:air> with anything.

Replacing null in recipes.replaceAllOccurences() returns a NullPointerException

Script used

https://gist.github.com/menguele/70cbbb8fc021fac473bf84cc6101aa45

The crafttweaker.log file

https://gist.github.com/menguele/a5b9184f29a93d82633e05b0e97185e3

Minecraft version

1.12

Modloader

Forge

Modloader version

14.23.5.2860

CraftTweaker version

4.1.20.677

Other relevant information

LoliASM 5.4
FoamFix 0.10.14

The latest.log file

https://gist.github.com/menguele/0ace9fee51e9cdf8f2797df165976a63

commented

In 1.12 that's likely not possible, since <minecraft:air> did not exist.
Instead null was used everywhere.

What you could try to do is something like:

for rec in recipes.all if <thermalexpansion:machine:1>.matches(rec.output) {
    recipes.removeByName(rec.name);
    //Assuming recipes are all known to be shaped!
    val ingredients = rec.ingredients2d;
    //... modify the 2D array to replace the airs with your ingots
 
    val newName = //... calculate based on rec.name?
    recipes.addShapeless(newName, rec.output, ingredients);
}


// Depending on your preferred codestyle something like this may be easier to read
for rec in recipes.all {
    if (<thermalexpansion:machine:1>.matches(rec.output)) {
       //...
    }
}
commented

Fixed by 04671e0