Aspect Recipe Index Support (#63)

This commit is contained in:
koolkrafter5 authored and GitHub committed 2026-03-10 14:34:14 -04:00
1 parent e367164245
commit e1094ff70b
11 files changed
+171 -52

No files matched your search

@@ -188,9 +188,23 @@ public class NEINeeConfig implements IConfigureNEI {
NEEKnowledgeInscriberHandler.instance,
"arcaneshapelessrecipes");
} catch (ClassNotFoundException e) {
API.registerGuiOverlay(GuiKnowledgeInscriber.class, "thaumcraft.arcane.shaped");
API.registerGuiOverlay(GuiKnowledgeInscriber.class, "thaumcraft.arcane.shapeless");
API.registerGuiOverlay(GuiKnowledgeInscriber.class, "thaumcraft.wands");
API.registerGuiOverlayHandler(
GuiKnowledgeInscriber.class,
NEEKnowledgeInscriberHandler.instance,
"thaumcraft.arcane.shaped");
API.registerGuiOverlayHandler(
GuiKnowledgeInscriber.class,
NEEKnowledgeInscriberHandler.instance,
"thaumcraft.arcane.shapeless");
API.registerGuiOverlayHandler(
GuiKnowledgeInscriber.class,
NEEKnowledgeInscriberHandler.instance,
"thaumcraft.wands");
}
} catch (ClassNotFoundException ignored) {}
}
}
@@ -1,5 +1,8 @@
package com.github.vfyjxf.nee.nei;
import static com.github.vfyjxf.nee.processor.RecipeProcessor.AspectRecipeIndex_isLoaded;
import static com.github.vfyjxf.nee.processor.RecipeProcessor.TCNEIPlugin_isLoaded;
import java.util.List;
import java.util.stream.Collectors;
@@ -14,6 +17,8 @@ import com.github.vfyjxf.nee.utils.Ingredient;
import com.github.vfyjxf.nee.utils.IngredientTracker;
import com.github.vfyjxf.nee.utils.ItemUtils;
import com.github.vfyjxf.nee.utils.ModIDs;
import com.gtnewhorizons.aspectrecipeindex.nei.arcaneworkbench.ArcaneSlotPositioner;
import com.gtnewhorizons.aspectrecipeindex.nei.arcaneworkbench.ShapedArcaneRecipeHandler;
import appeng.util.Platform;
import codechicken.nei.ItemsTooltipLineHandler;
@@ -32,7 +37,7 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
*/
public class NEEKnowledgeInscriberHandler implements IOverlayHandler {
public class NEEArcaneOverlayButton extends NEETerminalOverlayButton {
public static class NEEArcaneOverlayButton extends NEETerminalOverlayButton {
public NEEArcaneOverlayButton(GuiOverlayButton button) {
super(button.firstGui, button.handlerRef, button.xPosition, button.yPosition);
@@ -82,7 +87,6 @@ public class NEEKnowledgeInscriberHandler implements IOverlayHandler {
private NEEKnowledgeInscriberHandler() {
try {
// "Knowledge Inscriber"
knowledgeInscriberClz = Class.forName("thaumicenergistics.client.gui.GuiKnowledgeInscriber");
} catch (ClassNotFoundException ignored) {}
@@ -104,57 +108,57 @@ public class NEEKnowledgeInscriberHandler implements IOverlayHandler {
final List<PositionedStack> ingredients = recipe.getIngredientStacks(recipeIndex);
if (itemAspectClz != null) {
// Aspect Recipe Index already does not include vis in the ingredients for arcane recipes so they do not
// need to be removed.
ingredients.removeIf(positionedStack -> itemAspectClz.isInstance(positionedStack.item.getItem()));
}
for (PositionedStack positionedStack : ingredients) {
if (positionedStack.items != null && positionedStack.items.length > 0) {
final int slotIndex = getSlotIndex(positionedStack.relx * 100 + positionedStack.rely);
final ItemStack[] currentStackList = positionedStack.items;
ItemStack stack = positionedStack.item;
for (ItemStack currentStack : currentStackList) {
if (Platform.isRecipePrioritized(currentStack)) {
stack = currentStack.copy();
}
}
recipeInputs.setTag("#" + slotIndex, ItemUtils.writeItemStackToNBT(stack, stack.stackSize));
// Also applies to shapeless and wand handlers through inheritance
if (AspectRecipeIndex_isLoaded && recipe instanceof ShapedArcaneRecipeHandler) {
for (PositionedStack ps : ingredients) {
addIndexedIngredient(ps, ArcaneSlotPositioner.getSlotIndex(ps), recipeInputs);
}
} else if (TCNEIPlugin_isLoaded) {
for (PositionedStack ps : ingredients) {
addIndexedIngredient(ps, getSlotIndex(ps.relx * 100 + ps.rely), recipeInputs);
}
}
return new PacketArcaneRecipe(recipeInputs);
}
private int getSlotIndex(int xy) {
switch (xy) {
case 7533:
return 1;
case 10333:
return 2;
case 4960:
return 3;
case 7660:
return 4;
case 10360:
return 5;
case 4987:
return 6;
case 7687:
return 7;
case 10387:
return 8;
case 4832:
default:
return 0;
private static void addIndexedIngredient(PositionedStack ps, int i, NBTTagCompound recipeInputs) {
if (ps.items != null && ps.items.length > 0) {
ItemStack stack = getPrioritizedItem(ps.items);
if (stack == null) return;
recipeInputs.setTag("#" + i, ItemUtils.writeItemStackToNBT(stack, stack.stackSize));
}
}
private static ItemStack getPrioritizedItem(ItemStack[] ps) {
for (ItemStack currentStack : ps) {
if (Platform.isRecipePrioritized(currentStack)) {
return currentStack.copy();
}
}
return ps[0];
}
private int getSlotIndex(int xy) {
return switch (xy) {
case 7533 -> 1;
case 10333 -> 2;
case 4960 -> 3;
case 7660 -> 4;
case 10360 -> 5;
case 4987 -> 6;
case 7687 -> 7;
case 10387 -> 8;
default -> 0;
};
}
@SubscribeEvent
public void onActionPerformedEventPost(GuiRecipeButton.UpdateRecipeButtonsEvent.Post event) {
if (NEEConfig.noShift && event.gui instanceof GuiRecipe guiRecipe) {
if (NEEConfig.noShift && event.gui instanceof GuiRecipe<?>guiRecipe) {
if (isGuiArcaneCraftingTerm(guiRecipe)) {
for (int i = 0; i < event.buttonList.size(); i++) {
if (event.buttonList.get(i) instanceof GuiOverlayButton btn) {
@@ -2,6 +2,7 @@ package com.github.vfyjxf.nee.network.packet;
import static com.github.vfyjxf.nee.nei.NEEPatternTerminalHandler.INPUT_KEY;
import static com.github.vfyjxf.nee.nei.NEEPatternTerminalHandler.OUTPUT_KEY;
import static com.github.vfyjxf.nee.processor.RecipeProcessor.AspectRecipeIndex_isLoaded;
import static com.github.vfyjxf.nee.processor.RecipeProcessor.TCNEIPlugin_isLoaded;
import static com.github.vfyjxf.nee.processor.RecipeProcessor.ThaumicEnergistics_isLoaded;
import static thaumicenergistics.common.storage.AEEssentiaStackType.ESSENTIA_STACK_ID;
@@ -200,11 +201,16 @@ public class PacketNEIPatternRecipe implements IMessage {
private IAEStack<?> getAEStack(final ItemStack is) {
if (StackInfo.itemStackToNBT(is).hasKey("gtFluidName")) {
return AEFluidStack.create(StackInfo.getFluid(is));
} else if (TCNEIPlugin_isLoaded && ThaumicEnergistics_isLoaded && is.getItem() instanceof ItemAspect) {
} else if (ThaumicEnergistics_isLoaded && isAspect(is)) {
return AEStackTypeRegistry.getType(ESSENTIA_STACK_ID).convertStackFromItem(is);
} else {
return AEItemStack.create(is);
}
}
private static boolean isAspect(ItemStack is) {
return (TCNEIPlugin_isLoaded && is.getItem() instanceof ItemAspect) || (AspectRecipeIndex_isLoaded
&& is.getItem() instanceof com.gtnewhorizons.aspectrecipeindex.common.items.ItemAspect);
}
}
}
@@ -0,0 +1,73 @@
package com.github.vfyjxf.nee.processor;
import static com.github.vfyjxf.nee.processor.RecipeProcessor.ThaumicEnergistics_isLoaded;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.annotation.Nonnull;
import com.gtnewhorizons.aspectrecipeindex.common.items.ItemAspect;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.IRecipeHandler;
/**
* @author vfyjxf
*/
public class AspectRecipeIndexRecipeProcessor implements IRecipeProcessor {
@Nonnull
@Override
public Set<String> getAllOverlayIdentifier() {
return new HashSet<>(
Arrays.asList(
"thaumcraft.arcane.shaped",
"thaumcraft.arcane.shapeless",
"thaumcraft.wands",
"thaumcraft.aspects",
"thaumcraft.alchemy",
"thaumcraft.infusion"));
}
@Nonnull
@Override
public String getRecipeProcessorId() {
return "aspectrecipeindex";
}
@Nonnull
@Override
public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) {
List<PositionedStack> recipeInputs = new ArrayList<>();
if (this.getAllOverlayIdentifier().contains(identifier)) {
recipeInputs.addAll(recipe.getIngredientStacks(recipeIndex));
if (!ThaumicEnergistics_isLoaded) {
recipeInputs.removeIf(positionedStack -> positionedStack.item.getItem() instanceof ItemAspect);
}
return recipeInputs;
}
return recipeInputs;
}
@Nonnull
@Override
public List<PositionedStack> getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) {
List<PositionedStack> recipeOutputs = new ArrayList<>();
if (this.getAllOverlayIdentifier().contains(identifier)) {
recipeOutputs.add(recipe.getResultStack(recipeIndex));
if (!ThaumicEnergistics_isLoaded) {
recipeOutputs.removeIf(positionedStack -> positionedStack.item.getItem() instanceof ItemAspect);
}
return recipeOutputs;
}
return recipeOutputs;
}
}
@@ -11,8 +11,9 @@ public class RecipeProcessor {
public static final String NULL_IDENTIFIER = "null";
public static List<IRecipeProcessor> recipeProcessors = new ArrayList<>();
public static boolean TCNEIPlugin_isLoaded = Loader.isModLoaded("thaumcraftneiplugin");
public static boolean ThaumicEnergistics_isLoaded = Loader.isModLoaded("thaumicenergistics");
public static final boolean TCNEIPlugin_isLoaded = Loader.isModLoaded("thaumcraftneiplugin");
public static final boolean ThaumicEnergistics_isLoaded = Loader.isModLoaded("thaumicenergistics");
public static final boolean AspectRecipeIndex_isLoaded = Loader.isModLoaded("aspectrecipeindex");
public static void init() {
NotEnoughEnergistics.logger.info("-----Not Enough Energistics Init Start-----");
@@ -60,6 +61,10 @@ public class RecipeProcessor {
NotEnoughEnergistics.logger.info("Found Forestry, install Forestry support");
recipeProcessors.add(new ForestryRecipeProcessor());
}
if (AspectRecipeIndex_isLoaded) {
NotEnoughEnergistics.logger.info("Found Aspect Recipe Index, install Aspect Recipe Index support");
recipeProcessors.add(new AspectRecipeIndexRecipeProcessor());
}
if (TCNEIPlugin_isLoaded) {
NotEnoughEnergistics.logger.info("Found TCNEIPlugin, install TCNEIPlugin support");
recipeProcessors.add(new TCNEIPluginRecipeProcessor());