update dev environment to 1.12.2

This commit is contained in:
vfyjxf committed 2021-08-18 22:09:20 +08:00
1 parent 1b487f6e2a
commit 657fb6dfba
24 files changed
+52 -1601

No files matched your search

+45 -28
View File
@@ -2,10 +2,10 @@ buildscript {
repositories {
mavenCentral()
jcenter()
maven {
name = "forge"
url = "https://maven.minecraftforge.net"
}
maven {
name = "forge"
url = "https://maven.minecraftforge.net"
}
maven {
name = "github"
url = "https://github.com/juanmuscaria/maven/raw/master"
@@ -16,12 +16,6 @@ buildscript {
}
}
repositories {
flatDir {
dirs 'libs'
}
}
apply plugin: 'net.minecraftforge.gradle.forge'
version = mod_version
@@ -32,12 +26,12 @@ archivesBaseName = mod_archives_name
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8'
minecraft {
version = "1.12.2-14.23.5.2847"
version = "1.12.2-14.23.5.2847"
mappings = "stable_39"
runDir = "run"
replace '@VERSION@', project.version
// makeObfSourceJar = false
runDir = "run"
replace '@VERSION@', project.version
// makeObfSourceJar = false
}
processResources {
@@ -45,13 +39,13 @@ processResources {
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
expand 'version': project.version,
'mod_id': mod_id,
'mod_name': mod_name,
'mod_author': mod_author,
'mod_description': mod_description,
'mc_version': mc_version,
'mod_version': mod_version,
'mod_icon': mod_logo
'mod_id': mod_id,
'mod_name': mod_name,
'mod_author': mod_author,
'mod_description': mod_description,
'mc_version': mc_version,
'mod_version': mod_version,
'mod_icon': mod_logo
}
from(sourceSets.main.resources.srcDirs) {
@@ -59,21 +53,44 @@ processResources {
}
}
repositories {
maven {
// location of the maven that hosts JEI files
name = "Progwml6 maven"
url = "https://dvs1.progwml6.com/files/maven/"
}
maven {
// location of a maven mirror for JEI files, as a fallback
name = "ModMaven"
url = "https://modmaven.k-4u.nl"
}
maven {
name = "CurseMaven"
url = "https://www.cursemaven.com"
}
maven { url = "http://maven.cil.li/" }
flatDir {
dirs 'libs'
}
}
dependencies {
deobfCompile "mezz.jei:jei_${mc_version}:${jei_version}"
deobfCompile "curse.maven:applied-energistics-2-223794:2747063"
}
task devJar(type: Jar) {
classifier = 'dev'
from sourceSets.main.output
classifier = 'dev'
from sourceSets.main.output
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
classifier = 'sources'
from sourceSets.main.allSource
}
artifacts {
archives devJar
archives sourcesJar
archives devJar
archives sourcesJar
}
+1 -2
View File
@@ -4,8 +4,7 @@ org.gradle.daemon=false
# General Specifications
mc_version=1.12.2
jei_version=
ae2_version=
jei_version=4.16.1.302
mod_version=1.0.0
forge_version=14.23.5.2847
mod_group=com.github.vfyjxf.neenergistics
@@ -1,44 +0,0 @@
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");
}
}
@@ -1,84 +0,0 @@
package com.github.vfyjxf.nee;
import appeng.client.gui.implementations.GuiPatternTerm;
import appeng.client.gui.implementations.GuiPatternTermEx;
import codechicken.nei.api.API;
import codechicken.nei.api.IConfigureNEI;
import com.github.vfyjxf.nee.nei.NEECraftingHandler;
import com.github.vfyjxf.nee.processor.IRecipeProcessor;
import com.github.vfyjxf.nee.processor.RecipeProcessor;
import cpw.mods.fml.common.Loader;
import thaumicenergistics.client.gui.GuiKnowledgeInscriber;
import java.util.*;
public class NEINeeConfig implements IConfigureNEI {
@Override
public void loadConfig() {
RecipeProcessor.init();
Set<String> defaultIdentifiers = new HashSet<>(
Arrays.asList("crafting", "crafting2x2", "brewing", "smelting", "fuel", null)
);
Set<String> identifiers = new HashSet<>(defaultIdentifiers);
for (IRecipeProcessor processor : RecipeProcessor.recipeProcessors) {
identifiers.addAll(processor.getAllOverlayIdentifier());
}
for (String ident : identifiers) {
API.registerGuiOverlay(GuiPatternTerm.class, ident);
API.registerGuiOverlayHandler(GuiPatternTerm.class, new NEECraftingHandler(), ident);
}
installPatternTerminalExSupport(identifiers);
installThaumicEnergisticsSupport();
}
@Override
public String getName() {
return NotEnoughEnergistics.NAME;
}
@Override
public String getVersion() {
return NotEnoughEnergistics.VERSION;
}
private void installThaumicEnergisticsSupport() {
try {
Class.forName("thaumicenergistics.client.gui.GuiKnowledgeInscriber");
} catch (ClassNotFoundException e) {
return;
}
if (Loader.isModLoaded("thaumcraftneiplugin")) {
NotEnoughEnergistics.logger.info("Install ThaumicEnergistics support");
API.registerGuiOverlay(GuiKnowledgeInscriber.class, "arcaneshapedrecipes");
API.registerGuiOverlay(GuiKnowledgeInscriber.class, "arcaneshapelessrecipes");
API.registerGuiOverlayHandler(GuiKnowledgeInscriber.class, new NEECraftingHandler(), "arcaneshapedrecipes");
API.registerGuiOverlayHandler(GuiKnowledgeInscriber.class, new NEECraftingHandler(), "arcaneshapelessrecipes");
}
}
private void installPatternTerminalExSupport(Set<String> identifiers) {
try {
Class.forName("appeng.client.gui.implementations.GuiPatternTermEx");
} catch (ClassNotFoundException e) {
return;
}
identifiers.remove("crafting");
identifiers.remove("crafting2x2");
//PatternTermEx Support
for (String ident : identifiers) {
API.registerGuiOverlay(GuiPatternTermEx.class, ident);
API.registerGuiOverlayHandler(GuiPatternTermEx.class, new NEECraftingHandler(), ident);
}
}
}
@@ -1,10 +1,9 @@
package com.github.vfyjxf.nee;
import com.github.vfyjxf.nee.network.NEENetworkHandler;
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 net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -20,18 +19,15 @@ 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:NotEnoughItems;required-after:appliedenergistics2";
public static final String DEPENDENCIES = "required-after:jei;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"));
// NEEConfig.loadConfig(new File(Launch.minecraftHome, "config/NotEnoughEnergistics.cfg"));
}
@Mod.EventHandler
private void serverStarting(FMLServerStartingEvent event) {
event.registerServerCommand(new NEECommands());
}
}
@@ -1,212 +0,0 @@
package com.github.vfyjxf.nee.nei;
import appeng.client.gui.implementations.GuiPatternTerm;
import appeng.client.gui.implementations.GuiPatternTermEx;
import codechicken.nei.api.IOverlayHandler;
import codechicken.nei.recipe.TemplateRecipeHandler;
import com.github.vfyjxf.nee.network.NEENetworkHandler;
import appeng.util.Platform;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.IRecipeHandler;
import com.github.vfyjxf.nee.network.packet.PacketArcaneRecipe;
import com.github.vfyjxf.nee.network.packet.PacketNEIPatternRecipe;
import com.github.vfyjxf.nee.processor.IRecipeProcessor;
import com.github.vfyjxf.nee.processor.RecipeProcessor;
import com.github.vfyjxf.nee.utils.ItemUtils;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import java.util.ArrayList;
import java.util.List;
/**
* @author vfyjxf
*/
public class NEECraftingHandler implements IOverlayHandler {
public static final String OUTPUT_KEY = "Outputs";
@Override
public void overlayRecipe(GuiContainer firstGui, IRecipeHandler recipe, int recipeIndex, boolean shift) {
if (firstGui instanceof GuiPatternTerm || firstGui instanceof GuiPatternTermEx) {
NEENetworkHandler.getInstance().sendToServer(packRecipe(recipe, recipeIndex));
} else {
knowledgeInscriberHandler(firstGui, recipe, recipeIndex);
}
}
private PacketNEIPatternRecipe packRecipe(IRecipeHandler recipe, int recipeIndex) {
if (isCraftingTableRecipe(recipe)) {
return packCraftingTableRecipe(recipe, recipeIndex);
} else {
return packProcessRecipe(recipe, recipeIndex);
}
}
private PacketNEIPatternRecipe packProcessRecipe(IRecipeHandler recipe, int recipeIndex) {
final NBTTagCompound recipeInputs = new NBTTagCompound();
NBTTagCompound recipeOutputs = new NBTTagCompound();
String identifier = ((TemplateRecipeHandler) recipe).getOverlayIdentifier();
int inputIndex = 0;
int outputIndex = 0;
//get all recipe inputs and other stacks,use first item
for (IRecipeProcessor processor : RecipeProcessor.recipeProcessors) {
List<PositionedStack> inputs = processor.getRecipeInput(recipe, recipeIndex, identifier);
List<PositionedStack> outputs = processor.getRecipeOutput(recipe, recipeIndex, identifier);
String recipeProcessorId = processor.getRecipeProcessorId();
List<PositionedStack> tInputs = new ArrayList<>();
if (inputs != null && outputs != null) {
for (PositionedStack positionedStack : inputs) {
ItemStack currentStack = positionedStack.items[0];
boolean find = false;
for (PositionedStack storedStack : tInputs) {
ItemStack StoredStack = storedStack.items[0];
if (StoredStack.isItemEqual(currentStack) && (StoredStack.stackSize + currentStack.stackSize) <= StoredStack.getMaxStackSize()) {
find = true;
storedStack.items[0].stackSize = StoredStack.stackSize + currentStack.stackSize;
}
}
if (!find) {
tInputs.add(positionedStack);
}
}
for (PositionedStack positionedStack : tInputs) {
ItemStack currentStack = positionedStack.items[0];
ItemStack preferModItem = ItemUtils.getPreferModItem(positionedStack.items);
if (preferModItem != null) {
currentStack = preferModItem;
currentStack.stackSize = positionedStack.items[0].stackSize;
}
for (ItemStack stack : positionedStack.items) {
if (Platform.isRecipePrioritized(stack) || ItemUtils.isPreferItems(stack, recipeProcessorId, identifier)) {
currentStack = stack.copy();
currentStack.stackSize = positionedStack.items[0].stackSize;
break;
}
}
if (ItemUtils.isInBlackList(currentStack, recipeProcessorId, identifier)) {
continue;
}
recipeInputs.setTag("#" + inputIndex, currentStack.writeToNBT(new NBTTagCompound()));
inputIndex++;
}
for (PositionedStack positionedStack : outputs) {
if (outputIndex >= 4 || positionedStack == null || positionedStack.item == null) {
continue;
}
recipeOutputs.setTag(OUTPUT_KEY + outputIndex, positionedStack.item.writeToNBT(new NBTTagCompound()));
outputIndex++;
}
}
}
return new PacketNEIPatternRecipe(recipeInputs, recipeOutputs);
}
private PacketNEIPatternRecipe packCraftingTableRecipe(IRecipeHandler recipe, int recipeIndex) {
final NBTTagCompound recipeInputs = new NBTTagCompound();
final List<PositionedStack> ingredients = recipe.getIngredientStacks(recipeIndex);
for (final PositionedStack positionedStack : ingredients) {
final int col = (positionedStack.relx - 25) / 18;
final int row = (positionedStack.rely - 6) / 18;
int slotIndex = col + row * 3;
if (positionedStack.items != null && positionedStack.items.length > 0) {
final ItemStack[] currentStackList = positionedStack.items;
ItemStack stack = positionedStack.items[0];
ItemStack preferModItem = ItemUtils.getPreferModItem(positionedStack.items);
if (preferModItem != null) {
stack = preferModItem;
}
for (ItemStack currentStack : currentStackList) {
if (Platform.isRecipePrioritized(currentStack) || ItemUtils.isPreferItems(currentStack)) {
stack = currentStack.copy();
}
}
recipeInputs.setTag("#" + slotIndex, stack.writeToNBT(new NBTTagCompound()));
}
}
return new PacketNEIPatternRecipe(recipeInputs, null);
}
private void knowledgeInscriberHandler(GuiContainer firstGui, IRecipeHandler recipe, int recipeIndex) {
Class<?> knowledgeInscriberClz;
try {
knowledgeInscriberClz = Class.forName("thaumicenergistics.client.gui.GuiKnowledgeInscriber");
} catch (ClassNotFoundException e) {
return;
}
if (knowledgeInscriberClz.isInstance(firstGui)) {
NEENetworkHandler.getInstance().sendToServer(packetArcaneRecipe(recipe, recipeIndex));
}
}
private PacketArcaneRecipe packetArcaneRecipe(IRecipeHandler recipe, int recipeIndex) {
final Class<?> itemAspectClz;
Class<?> iA = null;
try {
iA = Class.forName("com.djgiannuzz.thaumcraftneiplugin.items.ItemAspect");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
itemAspectClz = iA;
final NBTTagCompound recipeInputs = new NBTTagCompound();
List<PositionedStack> ingredients = recipe.getIngredientStacks(recipeIndex);
if (itemAspectClz != null) {
ingredients.removeIf(positionedStack -> itemAspectClz.isInstance(positionedStack.item.getItem()));
}
for (PositionedStack positionedStack : ingredients) {
if (positionedStack.items != null && positionedStack.items.length > 0) {
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, stack.writeToNBT(new NBTTagCompound()));
}
}
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 boolean isCraftingTableRecipe(IRecipeHandler recipe) {
TemplateRecipeHandler templateRecipeHandler = (TemplateRecipeHandler) recipe;
String overlayIdentifier = templateRecipeHandler.getOverlayIdentifier();
return "crafting".equals(overlayIdentifier) || "crafting2x2".equals(overlayIdentifier);
}
}
@@ -1,10 +1,7 @@
package com.github.vfyjxf.nee.network;
import com.github.vfyjxf.nee.NotEnoughEnergistics;
import com.github.vfyjxf.nee.network.packet.PacketArcaneRecipe;
import com.github.vfyjxf.nee.network.packet.PacketNEIPatternRecipe;
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import cpw.mods.fml.relauncher.Side;
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
public class NEENetworkHandler {
@@ -15,8 +12,6 @@ public class NEENetworkHandler {
}
public static void init(){
INSTANCE.registerMessage(PacketNEIPatternRecipe.class, PacketNEIPatternRecipe.class,0, Side.SERVER);
INSTANCE.registerMessage(PacketArcaneRecipe.class, PacketArcaneRecipe.class, 1, Side.SERVER);
}
}
@@ -1,77 +0,0 @@
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;
}
}
@@ -1,212 +0,0 @@
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);
}
}
}
}
@@ -1,42 +0,0 @@
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;
}
}
@@ -1,48 +0,0 @@
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;
}
}
@@ -1,49 +0,0 @@
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));
}
}
@@ -1,52 +0,0 @@
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;
}
}
@@ -1,109 +0,0 @@
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
}
@@ -1,103 +0,0 @@
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;
}
}
@@ -1,83 +0,0 @@
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;
}
}
@@ -1,50 +0,0 @@
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;
}
}
@@ -1,27 +0,0 @@
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);
}
@@ -1,57 +0,0 @@
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;
}
}
@@ -1,52 +0,0 @@
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;
}
}
@@ -1,71 +0,0 @@
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-----");
}
}
@@ -1,50 +0,0 @@
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;
}
}
@@ -1,92 +0,0 @@
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;
}
}
@@ -1,42 +0,0 @@
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;
}
}