Skip to content

Commit

Permalink
Add config
Browse files Browse the repository at this point in the history
Add item blacklist and item  priority list
  • Loading branch information
vfyjxf committed Aug 11, 2021
1 parent 0a29733 commit 23da96e
Show file tree
Hide file tree
Showing 21 changed files with 362 additions and 66 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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)
11 changes: 5 additions & 6 deletions READNE_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ NotEnoughEnergistics 是[Just Enough Energistics](https://www.curseforge.com/min
- 如果一个物品输出为概率输出,那么NEE不会将它写入样板终端
- 在处理模式中合并同类物品
- 支持增广样板终端(16 -> 4模式)

- 允许你设置转换黑名单和转换优先名单,如对应物品在里面,那么他们将不会被转移/优先被转移
## 当前支持的Mod列表:

- [ ] AppliedEnergistics2(我们将不会支持AE2,因为AE2没有注册对应的OverlayHandler)
Expand All @@ -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)
Expand Down
97 changes: 49 additions & 48 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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"

}

Expand All @@ -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) {
Expand All @@ -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
}
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ 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
mod_name=NotEnoughEnergistics
mod_archives_name=NotEnoughEnergistics
mod_author=vfyxf
mod_description=
mod_logo=assets/neenergistics/meta/logo.png
mod_credits=Thanks TheRealp455w0rd
44 changes: 44 additions & 0 deletions src/main/java/com/github/vfyjxf/nee/NEECommands.java
Original file line number Diff line number Diff line change
@@ -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");
}
}
29 changes: 29 additions & 0 deletions src/main/java/com/github/vfyjxf/nee/NEEConfig.java
Original file line number Diff line number Diff line change
@@ -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();
}

}
2 changes: 1 addition & 1 deletion src/main/java/com/github/vfyjxf/nee/NEINeeConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private void installPatternTerminalExSupport(Set<String> identifiers) {
return;
}
identifiers.remove("crafting");
identifiers.remove( "crafting2x2");
identifiers.remove("crafting2x2");
//PatternTermEx Support
for (String ident : identifiers) {
API.registerGuiOverlay(GuiPatternTermEx.class, ident);
Expand Down
17 changes: 16 additions & 1 deletion src/main/java/com/github/vfyjxf/nee/NotEnoughEnergistics.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,19 @@
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";
Expand All @@ -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());
}

}
11 changes: 7 additions & 4 deletions src/main/java/com/github/vfyjxf/nee/nei/NEECraftingHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
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;
Expand Down Expand Up @@ -53,7 +54,7 @@ private PacketNEIPatternRecipe packProcessRecipe(IRecipeHandler recipe, int reci
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) {
Expand All @@ -76,11 +77,14 @@ private PacketNEIPatternRecipe packProcessRecipe(IRecipeHandler recipe, int reci
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++;
}
Expand All @@ -94,7 +98,6 @@ private PacketNEIPatternRecipe packProcessRecipe(IRecipeHandler recipe, int reci
}
}
}

return new PacketNEIPatternRecipe(recipeInputs, recipeOutputs);
}

Expand All @@ -109,7 +112,7 @@ private PacketNEIPatternRecipe packCraftingTableRecipe(IRecipeHandler recipe, in
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();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ public Set<String> getAllOverlayIdentifier() {
));
}

@Override
public String getRecipeProcessorId() {
return "Avaritia";
}

@Override
public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) {
for (String ident : getAllOverlayIdentifier()) {
Expand Down
Loading

0 comments on commit 23da96e

Please sign in to comment.