mirror of
https://github.com/GTNewHorizons/NotEnoughEnergistics.git
synced 2026-11-25 22:34:44 +00:00
fix bug
This commit is contained in:
1 parent
3a3671e0c6
commit
82945909c1
60 files changed
+1347
-90
No files matched your search
@@ -0,0 +1,44 @@
|
||||
package com.github.vfyjxf.nee;
|
||||
|
||||
import com.github.vfyjxf.nee.processor.IRecipeProcessor;
|
||||
import com.github.vfyjxf.nee.processor.RecipeProcessor;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.github.vfyjxf.nee.NotEnoughEnergistics.logger;
|
||||
|
||||
public class NEECommands extends CommandBase {
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "nee";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender sender) {
|
||||
return "use /nee RecipeProcessor to get RecipeProcessor and identifier,see them in log";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender sender, String[] args) {
|
||||
if (args.length != 0) {
|
||||
if ("RecipeProcessor".equals(args[0])) {
|
||||
for (IRecipeProcessor processor : RecipeProcessor.recipeProcessors) {
|
||||
logger.info("RecipeProcessor:" + processor.getRecipeProcessorId() + " identifier:");
|
||||
for (String ident : processor.getAllOverlayIdentifier()) {
|
||||
logger.info(ident);
|
||||
}
|
||||
}
|
||||
}
|
||||
}else {
|
||||
throw new WrongUsageException("use /nee RecipeProcessor to get RecipeProcessor and identifier,see them in log");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List addTabCompletionOptions(ICommandSender sender, String[] args) {
|
||||
return CommandBase.getListOfStringsMatchingLastWord(args, "RecipeProcessor");
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ public class NEEConfig {
|
||||
transformBlacklist = config.get("client", "transformItemBlacklist", new String[0],
|
||||
"If item in the blacklist, it will not be transferred.\n" +
|
||||
"the format is \" {modid:modid,name:name,meta:meta,recipeProcessor:recipeProcessorID,identifier:identifier}\"\n"+
|
||||
"example: \"{\"modid\":\"minecraft\",\"name\":\"iron_ingot\",\"recipeProcessor\":\"EnderIO\",\"identifier\":\"EnderIOAlloySmelter\"}\"").getStringList();
|
||||
"example: \"{modid:minecraft,name:iron_ingot,recipeProcessor:EnderIO,identifier:EnderIOAlloySmelter}\"").getStringList();
|
||||
transformPriorityList = config.get("client", "transformItemPriorityList", new String[0],
|
||||
"If item in tne priority list, it will be transferred first.").getStringList();
|
||||
|
||||
|
||||
@@ -97,4 +97,4 @@ public class NEINeeConfig implements IConfigureNEI {
|
||||
API.registerGuiOverlayHandler(GuiExtremeAutoCrafter.class, new NEECraftingHandler(), "extreme");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,15 @@
|
||||
package com.github.vfyjxf.nee;
|
||||
|
||||
import com.github.vfyjxf.nee.network.NEENetworkHandler;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerStartingEvent;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
|
||||
@Mod(modid = NotEnoughEnergistics.MODID,
|
||||
version = NotEnoughEnergistics.VERSION,
|
||||
@@ -16,13 +20,18 @@ public class NotEnoughEnergistics {
|
||||
public static final String MODID = "neenergistics";
|
||||
public static final String NAME = "NotEnoughEnergistics";
|
||||
public static final String VERSION = "@VERSION@";
|
||||
public static final String DEPENDENCIES = "required-after:jei;required-after:appliedenergistics2";
|
||||
public static final String DEPENDENCIES = "required-after:NotEnoughItems;required-after:appliedenergistics2";
|
||||
public static final Logger logger = LogManager.getLogger("NotEnoughEnergistics");
|
||||
|
||||
@Mod.EventHandler
|
||||
public void preInit(FMLPreInitializationEvent e) {
|
||||
NEENetworkHandler.init();
|
||||
NEEConfig.loadConfig(new File(Launch.minecraftHome, "config/NotEnoughEnergistics.cfg"));
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
private void serverStarting(FMLServerStartingEvent event) {
|
||||
event.registerServerCommand(new NEECommands());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -258,4 +258,4 @@ public class NEECraftingHandler implements IOverlayHandler {
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,4 +21,4 @@ public class NEENetworkHandler {
|
||||
INSTANCE.registerMessage(PacketExtremeRecipe.class, PacketExtremeRecipe.class, 2, Side.SERVER);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.github.vfyjxf.nee.network.packet;
|
||||
|
||||
import appeng.container.slot.SlotFakeCraftingMatrix;
|
||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import thaumicenergistics.common.container.ContainerKnowledgeInscriber;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
/**
|
||||
* @author vfyjxf
|
||||
*/
|
||||
public class PacketArcaneRecipe implements IMessage, IMessageHandler<PacketArcaneRecipe, IMessage> {
|
||||
|
||||
NBTTagCompound input;
|
||||
|
||||
public PacketArcaneRecipe() {}
|
||||
|
||||
public PacketArcaneRecipe(NBTTagCompound input) {
|
||||
this.input = input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
this.input = ByteBufUtils.readTag(buf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
ByteBufUtils.writeTag(buf, this.input);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketArcaneRecipe message, MessageContext ctx) {
|
||||
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
|
||||
Container container = player.openContainer;
|
||||
if (container instanceof ContainerKnowledgeInscriber) {
|
||||
ItemStack[] recipeInput = new ItemStack[9];
|
||||
NBTTagCompound currentStack;
|
||||
for (int i = 0; i < recipeInput.length; i++) {
|
||||
currentStack = (NBTTagCompound) message.input.getTag("#" + i);
|
||||
recipeInput[i] = currentStack == null ? null : ItemStack.loadItemStackFromNBT(currentStack);
|
||||
}
|
||||
|
||||
Field craftingSlots = ReflectionHelper.findField(ContainerKnowledgeInscriber.class, "craftingSlots");
|
||||
SlotFakeCraftingMatrix[] craftMatrix = getCraftingSlots(craftingSlots, (ContainerKnowledgeInscriber) container);
|
||||
if (craftMatrix != null && message.input != null) {
|
||||
for (int i = 0; i < recipeInput.length; i++) {
|
||||
ItemStack currentItem = null;
|
||||
if (recipeInput[i] != null) {
|
||||
currentItem = recipeInput[i].copy();
|
||||
}
|
||||
craftMatrix[i].putStack(currentItem);
|
||||
}
|
||||
((ContainerKnowledgeInscriber) container).func_75130_a(craftMatrix[0].inventory);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private SlotFakeCraftingMatrix[] getCraftingSlots(Field field, ContainerKnowledgeInscriber container) {
|
||||
try {
|
||||
return (SlotFakeCraftingMatrix[]) field.get(container);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -94,4 +94,4 @@ public class PacketExtremeRecipe implements IMessage, IMessageHandler<PacketExtr
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
package com.github.vfyjxf.nee.network.packet;
|
||||
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.security.ISecurityGrid;
|
||||
import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.container.implementations.ContainerPatternTerm;
|
||||
import appeng.container.implementations.ContainerPatternTermEx;
|
||||
import appeng.helpers.IContainerCraftingPacket;
|
||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import static com.github.vfyjxf.nee.nei.NEECraftingHandler.OUTPUT_KEY;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
|
||||
public class PacketNEIPatternRecipe implements IMessage, IMessageHandler<PacketNEIPatternRecipe, IMessage> {
|
||||
|
||||
NBTTagCompound input;
|
||||
NBTTagCompound output;
|
||||
|
||||
public PacketNEIPatternRecipe() {}
|
||||
|
||||
public PacketNEIPatternRecipe(@Nonnull NBTTagCompound input, NBTTagCompound output) {
|
||||
this.input = input;
|
||||
this.output = output;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
this.input = ByteBufUtils.readTag(buf);
|
||||
if (buf.readBoolean()) {
|
||||
this.output = ByteBufUtils.readTag(buf);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
ByteBufUtils.writeTag(buf, this.input);
|
||||
if (this.output != null) {
|
||||
buf.writeBoolean(true);
|
||||
ByteBufUtils.writeTag(buf, this.output);
|
||||
} else {
|
||||
buf.writeBoolean(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketNEIPatternRecipe message, MessageContext ctx) {
|
||||
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
|
||||
Container container = player.openContainer;
|
||||
if (container instanceof ContainerPatternTerm && message.output == null) {
|
||||
((ContainerPatternTerm) container).getPatternTerminal().setCraftingRecipe(true);
|
||||
message.craftingTableRecipeHandler((ContainerPatternTerm) container, message);
|
||||
} else if (container instanceof ContainerPatternTerm) {
|
||||
((ContainerPatternTerm) container).getPatternTerminal().setCraftingRecipe(false);
|
||||
message.processRecipeHandler((ContainerPatternTerm) container, message);
|
||||
} else if (container instanceof ContainerPatternTermEx && message.output != null){
|
||||
((ContainerPatternTermEx) container).getPatternTerminal().setInverted(false);
|
||||
message.processRecipeHandler((ContainerPatternTermEx) container,message);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void craftingTableRecipeHandler(ContainerPatternTerm container, PacketNEIPatternRecipe message) {
|
||||
ItemStack[] recipeInput = new ItemStack[9];
|
||||
NBTTagCompound currentStack;
|
||||
|
||||
|
||||
for (int i = 0; i < recipeInput.length; i++) {
|
||||
currentStack = (NBTTagCompound) message.input.getTag("#" + i);
|
||||
recipeInput[i] = currentStack == null ? null : ItemStack.loadItemStackFromNBT(currentStack);
|
||||
}
|
||||
|
||||
final IContainerCraftingPacket cct = container;
|
||||
final IGridNode node = cct.getNetworkNode();
|
||||
|
||||
if (node != null) {
|
||||
final IGrid grid = node.getGrid();
|
||||
if (grid == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final IStorageGrid inv = grid.getCache(IStorageGrid.class);
|
||||
final ISecurityGrid security = grid.getCache(ISecurityGrid.class);
|
||||
final IInventory craftMatrix = cct.getInventoryByName("crafting");
|
||||
|
||||
if (inv != null && message.input != null && security != null) {
|
||||
for (int i = 0; i < craftMatrix.getSizeInventory(); i++) {
|
||||
ItemStack currentItem = null;
|
||||
if (recipeInput[i] != null) {
|
||||
currentItem = recipeInput[i].copy();
|
||||
}
|
||||
craftMatrix.setInventorySlotContents(i, currentItem);
|
||||
}
|
||||
container.onCraftMatrixChanged(craftMatrix);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void processRecipeHandler(ContainerPatternTerm container, PacketNEIPatternRecipe message) {
|
||||
|
||||
ItemStack[] recipeInput = new ItemStack[9];
|
||||
ItemStack[] recipeOutput = new ItemStack[3];
|
||||
|
||||
|
||||
for (int i = 0; i < recipeInput.length; i++) {
|
||||
NBTTagCompound currentStack = (NBTTagCompound) message.input.getTag("#" + i);
|
||||
recipeInput[i] = currentStack == null ? null : ItemStack.loadItemStackFromNBT(currentStack);
|
||||
}
|
||||
|
||||
for (int i = 0; i < recipeOutput.length; i++) {
|
||||
NBTTagCompound currentStack = (NBTTagCompound) message.output.getTag(OUTPUT_KEY + i);
|
||||
recipeOutput[i] = currentStack == null ? null : ItemStack.loadItemStackFromNBT(currentStack);
|
||||
}
|
||||
|
||||
final IContainerCraftingPacket cct = container;
|
||||
final IGridNode node = cct.getNetworkNode();
|
||||
|
||||
if (node != null) {
|
||||
final IGrid grid = node.getGrid();
|
||||
if (grid == null) {
|
||||
return;
|
||||
}
|
||||
final IStorageGrid inv = grid.getCache(IStorageGrid.class);
|
||||
final ISecurityGrid security = grid.getCache(ISecurityGrid.class);
|
||||
final IInventory craftMatrix = cct.getInventoryByName("crafting");
|
||||
final IInventory outputMatrix = cct.getInventoryByName("output");
|
||||
|
||||
if (inv != null && message.input != null && security != null) {
|
||||
for (int i = 0; i < craftMatrix.getSizeInventory(); i++) {
|
||||
ItemStack currentItem = null;
|
||||
if (recipeInput[i] != null) {
|
||||
currentItem = recipeInput[i].copy();
|
||||
}
|
||||
craftMatrix.setInventorySlotContents(i, currentItem);
|
||||
}
|
||||
|
||||
for (int i = 0; i < outputMatrix.getSizeInventory(); i++) {
|
||||
ItemStack currentItem = null;
|
||||
if (recipeOutput[i] != null) {
|
||||
currentItem = recipeOutput[i].copy();
|
||||
}
|
||||
outputMatrix.setInventorySlotContents(i, currentItem);
|
||||
}
|
||||
container.onCraftMatrixChanged(craftMatrix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void processRecipeHandler(ContainerPatternTermEx container, PacketNEIPatternRecipe message) {
|
||||
|
||||
ItemStack[] recipeInput = new ItemStack[16];
|
||||
ItemStack[] recipeOutput = new ItemStack[4];
|
||||
|
||||
|
||||
for (int i = 0; i < recipeInput.length; i++) {
|
||||
NBTTagCompound currentStack = (NBTTagCompound) message.input.getTag("#" + i);
|
||||
recipeInput[i] = currentStack == null ? null : ItemStack.loadItemStackFromNBT(currentStack);
|
||||
}
|
||||
|
||||
for (int i = 0; i < recipeOutput.length; i++) {
|
||||
NBTTagCompound currentStack = (NBTTagCompound) message.output.getTag(OUTPUT_KEY + i);
|
||||
recipeOutput[i] = currentStack == null ? null : ItemStack.loadItemStackFromNBT(currentStack);
|
||||
}
|
||||
|
||||
final IContainerCraftingPacket cct = container;
|
||||
final IGridNode node = cct.getNetworkNode();
|
||||
|
||||
if (node != null) {
|
||||
final IGrid grid = node.getGrid();
|
||||
if (grid == null) {
|
||||
return;
|
||||
}
|
||||
final IStorageGrid inv = grid.getCache(IStorageGrid.class);
|
||||
final ISecurityGrid security = grid.getCache(ISecurityGrid.class);
|
||||
final IInventory craftMatrix = cct.getInventoryByName("crafting");
|
||||
final IInventory outputMatrix = cct.getInventoryByName("output");
|
||||
|
||||
if (inv != null && message.input != null && security != null) {
|
||||
for (int i = 0; i < craftMatrix.getSizeInventory(); i++) {
|
||||
ItemStack currentItem = null;
|
||||
if (recipeInput[i] != null) {
|
||||
currentItem = recipeInput[i].copy();
|
||||
}
|
||||
craftMatrix.setInventorySlotContents(i, currentItem);
|
||||
}
|
||||
|
||||
for (int i = 0; i < recipeOutput.length; i++) {
|
||||
ItemStack currentItem = null;
|
||||
if (recipeOutput[i] != null) {
|
||||
currentItem = recipeOutput[i].copy();
|
||||
}
|
||||
outputMatrix.setInventorySlotContents(i, currentItem);
|
||||
}
|
||||
container.onCraftMatrixChanged(craftMatrix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.github.vfyjxf.nee.processor;
|
||||
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class AvaritiaRecipeProcessor implements IRecipeProcessor {
|
||||
@Override
|
||||
public Set<String> getAllOverlayIdentifier() {
|
||||
return new HashSet<>(Arrays.asList(
|
||||
"extreme", "extreme_compression"
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeProcessorId() {
|
||||
return "Avaritia";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) {
|
||||
for (String ident : getAllOverlayIdentifier()) {
|
||||
if (ident.equals(identifier)) {
|
||||
return new ArrayList<>(recipe.getIngredientStacks(recipeIndex));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) {
|
||||
for (String ident : getAllOverlayIdentifier()) {
|
||||
if (ident.equals(identifier)) {
|
||||
List<PositionedStack> recipeOutput = new ArrayList<>();
|
||||
recipeOutput.add(recipe.getResultStack(recipeIndex));
|
||||
return recipeOutput;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.github.vfyjxf.nee.processor;
|
||||
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author vfyjxf
|
||||
*/
|
||||
public class BloodMagicRecipeProcessor implements IRecipeProcessor {
|
||||
@Override
|
||||
public Set<String> getAllOverlayIdentifier() {
|
||||
return new HashSet<>(Arrays.asList(
|
||||
"altarrecipes",
|
||||
"alchemicalwizardry.alchemy",
|
||||
"alchemicalwizardry.bindingritual"
|
||||
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeProcessorId() {
|
||||
return "BloodMagic";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) {
|
||||
for (String ident : getAllOverlayIdentifier()) {
|
||||
if (ident.equals(identifier)) {
|
||||
return new ArrayList<>(recipe.getIngredientStacks(recipeIndex));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) {
|
||||
for (String ident : getAllOverlayIdentifier()) {
|
||||
if (ident.equals(identifier)) {
|
||||
List<PositionedStack> recipeOutputs = new ArrayList<>();
|
||||
recipeOutputs.add(recipe.getResultStack(recipeIndex));
|
||||
return recipeOutputs;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.github.vfyjxf.nee.processor;
|
||||
|
||||
import buildcraft.compat.nei.RecipeHandlerAssemblyTable;
|
||||
import buildcraft.compat.nei.RecipeHandlerIntegrationTable;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author vfyjxf
|
||||
*/
|
||||
public class BuildCraftRecipeProcessor implements IRecipeProcessor {
|
||||
|
||||
@Override
|
||||
public String getRecipeProcessorId() {
|
||||
return "BuildCraft";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) {
|
||||
if (recipe instanceof RecipeHandlerAssemblyTable) {
|
||||
return handlerAssemblyTableRecipe((RecipeHandlerAssemblyTable) recipe, recipeIndex, true);
|
||||
} else if (recipe instanceof RecipeHandlerIntegrationTable) {
|
||||
return handlerIntegrationTableRecipe((RecipeHandlerIntegrationTable) recipe, recipeIndex, true);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) {
|
||||
if (recipe instanceof RecipeHandlerAssemblyTable) {
|
||||
return handlerAssemblyTableRecipe((RecipeHandlerAssemblyTable) recipe, recipeIndex, false);
|
||||
} else if (recipe instanceof RecipeHandlerIntegrationTable) {
|
||||
return handlerIntegrationTableRecipe((RecipeHandlerIntegrationTable) recipe, recipeIndex, false);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<PositionedStack> handlerAssemblyTableRecipe(RecipeHandlerAssemblyTable recipe, int recipeIndex, boolean getInput) {
|
||||
return getInput ? recipe.getIngredientStacks(recipeIndex) : Collections.singletonList(recipe.getResultStack(recipeIndex));
|
||||
}
|
||||
|
||||
private List<PositionedStack> handlerIntegrationTableRecipe(RecipeHandlerIntegrationTable recipe, int recipeIndex, boolean getInput) {
|
||||
return getInput ? recipe.getIngredientStacks(recipeIndex) : Collections.singletonList(recipe.getResultStack(recipeIndex));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.github.vfyjxf.nee.processor;
|
||||
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
import crazypants.enderio.nei.SagMillRecipeHandler;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class EnderIORecipeProcessor implements IRecipeProcessor {
|
||||
@Override
|
||||
public Set<String> getAllOverlayIdentifier() {
|
||||
return new HashSet<>(Arrays.asList(
|
||||
"EnderIOAlloySmelter", "EIOEnchanter", "EnderIOSagMill",
|
||||
"EnderIOSliceAndSplice", "EnderIOSoulBinder", "EnderIOVat"
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeProcessorId() {
|
||||
return "EnderIO";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) {
|
||||
for (String ident : getAllOverlayIdentifier()) {
|
||||
if (ident.equals(identifier)) {
|
||||
return new ArrayList<>(recipe.getIngredientStacks(recipeIndex));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) {
|
||||
if(identifier!=null) {
|
||||
for (String ident : getAllOverlayIdentifier()) {
|
||||
if (ident.equals(identifier)) {
|
||||
List<PositionedStack> recipeOutputs = new ArrayList<>();
|
||||
recipeOutputs.add(recipe.getResultStack(recipeIndex));
|
||||
recipeOutputs.addAll(recipe.getOtherStacks(recipeIndex));
|
||||
//remove output if it's chance != 1
|
||||
if(recipe instanceof SagMillRecipeHandler){
|
||||
SagMillRecipeHandler.MillRecipe millRecipe = (SagMillRecipeHandler.MillRecipe) ((SagMillRecipeHandler) recipe).arecipes.get(recipeIndex);
|
||||
recipeOutputs.removeIf(positionedStack -> millRecipe.getChanceForOutput(positionedStack.item) != 1.0F);
|
||||
}
|
||||
return recipeOutputs;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package com.github.vfyjxf.nee.processor;
|
||||
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
import forestry.factory.recipes.nei.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class ForestryRecipeProcessor implements IRecipeProcessor {
|
||||
|
||||
@Override
|
||||
public String getRecipeProcessorId() {
|
||||
return "Forestry";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) {
|
||||
if (recipe instanceof NEIHandlerBottler) {
|
||||
|
||||
return bottlerHandler((NEIHandlerBottler) recipe, recipeIndex, true);
|
||||
|
||||
} else if (recipe instanceof NEIHandlerCarpenter) {
|
||||
|
||||
return carpenterHandler((NEIHandlerCarpenter) recipe, recipeIndex, true);
|
||||
|
||||
} else if (recipe instanceof NEIHandlerCentrifuge) {
|
||||
|
||||
return centrifugeHandler((NEIHandlerCentrifuge) recipe, recipeIndex, true);
|
||||
|
||||
} else if (recipe instanceof NEIHandlerFabricator) {
|
||||
|
||||
return fabricatorHandler((NEIHandlerFabricator) recipe, recipeIndex, true);
|
||||
|
||||
} else if (recipe instanceof NEIHandlerMoistener) {
|
||||
|
||||
return moistenerHandler((NEIHandlerMoistener) recipe, recipeIndex, true);
|
||||
|
||||
} else if (recipe instanceof NEIHandlerSqueezer) {
|
||||
|
||||
return squeezerHandler((NEIHandlerSqueezer) recipe, recipeIndex, true);
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) {
|
||||
if (recipe instanceof NEIHandlerBottler) {
|
||||
|
||||
return bottlerHandler((NEIHandlerBottler) recipe, recipeIndex, false);
|
||||
|
||||
} else if (recipe instanceof NEIHandlerCarpenter) {
|
||||
|
||||
return carpenterHandler((NEIHandlerCarpenter) recipe, recipeIndex, false);
|
||||
|
||||
} else if (recipe instanceof NEIHandlerCentrifuge) {
|
||||
|
||||
return centrifugeHandler((NEIHandlerCentrifuge) recipe, recipeIndex, false);
|
||||
|
||||
} else if (recipe instanceof NEIHandlerFabricator) {
|
||||
|
||||
return fabricatorHandler((NEIHandlerFabricator) recipe, recipeIndex, false);
|
||||
|
||||
} else if (recipe instanceof NEIHandlerMoistener) {
|
||||
|
||||
return moistenerHandler((NEIHandlerMoistener) recipe, recipeIndex, false);
|
||||
|
||||
} else if (recipe instanceof NEIHandlerSqueezer) {
|
||||
|
||||
return squeezerHandler((NEIHandlerSqueezer) recipe, recipeIndex, false);
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<PositionedStack> bottlerHandler(NEIHandlerBottler base, int recipeIndex, boolean getInput) {
|
||||
return getInput ? base.getIngredientStacks(recipeIndex) : Collections.singletonList(base.getResultStack(recipeIndex));
|
||||
}
|
||||
|
||||
private List<PositionedStack> carpenterHandler(NEIHandlerCarpenter base, int recipeIndex, boolean getInput) {
|
||||
return getInput ? base.getIngredientStacks(recipeIndex) : Collections.singletonList(base.getResultStack(recipeIndex));
|
||||
}
|
||||
|
||||
private List<PositionedStack> centrifugeHandler(NEIHandlerCentrifuge base, int recipeIndex, boolean getInput) {
|
||||
return getInput ? base.getIngredientStacks(recipeIndex) : base.getOtherStacks(recipeIndex);
|
||||
}
|
||||
|
||||
private List<PositionedStack> fabricatorHandler(NEIHandlerFabricator base, int recipeIndex, boolean getInput) {
|
||||
List<PositionedStack> recipeInput = new ArrayList<>(base.getIngredientStacks(recipeIndex));
|
||||
recipeInput.addAll(base.getOtherStacks(recipeIndex));
|
||||
return getInput ? recipeInput : Collections.singletonList(base.getResultStack(recipeIndex));
|
||||
}
|
||||
|
||||
//Fermenter doesn't support, because it doesn't has a item output
|
||||
|
||||
private List<PositionedStack> moistenerHandler(NEIHandlerMoistener base, int recipeIndex, boolean getInput) {
|
||||
List<PositionedStack> recipeInput = new ArrayList<>(base.getIngredientStacks(recipeIndex));
|
||||
recipeInput.addAll(base.getOtherStacks(recipeIndex));
|
||||
return getInput ? recipeInput : Collections.singletonList(base.getResultStack(recipeIndex));
|
||||
}
|
||||
|
||||
private List<PositionedStack> squeezerHandler(NEIHandlerSqueezer base, int recipeIndex, boolean getInput) {
|
||||
return getInput ? base.getIngredientStacks(recipeIndex) : Collections.singletonList(base.getResultStack(recipeIndex));
|
||||
}
|
||||
//Still doesn't need support
|
||||
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package com.github.vfyjxf.nee.processor;
|
||||
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
import gregtech.api.enums.ItemList;
|
||||
import gregtech.api.util.GT_Recipe;
|
||||
import gregtech.api.util.GT_Utility;
|
||||
import gregtech.nei.GT_NEI_DefaultHandler.FixedPositionedStack;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author vfyjxf
|
||||
*/
|
||||
public class GregTech5RecipeProcessor implements IRecipeProcessor {
|
||||
|
||||
private static final Class<?> gtDefaultClz, gtAssLineClz;
|
||||
|
||||
static {
|
||||
Class<?> gtDH = null;
|
||||
Class<?> gtAL = null;
|
||||
try {
|
||||
gtDH = Class.forName("gregtech.nei.GT_NEI_DefaultHandler");
|
||||
gtAL = Class.forName("gregtech.nei.GT_NEI_AssLineHandler");
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
gtDefaultClz = gtDH;
|
||||
gtAssLineClz = gtAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getAllOverlayIdentifier() {
|
||||
|
||||
Set<String> identifiers = new HashSet<>();
|
||||
for (GT_Recipe.GT_Recipe_Map tMap : GT_Recipe.GT_Recipe_Map.sMappings) {
|
||||
if (tMap.mNEIAllowed) {
|
||||
identifiers.add(tMap.mNEIName);
|
||||
}
|
||||
}
|
||||
identifiers.add("gt.recipe.fakeAssemblylineProcess");
|
||||
return identifiers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeProcessorId() {
|
||||
return "GregTech5";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) {
|
||||
|
||||
if (gtDefaultClz.isInstance(recipe) || gtAssLineClz.isInstance(recipe)) {
|
||||
List<PositionedStack> recipeInputs = new ArrayList<>(recipe.getIngredientStacks(recipeIndex));
|
||||
recipeInputs.removeIf(positionedStack -> getFluidFromDisplayStack(positionedStack.items[0]) != null || positionedStack.item.stackSize == 0);
|
||||
if (!recipeInputs.isEmpty()) {
|
||||
ItemStack specialItem = recipeInputs.get(recipeInputs.size() - 1).items[0];
|
||||
if ((specialItem.isItemEqual(ItemList.Tool_DataStick.get(1)) || specialItem.isItemEqual(ItemList.Tool_DataOrb.get(1)) && (recipe.getRecipeName().equals("gt.recipe.scanner") || recipe.getRecipeName().equals("gt.recipe.fakeAssemblylineProcess"))))
|
||||
recipeInputs.remove(recipeInputs.size() - 1);
|
||||
}
|
||||
return recipeInputs;
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) {
|
||||
if (gtDefaultClz.isInstance(recipe) || gtAssLineClz.isInstance(recipe)) {
|
||||
List<PositionedStack> recipeOutputs = new ArrayList<>(recipe.getOtherStacks(recipeIndex));
|
||||
recipeOutputs.removeIf(positionedStack -> getFluidFromDisplayStack(positionedStack.items[0]) != null);
|
||||
//remove output if it's chance != 10000
|
||||
recipeOutputs.removeIf(stack -> stack instanceof FixedPositionedStack && !(((FixedPositionedStack) stack).mChance == 10000 || ((FixedPositionedStack) stack).mChance <= 0));
|
||||
return recipeOutputs;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* For resolving NoSuchMethodError
|
||||
* Copied from GTNewHorizons/GT5-Unofficial.
|
||||
*/
|
||||
public static FluidStack getFluidFromDisplayStack(ItemStack aDisplayStack) {
|
||||
if (!isStackValid(aDisplayStack) ||
|
||||
aDisplayStack.getItem() != ItemList.Display_Fluid.getItem() ||
|
||||
!aDisplayStack.hasTagCompound()) {
|
||||
return null;
|
||||
}
|
||||
Fluid tFluid = FluidRegistry.getFluid(ItemList.Display_Fluid.getItem().getDamage(aDisplayStack));
|
||||
return new FluidStack(tFluid, (int) aDisplayStack.getTagCompound().getLong("mFluidDisplayAmount"));
|
||||
}
|
||||
public static boolean isStackValid(Object aStack) {
|
||||
return (aStack instanceof ItemStack) && ((ItemStack) aStack).getItem() != null && ((ItemStack) aStack).stackSize >= 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.github.vfyjxf.nee.processor;
|
||||
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
import gregapi.NEI_RecipeMap;
|
||||
import gregapi.NEI_RecipeMap.FixedPositionedStack;
|
||||
import gregapi.data.FL;
|
||||
import gregapi.recipes.Recipe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author vfyjxf
|
||||
*/
|
||||
public class GregTech6RecipeProcessor implements IRecipeProcessor {
|
||||
@Override
|
||||
public Set<String> getAllOverlayIdentifier() {
|
||||
Set<String> identifiers = new HashSet<>();
|
||||
for (Recipe.RecipeMap tMap : Recipe.RecipeMap.RECIPE_MAPS.values()) {
|
||||
if (tMap.mNEIAllowed) {
|
||||
identifiers.add(tMap.mNameNEI);
|
||||
}
|
||||
}
|
||||
return identifiers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeProcessorId() {
|
||||
return "GregTech6";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) {
|
||||
for (String ident : getAllOverlayIdentifier()) {
|
||||
if (ident.equals(identifier)) {
|
||||
List<PositionedStack> recipeInputs = new ArrayList<>(recipe.getIngredientStacks(recipeIndex));
|
||||
//remove fluid
|
||||
recipeInputs.removeIf(positionedStack -> FL.getFluid(positionedStack.item, true) != null || positionedStack.item.stackSize == 0);
|
||||
//try to remove machine
|
||||
if (recipe instanceof NEI_RecipeMap) {
|
||||
Field mRecipeMapField = ReflectionHelper.findField(NEI_RecipeMap.class, "mRecipeMap");
|
||||
Recipe.RecipeMap mRecipeMap = null;
|
||||
try {
|
||||
mRecipeMap = (Recipe.RecipeMap) mRecipeMapField.get(recipe);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (mRecipeMap != null) {
|
||||
ItemStack lastItem = (recipeInputs.get(recipeInputs.size() - 1)).items[0];
|
||||
for (ItemStack stack : mRecipeMap.mRecipeMachineList) {
|
||||
if (ItemStack.areItemStackTagsEqual(lastItem, stack)) {
|
||||
recipeInputs.remove(recipeInputs.size() - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return recipeInputs;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) {
|
||||
for (String ident : getAllOverlayIdentifier()) {
|
||||
if (ident.equals(identifier)) {
|
||||
List<PositionedStack> recipeOutput = new ArrayList<>(recipe.getOtherStacks(recipeIndex));
|
||||
recipeOutput.removeIf(positionedStack -> FL.getFluid(positionedStack.item, true) != null || positionedStack.item.stackSize == 0);
|
||||
//try to remove item output if it's chance != 100%
|
||||
recipeOutput.removeIf(positionedStack -> positionedStack instanceof FixedPositionedStack && ((FixedPositionedStack) positionedStack).mChance > 0 && ((FixedPositionedStack) positionedStack).mChance != ((FixedPositionedStack) positionedStack).mMaxChance);
|
||||
return recipeOutput;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.github.vfyjxf.nee.processor;
|
||||
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author vfyjxf
|
||||
*/
|
||||
public class ICRecipeProcessor implements IRecipeProcessor {
|
||||
@Override
|
||||
public Set<String> getAllOverlayIdentifier() {
|
||||
return new HashSet<>(Arrays.asList(
|
||||
"blastfurnace", "BlockCutter", "centrifuge", "compressor",
|
||||
"extractor", "fluidcanner", "macerator",
|
||||
"metalformer", "oreWashing", "solidcanner"
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeProcessorId() {
|
||||
return "IC2";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) {
|
||||
for (String ident : getAllOverlayIdentifier()) {
|
||||
if (ident.equals(identifier)) {
|
||||
return new ArrayList<>(recipe.getIngredientStacks(recipeIndex));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) {
|
||||
for (String ident : getAllOverlayIdentifier()) {
|
||||
if (ident.equals(identifier)) {
|
||||
List<PositionedStack> recipeOutputs = new ArrayList<>();
|
||||
recipeOutputs.add(recipe.getResultStack(recipeIndex));
|
||||
recipeOutputs.addAll(recipe.getOtherStacks(recipeIndex));
|
||||
return recipeOutputs;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.github.vfyjxf.nee.processor;
|
||||
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
import com.github.vfyjxf.nee.network.packet.PacketNEIPatternRecipe;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author vfyjxf
|
||||
*/
|
||||
public interface IRecipeProcessor {
|
||||
|
||||
|
||||
default Set<String> getAllOverlayIdentifier(){
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
String getRecipeProcessorId();
|
||||
|
||||
List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier);
|
||||
|
||||
List<PositionedStack> getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier);
|
||||
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
package com.github.vfyjxf.nee.processor;
|
||||
|
||||
import blusunrize.immersiveengineering.client.nei.NEICrusherHandler.CachedCrusherRecipe;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author vfyjxf
|
||||
*/
|
||||
public class ImmersiveEngineeringRecipeProcessor implements IRecipeProcessor {
|
||||
@Override
|
||||
public Set<String> getAllOverlayIdentifier() {
|
||||
return new HashSet<>(Arrays.asList(
|
||||
"ieArcFurnace", "ieBlastFurnace", "ieBlueprintCrafting",
|
||||
"ieBottlingMachine", "ieCokeOven", "ieCrusher",
|
||||
"ieFermenter", "ieHammerCrushing", "ieMetalPress",
|
||||
"ieRefinery", "ieShaderBag", "ieSqueezer"
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeProcessorId() {
|
||||
return "ImmersiveEngineering";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) {
|
||||
for (String ident : getAllOverlayIdentifier()) {
|
||||
if (ident.equals(identifier)) {
|
||||
List<PositionedStack> recipeInputs = new ArrayList<>(recipe.getIngredientStacks(recipeIndex));
|
||||
if (!("ieArcFurnace".equals(identifier) || "ieCrusher".equals(identifier) || "ieBlastFurnace".equals(identifier))) {
|
||||
recipeInputs.addAll(recipe.getOtherStacks(recipeIndex));
|
||||
}
|
||||
return recipeInputs;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) {
|
||||
for (String ident : getAllOverlayIdentifier()) {
|
||||
if (ident.equals(identifier)) {
|
||||
List<PositionedStack> recipeOutputs = new ArrayList<>();
|
||||
recipeOutputs.add(recipe.getResultStack(recipeIndex));
|
||||
if ("ieArcFurnace".equals(identifier) || "ieCrusher".equals(identifier)) {
|
||||
recipeOutputs.addAll(recipe.getOtherStacks(recipeIndex));
|
||||
}
|
||||
return recipeOutputs;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.github.vfyjxf.nee.processor;
|
||||
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author vfyjxf
|
||||
*/
|
||||
public class MekanismRecipeProcessor implements IRecipeProcessor {
|
||||
@Override
|
||||
public Set<String> getAllOverlayIdentifier() {
|
||||
return new HashSet<>(Arrays.asList(
|
||||
"chemicalinfuser", "chemicalinjectionchamber",
|
||||
"chemicaloxidizer", "chemicalwasher", "combiner", "crusher", "electrolyticseparator",
|
||||
"chamber", "infuser", "compressor", "prc", "precisionsawmill", "purificationchamber",
|
||||
"rotarycondensentrator", "solarneutron", "thermalevaporation"
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeProcessorId() {
|
||||
return "Mekanism";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) {
|
||||
for (String ident : getAllOverlayIdentifier()) {
|
||||
if (ident.equals(identifier)) {
|
||||
List<PositionedStack> recipeInputs = new ArrayList<>(recipe.getIngredientStacks(recipeIndex));
|
||||
if (!recipe.getOtherStacks(recipeIndex).isEmpty()) {
|
||||
recipeInputs.addAll(recipe.getOtherStacks(recipeIndex));
|
||||
}
|
||||
return recipeInputs;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) {
|
||||
for (String ident : getAllOverlayIdentifier()) {
|
||||
if (ident.equals(identifier)) {
|
||||
List<PositionedStack> recipeOutputs = new ArrayList<>();
|
||||
recipeOutputs.add(recipe.getResultStack(recipeIndex));
|
||||
return recipeOutputs;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.github.vfyjxf.nee.processor;
|
||||
|
||||
import com.github.vfyjxf.nee.NotEnoughEnergistics;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class RecipeProcessor {
|
||||
public static List<IRecipeProcessor> recipeProcessors = new ArrayList<>();
|
||||
|
||||
public static void init() {
|
||||
NotEnoughEnergistics.logger.info("-----Not Enough Energistics Init Start-----");
|
||||
NotEnoughEnergistics.logger.info("Install Vanilla Support");
|
||||
recipeProcessors.add(new VanillaRecipeProcessor());
|
||||
|
||||
if (Loader.isModLoaded("gregtech") && !Loader.isModLoaded("gregapi")) {
|
||||
NotEnoughEnergistics.logger.info("Found GregTech5,install GregTech5 support");
|
||||
recipeProcessors.add(new GregTech5RecipeProcessor());
|
||||
}
|
||||
if (Loader.isModLoaded("gregapi") && Loader.isModLoaded("gregapi_post")) {
|
||||
NotEnoughEnergistics.logger.info("Found GregTech6,install GregTech6 support");
|
||||
recipeProcessors.add(new GregTech6RecipeProcessor());
|
||||
}
|
||||
if (Loader.isModLoaded("IC2")) {
|
||||
NotEnoughEnergistics.logger.info("Found IC2,install IC2 Support");
|
||||
recipeProcessors.add(new ICRecipeProcessor());
|
||||
}
|
||||
if (Loader.isModLoaded("Avaritia")) {
|
||||
NotEnoughEnergistics.logger.info("Found Avaritia, install Avaritia support");
|
||||
recipeProcessors.add(new AvaritiaRecipeProcessor());
|
||||
}
|
||||
if (Loader.isModLoaded("EnderIO")) {
|
||||
NotEnoughEnergistics.logger.info("Found EnderIO, install EnderIO support");
|
||||
recipeProcessors.add(new EnderIORecipeProcessor());
|
||||
}
|
||||
if (Loader.isModLoaded("Forestry")) {
|
||||
NotEnoughEnergistics.logger.info("Found Forestry, install Forestry support");
|
||||
recipeProcessors.add(new ForestryRecipeProcessor());
|
||||
}
|
||||
if (Loader.isModLoaded("thaumcraftneiplugin")) {
|
||||
NotEnoughEnergistics.logger.info("Found TCNEIPlugin, install TCNEIPlugin support");
|
||||
recipeProcessors.add(new TCNEIPluginRecipeProcessor());
|
||||
}
|
||||
if (Loader.isModLoaded("ThermalExpansion")) {
|
||||
NotEnoughEnergistics.logger.info("Found ThermalExpansion, install ThermalExpansion support");
|
||||
recipeProcessors.add(new ThermalExpansionRecipeProcessor());
|
||||
}
|
||||
if(Loader.isModLoaded("ImmersiveEngineering")){
|
||||
NotEnoughEnergistics.logger.info("Found ImmersiveEngineering, install ImmersiveEngineering support");
|
||||
recipeProcessors.add(new ImmersiveEngineeringRecipeProcessor());
|
||||
}
|
||||
if(Loader.isModLoaded("Mekanism")){
|
||||
NotEnoughEnergistics.logger.info("Found Mekanism, install Mekanism support");
|
||||
recipeProcessors.add(new MekanismRecipeProcessor());
|
||||
}
|
||||
if(Loader.isModLoaded("AWWayofTime")){
|
||||
NotEnoughEnergistics.logger.info("Found BloodMagic, install BloodMagic support");
|
||||
recipeProcessors.add(new BloodMagicRecipeProcessor());
|
||||
}
|
||||
if(Loader.isModLoaded("BuildCraft|Compat")){
|
||||
NotEnoughEnergistics.logger.info("Found BuildCraft-Compat, install BuildCraft-Compat support");
|
||||
recipeProcessors.add(new BuildCraftRecipeProcessor());
|
||||
}
|
||||
if (Loader.isModLoaded("appliedenergistics2")) {
|
||||
NotEnoughEnergistics.logger.info("Applied Energistics 2 will not be supported");
|
||||
}
|
||||
NotEnoughEnergistics.logger.info("-----Not Enough Energistics Init Finished-----");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.github.vfyjxf.nee.processor;
|
||||
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
import com.djgiannuzz.thaumcraftneiplugin.items.ItemAspect;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author vfyjxf
|
||||
*/
|
||||
public class TCNEIPluginRecipeProcessor implements IRecipeProcessor{
|
||||
|
||||
@Override
|
||||
public Set<String> getAllOverlayIdentifier() {
|
||||
return new HashSet<>(Arrays.asList(
|
||||
"arcaneshapedrecipes","arcaneshapelessrecipes","aspectsRecipe",
|
||||
"cruciblerecipe","infusionCrafting"
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeProcessorId() {
|
||||
return "TCNEIPlugin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) {
|
||||
for(String ident : getAllOverlayIdentifier()){
|
||||
if(ident.equals(identifier)){
|
||||
List<PositionedStack> recipeInputs = new ArrayList<>(recipe.getIngredientStacks(recipeIndex));
|
||||
recipeInputs.removeIf(positionedStack -> positionedStack.item.getItem() instanceof ItemAspect);
|
||||
return recipeInputs;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) {
|
||||
for(String ident : getAllOverlayIdentifier()){
|
||||
if(ident.equals(identifier)){
|
||||
List<PositionedStack> recipeOutputs = new ArrayList<>();
|
||||
recipeOutputs.add(recipe.getResultStack(recipeIndex));
|
||||
return recipeOutputs;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package com.github.vfyjxf.nee.processor;
|
||||
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
import cofh.thermalexpansion.plugins.nei.handlers.RecipeHandlerBase;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
public class ThermalExpansionRecipeProcessor implements IRecipeProcessor {
|
||||
@Override
|
||||
public Set<String> getAllOverlayIdentifier() {
|
||||
return new HashSet<>(Arrays.asList(
|
||||
"thermalexpansion.charger", "thermalexpansion.crucible", "thermalexpansion.furnace", "thermalexpansion.insolator",
|
||||
"thermalexpansion.pulverizer", "thermalexpansion.sawmill", "thermalexpansion.smelter", "thermalexpansion.transposer"
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeProcessorId() {
|
||||
return "ThermalExpansion";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) {
|
||||
for (String ident : getAllOverlayIdentifier()) {
|
||||
if (ident.equals(identifier)) {
|
||||
List<PositionedStack> recipeInputs = new ArrayList<>(recipe.getIngredientStacks(recipeIndex));
|
||||
if (recipe instanceof RecipeHandlerBase) {
|
||||
Class<?> NEIRecipeBase = null;
|
||||
try {
|
||||
NEIRecipeBase = Class.forName("cofh.thermalexpansion.plugins.nei.handlers.RecipeHandlerBase$NEIRecipeBase");
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (NEIRecipeBase != null) {
|
||||
Field secondaryInputField = ReflectionHelper.findField(NEIRecipeBase, "secondaryInput");
|
||||
PositionedStack secondaryInput = null;
|
||||
try {
|
||||
secondaryInput = (PositionedStack) secondaryInputField.get(((RecipeHandlerBase) recipe).arecipes.get(recipeIndex));
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (secondaryInput != null) {
|
||||
recipeInputs.add(secondaryInput);
|
||||
}
|
||||
}
|
||||
}
|
||||
return recipeInputs;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) {
|
||||
for (String ident : getAllOverlayIdentifier()) {
|
||||
if (ident.equals(identifier)) {
|
||||
List<PositionedStack> recipeOutputs = new ArrayList<>();
|
||||
recipeOutputs.add(recipe.getResultStack(recipeIndex));
|
||||
if (recipe instanceof RecipeHandlerBase) {
|
||||
Class<?> NEIRecipeBase = null;
|
||||
try {
|
||||
NEIRecipeBase = Class.forName("cofh.thermalexpansion.plugins.nei.handlers.RecipeHandlerBase$NEIRecipeBase");
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (NEIRecipeBase != null) {
|
||||
Field secondaryOutputField = ReflectionHelper.findField(NEIRecipeBase, "secondaryOutput");
|
||||
Field secondaryOutputChanceField = ReflectionHelper.findField(NEIRecipeBase, "secondaryOutputChance");
|
||||
PositionedStack secondaryOutput = null;
|
||||
int secondaryOutputChance = 0;
|
||||
try {
|
||||
secondaryOutput = (PositionedStack) secondaryOutputField.get(((RecipeHandlerBase) recipe).arecipes.get(recipeIndex));
|
||||
secondaryOutputChance = (int) secondaryOutputChanceField.get(((RecipeHandlerBase) recipe).arecipes.get(recipeIndex));
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (secondaryOutput != null && secondaryOutputChance >= 100) {
|
||||
recipeOutputs.add(secondaryOutput);
|
||||
}
|
||||
}
|
||||
}
|
||||
return recipeOutputs;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.github.vfyjxf.nee.processor;
|
||||
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author vfyjxf
|
||||
*/
|
||||
public class VanillaRecipeProcessor implements IRecipeProcessor {
|
||||
@Override
|
||||
public Set<String> getAllOverlayIdentifier() {
|
||||
return new HashSet<>(Arrays.asList("brewing", "smelting", "fuel"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeProcessorId() {
|
||||
return "Vanilla";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) {
|
||||
List<PositionedStack> recipeInputs = new ArrayList<>();
|
||||
if ("brewing".equals(identifier) || "smelting".equals(identifier) || "fuel".equals(identifier)) {
|
||||
recipeInputs.addAll(recipe.getIngredientStacks(recipeIndex));
|
||||
recipeInputs.addAll(recipe.getOtherStacks(recipeIndex));
|
||||
}
|
||||
return recipeInputs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) {
|
||||
if ("brewing".equals(identifier) || "smelting".equals(identifier) || "fuel".equals(identifier)) {
|
||||
List<PositionedStack> recipeOutput = new ArrayList<>();
|
||||
recipeOutput.add(recipe.getResultStack(recipeIndex));
|
||||
return recipeOutput;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,46 +1,39 @@
|
||||
package com.github.vfyjxf.nee.utils;
|
||||
|
||||
import mezz.jei.api.gui.IGuiIngredient;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class StackProcessor implements Serializable {
|
||||
public String itemName;
|
||||
public class StackProcessor {
|
||||
public String modid;
|
||||
public String name;
|
||||
public String meta;
|
||||
public String nbt;
|
||||
public String recipeType;
|
||||
public ItemStack itemStack;
|
||||
public int stackSize;
|
||||
public IGuiIngredient<ItemStack> ingredient;
|
||||
public Item item;
|
||||
public String recipeProcessor;
|
||||
public String identifier;
|
||||
|
||||
public StackProcessor(String itemName, String meta, String nbt, String recipeType) {
|
||||
this.itemName = itemName;
|
||||
public StackProcessor(String modid, String name, String meta, String nbt){
|
||||
this.modid = modid;
|
||||
this.name = name;
|
||||
this.meta = meta;
|
||||
this.nbt = nbt;
|
||||
this.recipeType = recipeType;
|
||||
}
|
||||
|
||||
public StackProcessor(String itemName, String meta) {
|
||||
this.itemName = itemName;
|
||||
public StackProcessor(String modid, String name, String meta){
|
||||
this.modid = modid;
|
||||
this.name = name;
|
||||
this.meta = meta;
|
||||
}
|
||||
public StackProcessor(String modid, String name){
|
||||
this.modid = modid;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public StackProcessor(ItemStack itemStack, String recipeType){
|
||||
public StackProcessor(ItemStack itemStack, Item item, String recipeProcessor, String identifier){
|
||||
this.itemStack = itemStack;
|
||||
this.recipeType = recipeType;
|
||||
}
|
||||
|
||||
|
||||
public StackProcessor(String itemName) {
|
||||
this.itemName = itemName;
|
||||
}
|
||||
public StackProcessor(IGuiIngredient<ItemStack> ingredient, int stackSize){
|
||||
this.ingredient = ingredient;
|
||||
this.stackSize = stackSize;
|
||||
}
|
||||
public StackProcessor(IGuiIngredient<ItemStack> ingredient){
|
||||
this.ingredient = ingredient;
|
||||
this.item = item;
|
||||
this.recipeProcessor = recipeProcessor;
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user