Skip to content

Commit ae0e23e

Browse files
committed
add mod priority list
1 parent 807e8cb commit ae0e23e

File tree

6 files changed

+41
-8
lines changed

6 files changed

+41
-8
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ This mod removes that functionality and allows the player to use NEI's transfer
1616
- If an item is a probability output, then nee will not transfer it.
1717
- Combine like stacks in processing patterns.
1818
- Support Processing Pattern Terminal(16 -> 4 mode).
19-
- 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)
19+
- 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)
20+
- Allow you to add mod priority list,if it's the mod's item,it will be use first.
2021

2122
## Compatible Modslist as followed:
2223

READNE_CN.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ NotEnoughEnergistics 是[Just Enough Energistics](https://www.curseforge.com/min
1212
- 在处理模式中合并同类物品
1313
- 支持增广样板终端(16 -> 4模式)
1414
- 允许你设置转换黑名单和转换优先名单,如对应物品在里面,那么他们将不会被转移/优先被转移
15+
- 允许你设置mod优先级列表,优先使用该mod的物品
16+
1517
## 当前支持的Mod列表:
1618

1719
- [ ] AppliedEnergistics2(我们将不会支持AE2,因为AE2没有注册对应的OverlayHandler)

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ org.gradle.daemon=false
66
mc_version=1.7.10
77
nei_version=2.1.6-GTNH
88
ae2_version=rv3-beta-52-GTNH
9-
mod_version=1.2.3
9+
mod_version=1.2.4
1010
forge_version=10.13.4.1614
1111
mod_group=com.github.vfyjxf.neenergistics
1212
mod_id=neenergistics

src/main/java/com/github/vfyjxf/nee/NEEConfig.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public class NEEConfig {
1212

1313
public static String[] transformBlacklist = new String[0];
1414
public static String[] transformPriorityList = new String[0];
15+
public static String[] transformPriorityModList = new String[0];
1516

1617
public static void loadConfig(File configFile) {
1718
Configuration config = new Configuration(configFile);
@@ -23,6 +24,10 @@ public static void loadConfig(File configFile) {
2324
"example: \"{modid:minecraft,name:iron_ingot,recipeProcessor:EnderIO,identifier:EnderIOAlloySmelter}\"").getStringList();
2425
transformPriorityList = config.get("client", "transformItemPriorityList", new String[0],
2526
"If item in tne priority list, it will be transferred first.").getStringList();
27+
28+
transformPriorityModList = config.get("client","transformPriorityModList",new String[0],
29+
"if oredict has this mod's item, use it first").getStringList();
30+
2631
if (config.hasChanged()) config.save();
2732
}
2833

src/main/java/com/github/vfyjxf/nee/nei/NEECraftingHandler.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,14 @@ private PacketNEIPatternRecipe packProcessRecipe(IRecipeHandler recipe, int reci
7575
}
7676

7777
for (PositionedStack positionedStack : tInputs) {
78-
ItemStack currentStack = positionedStack.items[0];
78+
ItemStack currentStack = positionedStack.item;
79+
currentStack.stackSize = positionedStack.items[0].stackSize;
80+
81+
ItemStack preferModItem = ItemUtils.getPreferModItem(positionedStack.items);
82+
if (preferModItem != null) {
83+
currentStack = preferModItem;
84+
}
85+
7986
for (ItemStack stack : positionedStack.items) {
8087
if (Platform.isRecipePrioritized(stack) || ItemUtils.isPreferItems(stack, recipeProcessorId, identifier)) {
8188
currentStack = stack.copy();
@@ -112,11 +119,18 @@ private PacketNEIPatternRecipe packCraftingTableRecipe(IRecipeHandler recipe, in
112119
if (positionedStack.items != null && positionedStack.items.length > 0) {
113120
final ItemStack[] currentStackList = positionedStack.items;
114121
ItemStack stack = positionedStack.items[0];
122+
123+
ItemStack preferModItem = ItemUtils.getPreferModItem(positionedStack.items);
124+
if (preferModItem != null) {
125+
stack = preferModItem;
126+
}
127+
115128
for (ItemStack currentStack : currentStackList) {
116129
if (Platform.isRecipePrioritized(currentStack) || ItemUtils.isPreferItems(currentStack)) {
117130
stack = currentStack.copy();
118131
}
119132
}
133+
120134
recipeInputs.setTag("#" + slotIndex, stack.writeToNBT(new NBTTagCompound()));
121135
}
122136
}
@@ -146,8 +160,9 @@ private PacketArcaneRecipe packetArcaneRecipe(IRecipeHandler recipe, int recipeI
146160
itemAspectClz = iA;
147161
final NBTTagCompound recipeInputs = new NBTTagCompound();
148162
List<PositionedStack> ingredients = recipe.getIngredientStacks(recipeIndex);
149-
ingredients.removeIf(positionedStack -> itemAspectClz.isInstance(positionedStack.item.getItem()));
150-
163+
if (itemAspectClz != null) {
164+
ingredients.removeIf(positionedStack -> itemAspectClz.isInstance(positionedStack.item.getItem()));
165+
}
151166
for (PositionedStack positionedStack : ingredients) {
152167

153168
if (positionedStack.items != null && positionedStack.items.length > 0) {

src/main/java/com/github/vfyjxf/nee/utils/ItemUtils.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
package com.github.vfyjxf.nee.utils;
22

3-
import static com.github.vfyjxf.nee.NEEConfig.transformBlacklist;
4-
import static com.github.vfyjxf.nee.NEEConfig.transformPriorityList;
5-
63
import com.github.vfyjxf.nee.NotEnoughEnergistics;
74
import com.google.gson.Gson;
85
import cpw.mods.fml.common.registry.GameRegistry;
@@ -16,6 +13,8 @@
1613
import java.util.ArrayList;
1714
import java.util.List;
1815

16+
import static com.github.vfyjxf.nee.NEEConfig.*;
17+
1918
public final class ItemUtils {
2019

2120
public static Gson gson = new Gson();
@@ -124,4 +123,15 @@ public static boolean isInBlackList(ItemStack itemStack, String recipeProcessor,
124123
return false;
125124
}
126125

126+
public static ItemStack getPreferModItem(ItemStack[] items) {
127+
for (String currentId : transformPriorityModList) {
128+
for(ItemStack stack : items){
129+
GameRegistry.UniqueIdentifier itemId = GameRegistry.findUniqueIdentifierFor(stack.getItem());
130+
if(currentId.equals(itemId.modId)){
131+
return stack;
132+
}
133+
}
134+
}
135+
return null;
136+
}
127137
}

0 commit comments

Comments
 (0)