add mod priority list

This commit is contained in:
vfyjxf committed 2021-08-17 00:28:52 +08:00
1 parent 807e8cbdb9
commit ae0e23eac5
6 files changed
+41 -8

No files matched your search

@@ -12,6 +12,7 @@ public class NEEConfig {
public static String[] transformBlacklist = new String[0];
public static String[] transformPriorityList = new String[0];
public static String[] transformPriorityModList = new String[0];
public static void loadConfig(File configFile) {
Configuration config = new Configuration(configFile);
@@ -23,6 +24,10 @@ public class NEEConfig {
"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();
transformPriorityModList = config.get("client","transformPriorityModList",new String[0],
"if oredict has this mod's item, use it first").getStringList();
if (config.hasChanged()) config.save();
}
@@ -75,7 +75,14 @@ public class NEECraftingHandler implements IOverlayHandler {
}
for (PositionedStack positionedStack : tInputs) {
ItemStack currentStack = positionedStack.items[0];
ItemStack currentStack = positionedStack.item;
currentStack.stackSize = positionedStack.items[0].stackSize;
ItemStack preferModItem = ItemUtils.getPreferModItem(positionedStack.items);
if (preferModItem != null) {
currentStack = preferModItem;
}
for (ItemStack stack : positionedStack.items) {
if (Platform.isRecipePrioritized(stack) || ItemUtils.isPreferItems(stack, recipeProcessorId, identifier)) {
currentStack = stack.copy();
@@ -112,11 +119,18 @@ public class NEECraftingHandler implements IOverlayHandler {
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()));
}
}
@@ -146,8 +160,9 @@ public class NEECraftingHandler implements IOverlayHandler {
itemAspectClz = iA;
final NBTTagCompound recipeInputs = new NBTTagCompound();
List<PositionedStack> ingredients = recipe.getIngredientStacks(recipeIndex);
ingredients.removeIf(positionedStack -> itemAspectClz.isInstance(positionedStack.item.getItem()));
if (itemAspectClz != null) {
ingredients.removeIf(positionedStack -> itemAspectClz.isInstance(positionedStack.item.getItem()));
}
for (PositionedStack positionedStack : ingredients) {
if (positionedStack.items != null && positionedStack.items.length > 0) {
@@ -1,8 +1,5 @@
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;
@@ -16,6 +13,8 @@ import net.minecraft.nbt.NBTTagCompound;
import java.util.ArrayList;
import java.util.List;
import static com.github.vfyjxf.nee.NEEConfig.*;
public final class ItemUtils {
public static Gson gson = new Gson();
@@ -124,4 +123,15 @@ public final class ItemUtils {
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;
}
}
}
return null;
}
}