mirror of
https://github.com/GTNewHorizons/NotEnoughEnergistics.git
synced 2026-10-26 14:23:58 +00:00
fix crash caused by item json error
This commit is contained in:
1 parent
b062cac5ed
commit
a3ebfd8f5d
7 files changed
+24
-15
No files matched your search
+1
-1
@@ -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.2.9
|
||||
mod_version=1.2.10
|
||||
forge_version=10.13.4.1614
|
||||
mod_group=com.github.vfyjxf.neenergistics
|
||||
mod_id=neenergistics
|
||||
|
||||
@@ -23,7 +23,7 @@ public class NEEConfig {
|
||||
"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 item in the 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();
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package com.github.vfyjxf.nee;
|
||||
|
||||
import appeng.client.gui.implementations.GuiPatternTerm;
|
||||
import appeng.client.gui.implementations.GuiPatternTermEx;
|
||||
import appeng.container.slot.SlotFake;
|
||||
import com.github.vfyjxf.nee.nei.NEECraftingHandler;
|
||||
import com.github.vfyjxf.nee.network.NEENetworkHandler;
|
||||
import com.github.vfyjxf.nee.network.packet.PacketStackCountChange;
|
||||
import com.github.vfyjxf.nee.utils.GuiUtils;
|
||||
|
||||
@@ -4,7 +4,6 @@ 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;
|
||||
|
||||
@@ -2,7 +2,6 @@ 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;
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
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.*;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.github.vfyjxf.nee.utils;
|
||||
|
||||
import com.github.vfyjxf.nee.NotEnoughEnergistics;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -18,11 +19,19 @@ import static com.github.vfyjxf.nee.NEEConfig.*;
|
||||
public final class ItemUtils {
|
||||
|
||||
public static Gson gson = new Gson();
|
||||
public static List<StackProcessor> transformItemBlacklist = getTransformItemBlacklist();
|
||||
public static List<StackProcessor> transformItemPriorityList = getTransformItemPriorityList();
|
||||
|
||||
public static List<StackProcessor> getTransformItemBlacklist() {
|
||||
List<StackProcessor> transformItemBlacklist = new ArrayList<>();
|
||||
for (String itemJsonString : transformBlacklist) {
|
||||
StackProcessor processor = gson.fromJson(itemJsonString, StackProcessor.class);
|
||||
StackProcessor processor;
|
||||
try {
|
||||
processor = gson.fromJson(itemJsonString, StackProcessor.class);
|
||||
} catch (JsonSyntaxException e) {
|
||||
NotEnoughEnergistics.logger.error("Found a error item json in item blacklist: " + itemJsonString);
|
||||
continue;
|
||||
}
|
||||
if (processor != null) {
|
||||
Item currentItem = GameRegistry.findItem(processor.modid, processor.name);
|
||||
if (currentItem != null) {
|
||||
@@ -49,7 +58,13 @@ public final class ItemUtils {
|
||||
public static List<StackProcessor> getTransformItemPriorityList() {
|
||||
List<StackProcessor> transformItemPriorityList = new ArrayList<>();
|
||||
for (String itemJsonString : transformPriorityList) {
|
||||
StackProcessor processor = gson.fromJson(itemJsonString, StackProcessor.class);
|
||||
StackProcessor processor;
|
||||
try {
|
||||
processor = gson.fromJson(itemJsonString, StackProcessor.class);
|
||||
} catch (JsonSyntaxException e) {
|
||||
NotEnoughEnergistics.logger.error("Found a error item json in item priority list: " + itemJsonString);
|
||||
continue;
|
||||
}
|
||||
if (processor != null) {
|
||||
Item currentItem = GameRegistry.findItem(processor.modid, processor.name);
|
||||
if (currentItem != null) {
|
||||
@@ -75,7 +90,7 @@ public final class ItemUtils {
|
||||
|
||||
|
||||
public static boolean isPreferItems(ItemStack itemStack, String recipeProcessor, String identifier) {
|
||||
for (StackProcessor processor : getTransformItemPriorityList()) {
|
||||
for (StackProcessor processor : ItemUtils.transformItemPriorityList) {
|
||||
ItemStack copyStack = itemStack.copy();
|
||||
copyStack.stackSize = 1;
|
||||
if (ItemStack.areItemStacksEqual(copyStack, processor.itemStack)) {
|
||||
@@ -94,7 +109,7 @@ public final class ItemUtils {
|
||||
}
|
||||
|
||||
public static boolean isPreferItems(ItemStack itemStack) {
|
||||
for (StackProcessor processor : getTransformItemPriorityList()) {
|
||||
for (StackProcessor processor : ItemUtils.transformItemPriorityList) {
|
||||
ItemStack copyStack = itemStack.copy();
|
||||
copyStack.stackSize = 1;
|
||||
if (ItemStack.areItemStacksEqual(copyStack, processor.itemStack)) {
|
||||
@@ -105,7 +120,7 @@ public final class ItemUtils {
|
||||
}
|
||||
|
||||
public static boolean isInBlackList(ItemStack itemStack, String recipeProcessor, String identifier) {
|
||||
for (StackProcessor processor : getTransformItemBlacklist()) {
|
||||
for (StackProcessor processor : ItemUtils.transformItemBlacklist) {
|
||||
ItemStack copyStack = itemStack.copy();
|
||||
copyStack.stackSize = 1;
|
||||
if (ItemStack.areItemStacksEqual(copyStack, processor.itemStack)) {
|
||||
@@ -125,9 +140,9 @@ public final class ItemUtils {
|
||||
|
||||
public static ItemStack getPreferModItem(ItemStack[] items) {
|
||||
for (String currentId : transformPriorityModList) {
|
||||
for(ItemStack stack : items){
|
||||
for (ItemStack stack : items) {
|
||||
GameRegistry.UniqueIdentifier itemId = GameRegistry.findUniqueIdentifierFor(stack.getItem());
|
||||
if(itemId.modId.equals(currentId)){
|
||||
if (itemId.modId.equals(currentId)) {
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user