mirror of
https://github.com/GTNewHorizons/NotEnoughEnergistics.git
synced 2026-10-25 20:32:19 +00:00
update dev environment to 1.12.2
This commit is contained in:
1 parent
1b487f6e2a
commit
dc584e9d6c
34 files changed
+605
-1792
No files matched your search
@@ -1,49 +1,22 @@
|
||||
[中文](READNE_CN.md)
|
||||
|
||||
# Not Enough Energistics
|
||||
NotEnoughEnergistics is a port of [Just Enough Energistics](https://www.curseforge.com/minecraft/mc-mods/just-enough-energistics-jee) to Minecraft 1.7.10
|
||||
NotEnoughEnergistics-1.12.2 is an improved version of [Just Enough Energistics](https://www.curseforge.com/minecraft/mc-mods/just-enough-energistics-jee)
|
||||
|
||||
This mod replaces AE2's default NEI integration for the Pattern Terminal.
|
||||
This mod replaces AE2's default JEI integration for the Pattern Terminal.
|
||||
|
||||
By default, AE2 forces the player to either have the necessary items for a recipe in their personal inventory or in their ME network.
|
||||
|
||||
This mod removes that functionality and allows the player to use NEI's transfer system (shift + click [?] button) to create patterns whether the player possesses the items required by the recipe.
|
||||
This mod removes that functionality and allows the player to use JEI's transfer system (click [+] button) to create patterns whether the player possesses the items required by the recipe.
|
||||
|
||||
|
||||
## Features
|
||||
|
||||
- Automatically switch the mode of PatternTerminal.
|
||||
- If an item is a probability output, then nee will not transfer it.
|
||||
- Combine like stacks in processing patterns.
|
||||
- Support Processing Pattern Terminal(16 -> 4 mode).
|
||||
- Allow you to add item blackList and item priority list, if item in them, it will not be transferred / transfer it first.(use /nee RecipeProcessor to get RecipeProcessor and identifier in log)
|
||||
- Allow you to add mod priority list,if the mod's has this item,it will be use first.
|
||||
|
||||
## Compatible Modslist as followed:
|
||||
|
||||
- [ ] AppliedEnergistics2(Won't support it because AE2 doesn't register OverlayHandler)
|
||||
- [x] Vanilla
|
||||
- [x] GregTech5
|
||||
- [x] GregTech6
|
||||
- [x] IndustrialCraft2
|
||||
- [x] Avaritia
|
||||
- [x] EnderIO
|
||||
- [x] Forestry(Doesn't support Fermenter and Still,because they don't have an item output)
|
||||
- [x] Thaumcraft NEI Plugin
|
||||
- [x] Thaumic Energistics(Allows you to transfer ArcaneRecipe from NEI to Knowledge Inscriber, it requires Thaumcraft NEI Plugin)
|
||||
- [x] ThermalExpansion
|
||||
- [x] ImmersiveEngineering
|
||||
- [x] Mekanism
|
||||
- [x] BloodMagic
|
||||
- [x] BuildCraft
|
||||
|
||||
If you want other Mod support,see [RecipeProcessor](./src/main/java/com/github/vfyjxf/nee/processor/RecipeProcessor.java) and [Mod support Issue](https://github.com/vfyjxf/NotEnoughEnergistics/issues/1)
|
||||
|
||||
## TODO
|
||||
|
||||
- [x] Add item blackList ,if item in the blacklist, it will not be transferred.
|
||||
- [x] Add item priority list, if item in tne priority list, it will be transferred first.
|
||||
- [x] Combine like stacks in processing patterns.
|
||||
|
||||
## Credits
|
||||
Thanks TheRealp455w0rd and his [Just Enough Energistics](https://www.curseforge.com/minecraft/mc-mods/just-enough-energistics-jee)
|
||||
+3
-29
@@ -1,44 +1,18 @@
|
||||
# Not Enough Energistics
|
||||
NotEnoughEnergistics 是[Just Enough Energistics](https://www.curseforge.com/minecraft/mc-mods/just-enough-energistics-jee) 的逆向移植版本
|
||||
NotEnoughEnergistics 是[Just Enough Energistics](https://www.curseforge.com/minecraft/mc-mods/just-enough-energistics-jee) 的改进版本
|
||||
|
||||
它替换了AE2默认的NEI集成, 默认情况下ae只能识别玩家身上或者网络里的存储物品。
|
||||
它替换了AE2默认的JEI集成, 默认情况下ae只能识别玩家身上或者网络里的存储物品。
|
||||
|
||||
本MOD允许你直接从nei获取配方并写入样板终端(shift点击[?]按钮)
|
||||
本MOD允许你直接从jei获取配方并写入样板终端(shift点击[+]按钮)
|
||||
|
||||
## Features
|
||||
|
||||
- 根据配方自动切换样板终端的模式
|
||||
- 如果一个物品输出为概率输出,那么NEE不会将它写入样板终端
|
||||
- 在处理模式中合并同类物品
|
||||
- 支持增广样板终端(16 -> 4模式)
|
||||
- 允许你设置转换黑名单和转换优先名单,如对应物品在里面,那么他们将不会被转移/优先被转移
|
||||
- 允许你设置mod优先级列表,优先使用该mod的物品
|
||||
|
||||
## 当前支持的Mod列表:
|
||||
|
||||
- [ ] AppliedEnergistics2(我们将不会支持AE2,因为AE2没有注册对应的OverlayHandler)
|
||||
- [x] Vanilla
|
||||
- [x] GregTech5
|
||||
- [x] GregTech6
|
||||
- [x] IndustrialCraft2
|
||||
- [x] Avaritia
|
||||
- [x] EnderIO
|
||||
- [x] Forestry(不支持发酵机和蒸馏器,因为它们没有物品输出)
|
||||
- [x] Thaumcraft NEI Plugin
|
||||
- [x] Thaumic Energistics(允许你从NEI转移奥术合成台配方到知识记录仪,需要Thaumcraft NEI Plugin)
|
||||
- [x] ThermalExpansion
|
||||
- [x] ImmersiveEngineering
|
||||
- [x] Mekanism
|
||||
- [x] BloodMagic
|
||||
- [x] BuildCraft
|
||||
|
||||
如果你想要别的Mod的支持,请看[RecipeProcessor](./src/main/java/com/github/vfyjxf/nee/processor/RecipeProcessor.java) 或者[模组支持处理区](https://github.com/vfyjxf/NotEnoughEnergistics/issues/1)
|
||||
|
||||
## TODO
|
||||
- [x] 添加转换黑名单,使在黑名单里的物品不会被转移到样板终端
|
||||
- [x] 添加优先转换列表,在优先转换列表的物品会替换配方里的同类物品
|
||||
- [x] 在有多个同类物品的情况下,合并同类物品
|
||||
|
||||
## Credits
|
||||
感谢 TheRealp455w0rd 和他的 [Just Enough Energistics](https://www.curseforge.com/minecraft/mc-mods/just-enough-energistics-jee)
|
||||
|
||||
|
||||
+49
-28
@@ -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,11 @@ 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
|
||||
}
|
||||
|
||||
processResources {
|
||||
@@ -45,35 +38,63 @@ 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_credits': mod_credits,
|
||||
'mod_author': mod_author,
|
||||
'mod_description': mod_description,
|
||||
'mc_version': mc_version,
|
||||
'mod_version': mod_version,
|
||||
'mod_logo': mod_logo
|
||||
}
|
||||
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
exclude 'mcmod.info'
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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"
|
||||
|
||||
runtime "mezz.jei:jei_${mc_version}:${jei_version}"
|
||||
runtime "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
@@ -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,34 +1,30 @@
|
||||
package com.github.vfyjxf.nee;
|
||||
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.common.config.Config;
|
||||
import net.minecraftforge.common.config.Config.Comment;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author vfyjxf
|
||||
*/
|
||||
@Config(modid = "neenergistics", name = "NotEnoughEnergistics", category = "transfer")
|
||||
public class NEEConfig {
|
||||
|
||||
@Comment("Automatic switch Pattern Terminal's Mode when click [+].Default:true")
|
||||
public static boolean allowAutomaticSwitchPatternTerminalMode = true;
|
||||
|
||||
public static String[] transformBlacklist = new String[0];
|
||||
public static String[] transformPriorityList = new String[0];
|
||||
public static String[] transformPriorityModList = new String[0];
|
||||
@Comment("If true, print current recipe type in log.Default:false")
|
||||
public static boolean allowPrintRecipeType = false;
|
||||
|
||||
public static void loadConfig(File configFile) {
|
||||
Configuration config = new Configuration(configFile);
|
||||
config.load();
|
||||
@Comment("If oredict has this mod's item, use it first.")
|
||||
public static String[] modPriorityList = new String[0];
|
||||
|
||||
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();
|
||||
transformPriorityList = config.get("client", "transformItemPriorityList", new String[0],
|
||||
"If item in tne priority list, it will be transferred first.").getStringList();
|
||||
@Comment("If item in the blacklist, it will not be transferred.\n" +
|
||||
"example:{\"itemName\":\"gregtech:meta_item_2\",\"meta\":\"32492\"}")
|
||||
public static String[] itemBlacklist = new String[0];
|
||||
|
||||
transformPriorityModList = config.get("client","transformPriorityModList",new String[0],
|
||||
"if oredict has this mod's item, use it first").getStringList();
|
||||
|
||||
if (config.hasChanged()) config.save();
|
||||
}
|
||||
@Comment("If item in tne priority list, it will be transferred first.\n" +
|
||||
"example:{\"itemName\":\"gregtech:meta_item_2\",\"meta\":\"32492\"}")
|
||||
public static String[] itemPriorityList = new String[0];
|
||||
|
||||
}
|
||||
@@ -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,15 +1,11 @@
|
||||
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;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
|
||||
@Mod(modid = NotEnoughEnergistics.MODID,
|
||||
version = NotEnoughEnergistics.VERSION,
|
||||
@@ -20,18 +16,13 @@ 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"));
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
private void serverStarting(FMLServerStartingEvent event) {
|
||||
event.registerServerCommand(new NEECommands());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copied from Just Enough Energistics(https://github.com/p455w0rd/JustEnoughEnergistics/blob/master/src/main/java/p455w0rd/jee/integration/JEI.java)
|
||||
*/
|
||||
package com.github.vfyjxf.nee.jei;
|
||||
|
||||
import appeng.container.implementations.ContainerPatternTerm;
|
||||
import com.github.vfyjxf.nee.NotEnoughEnergistics;
|
||||
import com.github.vfyjxf.nee.utils.WrappedTable;
|
||||
import mezz.jei.api.IModPlugin;
|
||||
import mezz.jei.api.IModRegistry;
|
||||
import mezz.jei.api.JEIPlugin;
|
||||
import mezz.jei.api.recipe.transfer.IRecipeTransferHandler;
|
||||
import mezz.jei.collect.Table;
|
||||
import com.google.common.collect.Table.Cell;
|
||||
import mezz.jei.config.Constants;
|
||||
import mezz.jei.recipes.RecipeTransferRegistry;
|
||||
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
||||
|
||||
/**
|
||||
* @author vfyjxf
|
||||
*/
|
||||
@JEIPlugin
|
||||
public class NEEJEIPlugin implements IModPlugin {
|
||||
|
||||
public static IModRegistry registry;
|
||||
|
||||
@Override
|
||||
public void register(IModRegistry registry) {
|
||||
NEEJEIPlugin.registry = registry;
|
||||
Table<Class<?>, String, IRecipeTransferHandler> newRegistry = Table.hashBasedTable();
|
||||
boolean ae2found = false;
|
||||
for (final Cell<Class, String, IRecipeTransferHandler> currentCell : ((RecipeTransferRegistry) registry.getRecipeTransferRegistry()).getRecipeTransferHandlers().cellSet()) {
|
||||
if (currentCell.getRowKey().equals(ContainerPatternTerm.class)) {
|
||||
ae2found = true;
|
||||
continue;
|
||||
}
|
||||
newRegistry.put(currentCell.getRowKey(), currentCell.getColumnKey(), currentCell.getValue());
|
||||
}
|
||||
newRegistry.put(ContainerPatternTerm.class, Constants.UNIVERSAL_RECIPE_TRANSFER_UID, new NEERecipeTransferHandler());
|
||||
if (ae2found) {
|
||||
NotEnoughEnergistics.logger.info("AE2 RecipeTransferHandler Replaced Successfully (Registered prior)");
|
||||
} else {
|
||||
newRegistry = new WrappedTable<>(newRegistry);
|
||||
}
|
||||
ObfuscationReflectionHelper.setPrivateValue(RecipeTransferRegistry.class, (RecipeTransferRegistry) registry.getRecipeTransferRegistry(), newRegistry, "recipeTransferHandlers");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package com.github.vfyjxf.nee.jei;
|
||||
|
||||
import appeng.container.implementations.ContainerPatternTerm;
|
||||
import com.github.vfyjxf.nee.NEEConfig;
|
||||
import com.github.vfyjxf.nee.NotEnoughEnergistics;
|
||||
import com.github.vfyjxf.nee.network.NEENetworkHandler;
|
||||
import com.github.vfyjxf.nee.network.packet.NEERecipeTransferPacket;
|
||||
import com.github.vfyjxf.nee.utils.ItemUtils;
|
||||
import com.github.vfyjxf.nee.utils.StackProcessor;
|
||||
import mezz.jei.api.gui.IGuiIngredient;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
|
||||
import mezz.jei.api.recipe.transfer.IRecipeTransferError;
|
||||
import mezz.jei.api.recipe.transfer.IRecipeTransferHandler;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import static com.github.vfyjxf.nee.jei.NEEJEIPlugin.registry;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author vfyjxf
|
||||
*/
|
||||
public class NEERecipeTransferHandler implements IRecipeTransferHandler<ContainerPatternTerm> {
|
||||
|
||||
public static final String OUTPUT_KEY = "Outputs";
|
||||
|
||||
public NEERecipeTransferHandler() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<ContainerPatternTerm> getContainerClass() {
|
||||
return ContainerPatternTerm.class;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IRecipeTransferError transferRecipe(ContainerPatternTerm container, IRecipeLayout recipeLayout, EntityPlayer player, boolean maxTransfer, boolean doTransfer) {
|
||||
String recipeType = recipeLayout.getRecipeCategory().getUid();
|
||||
boolean isCraftingRecipe = isCraftingRecipe(recipeType);
|
||||
if (container.isCraftingMode()) {
|
||||
if (!isCraftingRecipe && !NEEConfig.allowAutomaticSwitchPatternTerminalMode) {
|
||||
return registry.getJeiHelpers().recipeTransferHandlerHelper().createUserErrorWithTooltip(I18n.format("jei.tooltip.nee.need.processing"));
|
||||
}
|
||||
} else {
|
||||
if (isCraftingRecipe && !NEEConfig.allowAutomaticSwitchPatternTerminalMode) {
|
||||
return registry.getJeiHelpers().recipeTransferHandlerHelper().createUserErrorWithTooltip(I18n.format("jei.tooltip.nee.need.crating"));
|
||||
}
|
||||
}
|
||||
if (doTransfer) {
|
||||
final Map<Integer, ? extends IGuiIngredient<ItemStack>> ingredients = recipeLayout.getItemStacks().getGuiIngredients();
|
||||
final NBTTagCompound recipeInputs = new NBTTagCompound();
|
||||
final NBTTagCompound recipeOutputs = new NBTTagCompound();
|
||||
int inputIndex = 0;
|
||||
int outputIndex = 0;
|
||||
List<StackProcessor> tInputs = new ArrayList<>();
|
||||
for (Map.Entry<Integer, ? extends IGuiIngredient<ItemStack>> entry : ingredients.entrySet()) {
|
||||
final IGuiIngredient<ItemStack> ingredient = entry.getValue();
|
||||
if (ingredient != null) {
|
||||
ItemStack currentStack = ingredient.getDisplayedIngredient() == null ? ItemStack.EMPTY : ingredient.getDisplayedIngredient().copy();
|
||||
if (ingredient.isInput()) {
|
||||
if (isCraftingRecipe) {
|
||||
tInputs.add(new StackProcessor(ingredient, currentStack.getCount()));
|
||||
} else {
|
||||
boolean find = false;
|
||||
if (currentStack.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
for (StackProcessor storedIngredient : tInputs) {
|
||||
ItemStack storedStack = storedIngredient.ingredient.getDisplayedIngredient();
|
||||
if (storedStack != null && currentStack.isItemEqual(storedStack) && ItemStack.areItemStackTagsEqual(currentStack, storedStack)) {
|
||||
if (currentStack.getCount() + storedIngredient.stackSize <= storedStack.getMaxStackSize()) {
|
||||
find = true;
|
||||
storedIngredient.stackSize = currentStack.getCount() + storedIngredient.stackSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!find) {
|
||||
tInputs.add(new StackProcessor(ingredient, currentStack.getCount()));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (outputIndex >= 3 || currentStack.isEmpty() || (container.isCraftingMode() && !NEEConfig.allowAutomaticSwitchPatternTerminalMode)) {
|
||||
continue;
|
||||
}
|
||||
recipeOutputs.setTag(OUTPUT_KEY + outputIndex, currentStack.writeToNBT(new NBTTagCompound()));
|
||||
outputIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (StackProcessor currentIngredient : tInputs) {
|
||||
ItemStack currentStack = currentIngredient.ingredient.getDisplayedIngredient() == null ? ItemStack.EMPTY : currentIngredient.ingredient.getDisplayedIngredient().copy();
|
||||
ItemStack preferModItem = ItemUtils.isPreferModItem(currentStack) ? currentStack : ItemUtils.getPreferModItem(currentIngredient.ingredient);
|
||||
|
||||
if (!currentStack.isEmpty()) {
|
||||
currentStack.setCount(currentIngredient.stackSize);
|
||||
}
|
||||
|
||||
if (!currentStack.isEmpty() && preferModItem != null && !preferModItem.isEmpty()) {
|
||||
currentStack = preferModItem.copy();
|
||||
currentStack.setCount(currentIngredient.stackSize);
|
||||
}
|
||||
for (ItemStack stack : currentIngredient.ingredient.getAllIngredients()) {
|
||||
if (ItemUtils.isPreferItems(stack, recipeType) && !currentStack.isEmpty()) {
|
||||
currentStack = stack.copy();
|
||||
currentStack.setCount(currentIngredient.stackSize);
|
||||
}
|
||||
}
|
||||
if (!currentStack.isEmpty() && ItemUtils.isInBlackList(currentStack, recipeType)) {
|
||||
continue;
|
||||
}
|
||||
recipeInputs.setTag("#" + inputIndex, currentStack.writeToNBT(new NBTTagCompound()));
|
||||
inputIndex++;
|
||||
}
|
||||
NEENetworkHandler.getInstance().sendToServer(new NEERecipeTransferPacket(recipeInputs, recipeOutputs, isCraftingRecipe));
|
||||
if (NEEConfig.allowPrintRecipeType) {
|
||||
NotEnoughEnergistics.logger.info(recipeType);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean isCraftingRecipe(String recipeType) {
|
||||
if (!recipeType.equals(VanillaRecipeCategoryUid.INFORMATION) && !recipeType.equals(VanillaRecipeCategoryUid.FUEL)) {
|
||||
return recipeType.equals(VanillaRecipeCategoryUid.CRAFTING);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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,22 +1,20 @@
|
||||
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 com.github.vfyjxf.nee.network.packet.NEERecipeTransferPacket;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
public class NEENetworkHandler {
|
||||
|
||||
private static final SimpleNetworkWrapper INSTANCE = new SimpleNetworkWrapper(NotEnoughEnergistics.MODID);
|
||||
|
||||
public static SimpleNetworkWrapper getInstance(){
|
||||
public static SimpleNetworkWrapper getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public static void init(){
|
||||
INSTANCE.registerMessage(PacketNEIPatternRecipe.class, PacketNEIPatternRecipe.class,0, Side.SERVER);
|
||||
INSTANCE.registerMessage(PacketArcaneRecipe.class, PacketArcaneRecipe.class, 1, Side.SERVER);
|
||||
public static void init() {
|
||||
NEENetworkHandler.getInstance().registerMessage(NEERecipeTransferPacket.class, NEERecipeTransferPacket.class, 0, Side.SERVER);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
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.helpers.IContainerCraftingPacket;
|
||||
import appeng.util.helpers.ItemHandlerUtil;
|
||||
import appeng.util.inv.WrapperInvItemHandler;
|
||||
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 net.minecraftforge.fml.common.network.ByteBufUtils;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import static com.github.vfyjxf.nee.jei.NEERecipeTransferHandler.OUTPUT_KEY;
|
||||
|
||||
/**
|
||||
* @author vfyjxf
|
||||
*/
|
||||
public class NEERecipeTransferPacket implements IMessage, IMessageHandler<NEERecipeTransferPacket, IMessage> {
|
||||
|
||||
private NBTTagCompound input;
|
||||
private NBTTagCompound output;
|
||||
private boolean craftingMode;
|
||||
|
||||
public NEERecipeTransferPacket() {
|
||||
|
||||
}
|
||||
|
||||
public NEERecipeTransferPacket(@Nonnull NBTTagCompound input, NBTTagCompound output, boolean craftingMode) {
|
||||
this.input = input;
|
||||
this.output = output;
|
||||
this.craftingMode = craftingMode;
|
||||
}
|
||||
|
||||
public NBTTagCompound getInput() {
|
||||
return input;
|
||||
}
|
||||
|
||||
public NBTTagCompound getOutput() {
|
||||
return output;
|
||||
}
|
||||
|
||||
public boolean getCraftingMode() {
|
||||
return craftingMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
this.input = ByteBufUtils.readTag(buf);
|
||||
this.craftingMode = buf.readBoolean();
|
||||
if (buf.readBoolean()) {
|
||||
this.output = ByteBufUtils.readTag(buf);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
ByteBufUtils.writeTag(buf, this.input);
|
||||
buf.writeBoolean(this.craftingMode);
|
||||
if (this.output != null) {
|
||||
buf.writeBoolean(true);
|
||||
ByteBufUtils.writeTag(buf, this.output);
|
||||
} else {
|
||||
buf.writeBoolean(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(NEERecipeTransferPacket message, MessageContext ctx) {
|
||||
EntityPlayerMP player = ctx.getServerHandler().player;
|
||||
Container container = player.openContainer;
|
||||
player.getServerWorld().addScheduledTask(() -> {
|
||||
if (container instanceof ContainerPatternTerm) {
|
||||
((ContainerPatternTerm) container).getPatternTerminal().setCraftingRecipe(message.getCraftingMode());
|
||||
ItemStack[] recipeInputs = new ItemStack[9];
|
||||
ItemStack[] recipeOutputs = null;
|
||||
NBTTagCompound currentStack;
|
||||
|
||||
for (int i = 0; i < recipeInputs.length; i++) {
|
||||
currentStack = message.getInput().getCompoundTag("#" + i);
|
||||
recipeInputs[i] = currentStack.isEmpty() ? ItemStack.EMPTY : new ItemStack(currentStack);
|
||||
}
|
||||
|
||||
if (!message.output.isEmpty()) {
|
||||
recipeOutputs = new ItemStack[3];
|
||||
for (int i = 0; i < recipeOutputs.length; i++) {
|
||||
currentStack = message.getOutput().getCompoundTag(OUTPUT_KEY + i);
|
||||
recipeOutputs[i] = currentStack.isEmpty() ? ItemStack.EMPTY : new ItemStack(currentStack);
|
||||
}
|
||||
}
|
||||
final IContainerCraftingPacket cct = (IContainerCraftingPacket) container;
|
||||
final IGridNode node = cct.getNetworkNode();
|
||||
if (node == null) {
|
||||
return;
|
||||
}
|
||||
final IGrid grid = node.getGrid();
|
||||
final IStorageGrid inv = grid.getCache(IStorageGrid.class);
|
||||
final ISecurityGrid security = grid.getCache(ISecurityGrid.class);
|
||||
final IItemHandler craftMatrix = cct.getInventoryByName("crafting");
|
||||
if (message.input != null) {
|
||||
for (int i = 0; i < craftMatrix.getSlots(); i++) {
|
||||
ItemStack currentItem = ItemStack.EMPTY;
|
||||
if (recipeInputs[i] != null) {
|
||||
currentItem = recipeInputs[i].copy();
|
||||
}
|
||||
ItemHandlerUtil.setStackInSlot(craftMatrix, i, currentItem);
|
||||
}
|
||||
if (recipeOutputs != null && !message.getCraftingMode()) {
|
||||
final IItemHandler outputMatrix = cct.getInventoryByName("output");
|
||||
for (int i = 0; i < outputMatrix.getSlots(); i++) {
|
||||
ItemStack currentItem = ItemStack.EMPTY;
|
||||
if (recipeOutputs[i] != null) {
|
||||
currentItem = recipeOutputs[i].copy();
|
||||
}
|
||||
ItemHandlerUtil.setStackInSlot(outputMatrix, i, currentItem);
|
||||
}
|
||||
}
|
||||
container.onCraftMatrixChanged(new WrapperInvItemHandler(craftMatrix));
|
||||
}
|
||||
}
|
||||
});
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
-57
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,92 +1,73 @@
|
||||
package com.github.vfyjxf.nee.utils;
|
||||
|
||||
import com.github.vfyjxf.nee.NotEnoughEnergistics;
|
||||
import com.google.gson.Gson;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.item.Item;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import mezz.jei.api.gui.IGuiIngredient;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.JsonToNBT;
|
||||
import net.minecraft.nbt.NBTException;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.github.vfyjxf.nee.NEEConfig.*;
|
||||
|
||||
/**
|
||||
* @author vfyjxf
|
||||
*/
|
||||
public final class ItemUtils {
|
||||
|
||||
public static Gson gson = new Gson();
|
||||
|
||||
public static List<StackProcessor> getTransformItemBlacklist() {
|
||||
private static List<StackProcessor> getTransformItemBlacklist() {
|
||||
List<StackProcessor> transformItemBlacklist = new ArrayList<>();
|
||||
for (String itemJsonString : transformBlacklist) {
|
||||
StackProcessor processor = gson.fromJson(itemJsonString, StackProcessor.class);
|
||||
if (processor != null) {
|
||||
Item currentItem = GameRegistry.findItem(processor.modid, processor.name);
|
||||
if (currentItem != null) {
|
||||
ItemStack currentStack = processor.meta != null ? new ItemStack(currentItem, 1, Integer.parseInt(processor.meta)) : new ItemStack(currentItem);
|
||||
if (processor.nbt != null) {
|
||||
NBTTagCompound nbt = null;
|
||||
try {
|
||||
nbt = (NBTTagCompound) JsonToNBT.func_150315_a(processor.nbt);
|
||||
} catch (NBTException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (nbt != null) {
|
||||
currentStack.setTagCompound(nbt);
|
||||
}
|
||||
}
|
||||
transformItemBlacklist.add(new StackProcessor(currentStack, currentItem, processor.recipeProcessor, processor.identifier));
|
||||
for (String itemJsonString : itemBlacklist) {
|
||||
JsonObject jsonObject = new JsonParser().parse(itemJsonString).getAsJsonObject();
|
||||
if (jsonObject != null) {
|
||||
String itemName = jsonObject.get("itemName").getAsString();
|
||||
if (itemName == null || itemName.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
int meta = itemJsonString.contains("meta") ? Integer.parseInt(jsonObject.get("meta").getAsString()) : 0;
|
||||
String nbtJsonString = itemJsonString.contains("nbt") ? jsonObject.get("nbt").getAsString() : "";
|
||||
ItemStack currentStack = GameRegistry.makeItemStack(itemName, meta, 1, nbtJsonString);
|
||||
String recipeType = itemJsonString.contains("recipeType") ? jsonObject.get("name").getAsString() : "";
|
||||
transformItemBlacklist.add(new StackProcessor(currentStack, recipeType));
|
||||
}
|
||||
}
|
||||
|
||||
return transformItemBlacklist;
|
||||
}
|
||||
|
||||
public static List<StackProcessor> getTransformItemPriorityList() {
|
||||
private static List<StackProcessor> getTransformItemPriorityList() {
|
||||
List<StackProcessor> transformItemPriorityList = new ArrayList<>();
|
||||
for (String itemJsonString : transformPriorityList) {
|
||||
StackProcessor processor = gson.fromJson(itemJsonString, StackProcessor.class);
|
||||
if (processor != null) {
|
||||
Item currentItem = GameRegistry.findItem(processor.modid, processor.name);
|
||||
if (currentItem != null) {
|
||||
ItemStack currentStack = processor.meta != null ? new ItemStack(currentItem, 1, Integer.parseInt(processor.meta)) : new ItemStack(currentItem);
|
||||
if (processor.nbt != null) {
|
||||
NBTTagCompound nbt = null;
|
||||
try {
|
||||
nbt = (NBTTagCompound) JsonToNBT.func_150315_a(processor.nbt);
|
||||
} catch (NBTException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (nbt != null) {
|
||||
currentStack.setTagCompound(nbt);
|
||||
}
|
||||
}
|
||||
transformItemPriorityList.add(new StackProcessor(currentStack, currentItem, processor.recipeProcessor, processor.identifier));
|
||||
for (String itemJsonString : itemPriorityList) {
|
||||
JsonObject jsonObject = new JsonParser().parse(itemJsonString).getAsJsonObject();
|
||||
if (jsonObject != null) {
|
||||
String itemName = jsonObject.get("itemName").getAsString();
|
||||
if (itemName == null || itemName.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
int meta = itemJsonString.contains("meta") ? Integer.parseInt(jsonObject.get("meta").getAsString()) : 0;
|
||||
String nbtJsonString = itemJsonString.contains("nbt") ? jsonObject.get("nbt").getAsString() : "";
|
||||
ItemStack currentStack = GameRegistry.makeItemStack(itemName, meta, 1, nbtJsonString);
|
||||
String recipeType = itemJsonString.contains("recipeType") ? jsonObject.get("name").getAsString() : "";
|
||||
transformItemPriorityList.add(new StackProcessor(currentStack, recipeType));
|
||||
}
|
||||
}
|
||||
|
||||
return transformItemPriorityList;
|
||||
}
|
||||
|
||||
|
||||
public static boolean isPreferItems(ItemStack itemStack, String recipeProcessor, String identifier) {
|
||||
for (StackProcessor processor : getTransformItemPriorityList()) {
|
||||
ItemStack copyStack = itemStack.copy();
|
||||
copyStack.stackSize = 1;
|
||||
if (ItemStack.areItemStacksEqual(copyStack, processor.itemStack)) {
|
||||
if (processor.recipeProcessor == null && processor.identifier == null) {
|
||||
public static boolean isPreferItems(ItemStack itemStack, String recipeType) {
|
||||
ItemStack stack = itemStack.copy();
|
||||
stack.setCount(1);
|
||||
for (StackProcessor stackProcessor : getTransformItemPriorityList()) {
|
||||
if (ItemStack.areItemStacksEqual(stack, stackProcessor.itemStack)) {
|
||||
String currentRecipeType = stackProcessor.recipeType;
|
||||
if (currentRecipeType == null || currentRecipeType.isEmpty()) {
|
||||
return true;
|
||||
} else if (recipeType.equals(currentRecipeType)) {
|
||||
return true;
|
||||
} else if (processor.recipeProcessor == null) {
|
||||
return identifier.equals(processor.identifier);
|
||||
} else if (processor.identifier == null) {
|
||||
return recipeProcessor.equals(processor.recipeProcessor);
|
||||
} else {
|
||||
return recipeProcessor.equals(processor.recipeProcessor) && identifier.equals(processor.identifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -94,44 +75,51 @@ public final class ItemUtils {
|
||||
}
|
||||
|
||||
public static boolean isPreferItems(ItemStack itemStack) {
|
||||
for (StackProcessor processor : getTransformItemPriorityList()) {
|
||||
ItemStack copyStack = itemStack.copy();
|
||||
copyStack.stackSize = 1;
|
||||
if (ItemStack.areItemStacksEqual(copyStack, processor.itemStack)) {
|
||||
ItemStack stack = itemStack.copy();
|
||||
stack.setCount(1);
|
||||
for (StackProcessor stackProcessor : getTransformItemPriorityList()) {
|
||||
if (ItemStack.areItemStacksEqual(stack, stackProcessor.itemStack)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isInBlackList(ItemStack itemStack, String recipeProcessor, String identifier) {
|
||||
for (StackProcessor processor : getTransformItemBlacklist()) {
|
||||
ItemStack copyStack = itemStack.copy();
|
||||
copyStack.stackSize = 1;
|
||||
if (ItemStack.areItemStacksEqual(copyStack, processor.itemStack)) {
|
||||
if (processor.recipeProcessor == null && processor.identifier == null) {
|
||||
public static boolean isInBlackList(ItemStack itemStack, String recipeType) {
|
||||
ItemStack stack = itemStack.copy();
|
||||
stack.setCount(1);
|
||||
for (StackProcessor stackProcessor : getTransformItemBlacklist()) {
|
||||
if (ItemStack.areItemStacksEqual(stack, stackProcessor.itemStack)) {
|
||||
String currentRecipeType = stackProcessor.recipeType;
|
||||
if (currentRecipeType == null || currentRecipeType.isEmpty()) {
|
||||
return true;
|
||||
} else if (recipeType.equals(currentRecipeType)) {
|
||||
return true;
|
||||
} else if (processor.recipeProcessor == null) {
|
||||
return identifier.equals(processor.identifier);
|
||||
} else if (processor.identifier == null) {
|
||||
return recipeProcessor.equals(processor.recipeProcessor);
|
||||
} else {
|
||||
return recipeProcessor.equals(processor.recipeProcessor) && identifier.equals(processor.identifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ItemStack getPreferModItem(ItemStack[] items) {
|
||||
for (String currentId : transformPriorityModList) {
|
||||
for(ItemStack stack : items){
|
||||
GameRegistry.UniqueIdentifier itemId = GameRegistry.findUniqueIdentifierFor(stack.getItem());
|
||||
if(currentId.equals(itemId.modId)){
|
||||
return stack;
|
||||
public static ItemStack getPreferModItem(IGuiIngredient<ItemStack> ingredient) {
|
||||
for (String currentId : modPriorityList) {
|
||||
for (ItemStack currentIngredient : ingredient.getAllIngredients()) {
|
||||
String itemModid = currentIngredient.getItem().getRegistryName().getNamespace();
|
||||
if (itemModid.equals(currentId)) {
|
||||
return currentIngredient;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
public static boolean isPreferModItem(ItemStack stack) {
|
||||
for (String currentId : modPriorityList) {
|
||||
String itemModid = stack.getItem().getRegistryName().getNamespace();
|
||||
if (itemModid.equals(currentId)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,39 +1,46 @@
|
||||
package com.github.vfyjxf.nee.utils;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import mezz.jei.api.gui.IGuiIngredient;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class StackProcessor {
|
||||
public String modid;
|
||||
public String name;
|
||||
import java.io.Serializable;
|
||||
|
||||
public class StackProcessor implements Serializable {
|
||||
public String itemName;
|
||||
public String meta;
|
||||
public String nbt;
|
||||
public String recipeType;
|
||||
public ItemStack itemStack;
|
||||
public Item item;
|
||||
public String recipeProcessor;
|
||||
public String identifier;
|
||||
public int stackSize;
|
||||
public IGuiIngredient<ItemStack> ingredient;
|
||||
|
||||
public StackProcessor(String modid, String name, String meta, String nbt){
|
||||
this.modid = modid;
|
||||
this.name = name;
|
||||
public StackProcessor(String itemName, String meta, String nbt, String recipeType) {
|
||||
this.itemName = itemName;
|
||||
this.meta = meta;
|
||||
this.nbt = nbt;
|
||||
}
|
||||
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;
|
||||
this.recipeType = recipeType;
|
||||
}
|
||||
|
||||
public StackProcessor(ItemStack itemStack, Item item, String recipeProcessor, String identifier){
|
||||
public StackProcessor(String itemName, String meta) {
|
||||
this.itemName = itemName;
|
||||
this.meta = meta;
|
||||
}
|
||||
|
||||
public StackProcessor(ItemStack itemStack, String recipeType){
|
||||
this.itemStack = itemStack;
|
||||
this.item = item;
|
||||
this.recipeProcessor = recipeProcessor;
|
||||
this.identifier = identifier;
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copied from Just Enough Energistics(https://github.com/p455w0rd/JustEnoughEnergistics/blob/master/src/main/java/p455w0rd/jee/util/WrappedTable.java)
|
||||
*/
|
||||
package com.github.vfyjxf.nee.utils;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.github.vfyjxf.nee.NotEnoughEnergistics;
|
||||
import com.github.vfyjxf.nee.jei.NEERecipeTransferHandler;
|
||||
import com.google.common.collect.ImmutableTable;
|
||||
|
||||
import appeng.container.implementations.ContainerPatternTerm;
|
||||
import mezz.jei.collect.Table;
|
||||
|
||||
public class WrappedTable<R, C, V> extends Table<R, C, V> {
|
||||
|
||||
private static final Field f_modifiers;
|
||||
private static final Field f_table;
|
||||
private static final Field f_rowMappingFunction;
|
||||
private final Table<R, C, V> wrapped;
|
||||
|
||||
static {
|
||||
try {
|
||||
f_modifiers = Field.class.getDeclaredField("modifiers");
|
||||
f_modifiers.setAccessible(true);
|
||||
|
||||
f_table = Table.class.getDeclaredField("table");
|
||||
f_table.setAccessible(true);
|
||||
makeWriteable(f_table);
|
||||
|
||||
f_rowMappingFunction = Table.class.getDeclaredField("rowMappingFunction");
|
||||
f_rowMappingFunction.setAccessible(true);
|
||||
makeWriteable(f_rowMappingFunction);
|
||||
|
||||
}
|
||||
catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
throw new RuntimeException("Unable to do reflection things.", e);
|
||||
}
|
||||
}
|
||||
|
||||
public WrappedTable(Table<R, C, V> other) {
|
||||
super(new HashMap<>(), HashMap::new);//Dummy values to constructor, will be replaced.
|
||||
wrapped = other;
|
||||
|
||||
//Set underlying table stuff incase anyone else reflects it.
|
||||
try {
|
||||
f_table.set(this, f_table.get(other));
|
||||
f_rowMappingFunction.set(this, f_rowMappingFunction.get(other));
|
||||
}
|
||||
catch (IllegalAccessException e) {
|
||||
throw new RuntimeException("Unable to do reflection things.", e);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public V onValueSet(R row, V value) {
|
||||
if (row == ContainerPatternTerm.class && value.getClass().getCanonicalName().equals("appeng.integration.modules.jei.RecipeTransferHandler")) {
|
||||
value = (V) new NEERecipeTransferHandler();
|
||||
NotEnoughEnergistics.logger.info("AE2 RecipeTransfeHandler Replaced Successfully (Overwrite Denied)");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public V computeIfAbsent(R row, C col, Supplier<V> valueSupplier) {
|
||||
Map<C, V> rowMap = getRow(row);
|
||||
return rowMap.computeIfAbsent(col, k -> onValueSet(row, valueSupplier.get()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public V put(R row, C col, V val) {
|
||||
Map<C, V> rowMap = getRow(row);
|
||||
return rowMap.put(col, onValueSet(row, val));
|
||||
}
|
||||
|
||||
@Override
|
||||
public V get(R row, C col) {
|
||||
return wrapped.get(row, col);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<C, V> getRow(R row) {
|
||||
return wrapped.getRow(row);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableTable<R, C, V> toImmutable() {
|
||||
return wrapped.toImmutable();
|
||||
}
|
||||
|
||||
private static void makeWriteable(Field field) throws IllegalAccessException {
|
||||
if ((field.getModifiers() & Modifier.FINAL) != 0) {
|
||||
f_modifiers.set(field, field.getModifiers() & ~Modifier.FINAL);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,7 +8,7 @@
|
||||
"updateUrl": "",
|
||||
"authorList": ["${mod_author}"],
|
||||
"credits": "${mod_credits}",
|
||||
"logoFile":"${mod_logo}",
|
||||
"logoFile": "${mod_logo}",
|
||||
"screenshots": [],
|
||||
"dependencies": []
|
||||
}]
|
||||
}]
|
||||
Reference in new issue
Block a user