Skip to content

Commit

Permalink
close #215
Browse files Browse the repository at this point in the history
  • Loading branch information
brachy84 committed Aug 12, 2024
1 parent fb945a6 commit b7a08ce
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,9 @@ public static class Compat {

@Config.Comment("Enables DE energy core compat. Config is mainly for other mods compat.")
public boolean draconicEvolutionEnergyCore = true;

@Config.Name("ExtendedCrafting recipe maker makes grs recipes")
@Config.Comment("If this is true, the recipe maker from ExtendedCrafting will produce a script for GroovyScript instead of CraftTweaker.")
public boolean extendedCraftingRecipeMakerMakesGrsRecipes = true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
import com.blakebr0.extendedcrafting.item.ItemRecipeMaker;
import com.blakebr0.extendedcrafting.lib.IExtendedTable;
import com.blakebr0.extendedcrafting.tile.TileEnderCrafter;
import com.cleanroommc.groovyscript.GroovyScriptConfig;
import com.cleanroommc.groovyscript.helper.ingredient.GroovyScriptCodeConverter;
import com.google.common.base.Joiner;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
Expand All @@ -28,6 +30,7 @@ public abstract class ItemRecipeMakerMixin {

@Inject(method = "setClipboard", at = @At("HEAD"), cancellable = true)
public void setClipboard(IExtendedTable table, ItemStack stack, CallbackInfoReturnable<Boolean> cir) {
if (!GroovyScriptConfig.compat.extendedCraftingRecipeMakerMakesGrsRecipes) return;
if (Desktop.isDesktopSupported()) {
boolean ender = table instanceof TileEnderCrafter;
StringBuilder string = (new StringBuilder("mods.extendedcrafting.")).append(ender ? "EnderCrafting" : "TableCrafting");
Expand All @@ -54,20 +57,21 @@ public void setClipboard(IExtendedTable table, ItemStack stack, CallbackInfoRetu
cir.setReturnValue(false);
}

@Unique
public String groovyscript$makeItemArrayShapeless(IExtendedTable table) {
StringBuilder builder = new StringBuilder();
boolean isEmpty = true;
for (ItemStack stack : table.getMatrix()) {
if (!stack.isEmpty()) {
builder.append(groovyscript$makeItem(stack))
.append(", ");
builder.append(groovyscript$makeItem(stack)).append(", ");
isEmpty = false;
}
}
if (isEmpty) return null;
return builder.delete(builder.length() - 2, builder.length()).toString();
}

@Unique
public String groovyscript$makeItemArrayShaped(IExtendedTable table, boolean removeEmpties) {
List<List<String>> matrix = new ArrayList<>();
int row = 0;
Expand Down

0 comments on commit b7a08ce

Please sign in to comment.