Add config

Add item blacklist and item  priority list
This commit is contained in:
vfyjxf committed 2021-08-11 21:59:56 +08:00
1 parent 0a297333c7
commit 23da96e1aa
21 files changed
+362 -66

No files matched your search

+5 -5
View File
@@ -16,6 +16,7 @@ This mod removes that functionality and allows the player to use NEI's transfer
- 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 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)
## Compatible Modslist as followed:
@@ -27,16 +28,15 @@ This mod removes that functionality and allows the player to use NEI's transfer
- [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 transform ArcaneRecipe from NEI, it requires Thaumcraft NEI Plugin)
- [x] Thaumic Energistics(Allows you to transfer ArcaneRecipe from NEI to Knowledge Inscriber, it requires Thaumcraft NEI Plugin)
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
- Add item blackList ,if item in the blacklist, it will not be transferred.
- Add item priority list, if item in tne priority list, it will be transferred first
~~Combine like stacks in processing patterns.~~
-[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)
+5 -6
View File
@@ -11,7 +11,7 @@ NotEnoughEnergistics 是[Just Enough Energistics](https://www.curseforge.com/min
- 如果一个物品输出为概率输出,那么NEE不会将它写入样板终端
- 在处理模式中合并同类物品
- 支持增广样板终端(16 -> 4模式)
- 允许你设置转换黑名单和转换优先名单,如对应物品在里面,那么他们将不会被转移/优先被转移
## 当前支持的Mod列表:
- [ ] AppliedEnergistics2(我们将不会支持AE2,因为AE2没有注册对应的OverlayHandler)
@@ -22,15 +22,14 @@ NotEnoughEnergistics 是[Just Enough Energistics](https://www.curseforge.com/min
- [x] EnderIO
- [x] Forestry(不支持发酵机和蒸馏器,因为它们没有物品输出)
- [x] Thaumcraft NEI Plugin
- [x] Thaumic Energistics(允许你从NEI转移奥术合成台配方,需要Thaumcraft NEI Plugin)
- [x] Thaumic Energistics(允许你从NEI转移奥术合成台配方到知识记录仪,需要Thaumcraft NEI Plugin)
如果你想要别的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 -48
View File
@@ -1,23 +1,23 @@
buildscript {
repositories {
mavenCentral()
jcenter()
repositories {
mavenCentral()
jcenter()
maven {
name = "github"
url = "https://github.com/juanmuscaria/maven/raw/master"
}
maven {
name = "gt"
url = "https://gregtech.overminddl1.com/"
}
maven {
name = "jitpack"
url = "https://jitpack.io"
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-1.4.4-SNAPSHOT'
}
maven {
name = "gt"
url = "https://gregtech.overminddl1.com/"
}
maven {
name = "jitpack"
url = "https://jitpack.io"
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-1.4.4-SNAPSHOT'
}
}
apply plugin: 'java'
@@ -30,32 +30,32 @@ group = mod_group
archivesBaseName = mod_archives_name
minecraft {
version = "1.7.10-10.13.4.1614-1.7.10"
runDir = "eclipse"
replace "@VERSION@", project.version
version = "1.7.10-10.13.4.1614-1.7.10"
runDir = "eclipse"
replace "@VERSION@", project.version
}
repositories {
maven {
name 'chickenbones'
url 'http://chickenbones.net/maven'
}
maven {
name = "gt"
url = "http://gregtech.overminddl1.com/"
}
flatDir {
dirs 'libs'
}
maven {
name 'chickenbones'
url 'http://chickenbones.net/maven'
}
maven {
name = "gt"
url = "http://gregtech.overminddl1.com/"
}
flatDir {
dirs 'libs'
}
}
dependencies {
compile "codechicken:NotEnoughItems:${mc_version}-${nei_version}:universal"
compile "codechicken:CodeChickenLib:1.7.10-1.1.3.138:dev"
compile "codechicken:CodeChickenCore:1.7.10-1.0.7.+:dev"
compile "codechicken:NotEnoughItems:${mc_version}-${nei_version}:universal"
compile "codechicken:CodeChickenLib:1.7.10-1.1.3.138:dev"
compile "codechicken:CodeChickenCore:1.7.10-1.0.7.+:dev"
runtime "thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev"
runtime "thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev"
}
@@ -64,13 +64,14 @@ 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_credits': mod_credits
'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_logo': mod_logo,
'mod_credits': mod_credits
}
from(sourceSets.main.resources.srcDirs) {
@@ -79,21 +80,21 @@ processResources {
}
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
}
jar{
appendix project.minecraft.version
jar {
appendix project.minecraft.version
}
artifacts {
archives devJar
archives sourcesJar
archives devJar
archives sourcesJar
}
+2 -1
View File
@@ -6,7 +6,7 @@ org.gradle.daemon=false
mc_version=1.7.10
nei_version=2.1.6-GTNH
ae2_version=rv3-beta-52-GTNH
mod_version=1.1.2
mod_version=1.2.0
forge_version=10.13.4.1614
mod_group=com.github.vfyjxf.neenergistics
mod_id=neenergistics
@@ -14,4 +14,5 @@ mod_name=NotEnoughEnergistics
mod_archives_name=NotEnoughEnergistics
mod_author=vfyxf
mod_description=
mod_logo=assets/neenergistics/meta/logo.png
mod_credits=Thanks TheRealp455w0rd
@@ -0,0 +1,44 @@
package com.github.vfyjxf.nee;
import com.github.vfyjxf.nee.processor.IRecipeProcessor;
import com.github.vfyjxf.nee.processor.RecipeProcessor;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.command.WrongUsageException;
import java.util.List;
import static com.github.vfyjxf.nee.NotEnoughEnergistics.logger;
public class NEECommands extends CommandBase {
@Override
public String getCommandName() {
return "nee";
}
@Override
public String getCommandUsage(ICommandSender sender) {
return "use /nee RecipeProcessor to get RecipeProcessor and identifier,see them in log";
}
@Override
public void processCommand(ICommandSender sender, String[] args) {
if (args.length != 0) {
if ("RecipeProcessor".equals(args[0])) {
for (IRecipeProcessor processor : RecipeProcessor.recipeProcessors) {
logger.info("RecipeProcessor:" + processor.getRecipeProcessorId() + " identifier:");
for (String ident : processor.getAllOverlayIdentifier()) {
logger.info(ident);
}
}
}
}else {
throw new WrongUsageException("use /nee RecipeProcessor to get RecipeProcessor and identifier,see them in log");
}
}
@Override
public List addTabCompletionOptions(ICommandSender sender, String[] args) {
return CommandBase.getListOfStringsMatchingLastWord(args, "RecipeProcessor");
}
}
@@ -0,0 +1,29 @@
package com.github.vfyjxf.nee;
import net.minecraftforge.common.config.Configuration;
import java.io.File;
/**
* @author vfyjxf
*/
public class NEEConfig {
public static String[] transformBlacklist = new String[0];
public static String[] transformPriorityList = new String[0];
public static void loadConfig(File configFile) {
Configuration config = new Configuration(configFile);
config.load();
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();
if (config.hasChanged()) config.save();
}
}
@@ -74,7 +74,7 @@ public class NEINeeConfig implements IConfigureNEI {
return;
}
identifiers.remove("crafting");
identifiers.remove( "crafting2x2");
identifiers.remove("crafting2x2");
//PatternTermEx Support
for (String ident : identifiers) {
API.registerGuiOverlay(GuiPatternTermEx.class, ident);
@@ -3,11 +3,19 @@ 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 org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.File;
@Mod(modid = NotEnoughEnergistics.MODID, version = NotEnoughEnergistics.VERSION, name = NotEnoughEnergistics.NAME, dependencies = NotEnoughEnergistics.DEPENDENCIES)
@Mod(modid = NotEnoughEnergistics.MODID,
version = NotEnoughEnergistics.VERSION,
name = NotEnoughEnergistics.NAME,
dependencies = NotEnoughEnergistics.DEPENDENCIES,
useMetadata = true)
public class NotEnoughEnergistics {
public static final String MODID = "neenergistics";
public static final String NAME = "NotEnoughEnergistics";
@@ -18,5 +26,12 @@ public class 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());
}
}
@@ -12,6 +12,7 @@ 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;
@@ -53,7 +54,7 @@ public class NEECraftingHandler implements IOverlayHandler {
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) {
@@ -76,11 +77,14 @@ public class NEECraftingHandler implements IOverlayHandler {
for (PositionedStack positionedStack : tInputs) {
ItemStack currentStack = positionedStack.items[0];
for (ItemStack stack : positionedStack.items) {
if (Platform.isRecipePrioritized(stack)) {
if (Platform.isRecipePrioritized(stack) || ItemUtils.isPreferItems(stack, recipeProcessorId, identifier)) {
currentStack = stack.copy();
break;
}
}
if (ItemUtils.isInBlackList(currentStack, recipeProcessorId, identifier)) {
continue;
}
recipeInputs.setTag("#" + inputIndex, currentStack.writeToNBT(new NBTTagCompound()));
inputIndex++;
}
@@ -94,7 +98,6 @@ public class NEECraftingHandler implements IOverlayHandler {
}
}
}
return new PacketNEIPatternRecipe(recipeInputs, recipeOutputs);
}
@@ -109,7 +112,7 @@ public class NEECraftingHandler implements IOverlayHandler {
final ItemStack[] currentStackList = positionedStack.items;
ItemStack stack = positionedStack.items[0];
for (ItemStack currentStack : currentStackList) {
if (Platform.isRecipePrioritized(currentStack)) {
if (Platform.isRecipePrioritized(currentStack) || ItemUtils.isPreferItems(currentStack)) {
stack = currentStack.copy();
}
}
@@ -13,6 +13,11 @@ public class AvaritiaRecipeProcessor implements IRecipeProcessor {
));
}
@Override
public String getRecipeProcessorId() {
return "Avaritia";
}
@Override
public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) {
for (String ident : getAllOverlayIdentifier()) {
@@ -15,6 +15,11 @@ public class EnderIORecipeProcessor implements IRecipeProcessor {
));
}
@Override
public String getRecipeProcessorId() {
return "EnderIO";
}
@Override
public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) {
for (String ident : getAllOverlayIdentifier()) {
@@ -10,6 +10,11 @@ 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) {
@@ -49,6 +49,11 @@ public class GregTechRecipeProcessor implements IRecipeProcessor {
return identifiers;
}
@Override
public String getRecipeProcessorId() {
return "GregTech5";
}
@Override
public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) {
@@ -18,6 +18,11 @@ public class ICRecipeProcessor implements IRecipeProcessor {
));
}
@Override
public String getRecipeProcessorId() {
return "IC2";
}
@Override
public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) {
for (String ident : getAllOverlayIdentifier()) {
@@ -18,6 +18,8 @@ public interface IRecipeProcessor {
return Collections.emptySet();
}
String getRecipeProcessorId();
List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier);
List<PositionedStack> getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier);
@@ -19,6 +19,11 @@ public class TCNEIPluginRecipeProcessor implements IRecipeProcessor{
));
}
@Override
public String getRecipeProcessorId() {
return "TCNEIPlugin";
}
@Override
public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) {
for(String ident : getAllOverlayIdentifier()){
@@ -14,6 +14,11 @@ public class VanillaRecipeProcessor implements IRecipeProcessor {
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<>();
@@ -0,0 +1,127 @@
package com.github.vfyjxf.nee.utils;
import static com.github.vfyjxf.nee.NEEConfig.transformBlacklist;
import static com.github.vfyjxf.nee.NEEConfig.transformPriorityList;
import com.github.vfyjxf.nee.NotEnoughEnergistics;
import com.google.gson.Gson;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.JsonToNBT;
import net.minecraft.nbt.NBTException;
import net.minecraft.nbt.NBTTagCompound;
import java.util.ArrayList;
import java.util.List;
public final class ItemUtils {
public static Gson gson = new Gson();
public 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));
}
}
}
return transformItemBlacklist;
}
public 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));
}
}
}
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) {
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 boolean isPreferItems(ItemStack itemStack) {
for (StackProcessor processor : getTransformItemPriorityList()) {
ItemStack copyStack = itemStack.copy();
copyStack.stackSize = 1;
if (ItemStack.areItemStacksEqual(copyStack, processor.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) {
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;
}
}
@@ -0,0 +1,39 @@
package com.github.vfyjxf.nee.utils;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class StackProcessor {
public String modid;
public String name;
public String meta;
public String nbt;
public ItemStack itemStack;
public Item item;
public String recipeProcessor;
public String identifier;
public StackProcessor(String modid, String name, String meta, String nbt){
this.modid = modid;
this.name = name;
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;
}
public StackProcessor(ItemStack itemStack, Item item, String recipeProcessor, String identifier){
this.itemStack = itemStack;
this.item = item;
this.recipeProcessor = recipeProcessor;
this.identifier = identifier;
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB

+1
View File
@@ -8,6 +8,7 @@
"updateUrl": "",
"authorList": ["${mod_author}"],
"credits": "${mod_credits}",
"logoFile":"${mod_logo}",
"screenshots": [],
"dependencies": []
}]