diff --git a/build.properties b/build.properties index c4ed2a8..b587300 100644 --- a/build.properties +++ b/build.properties @@ -1,3 +1,3 @@ minecraft.version=1.10.2 forge.version=1.10.2-12.18.3.2254 -mod.version=2.0.12 +mod.version=2.0.13 diff --git a/src/main/java/modtweaker/mods/bloodmagic/handlers/AlchemyTable.java b/src/main/java/modtweaker/mods/bloodmagic/handlers/AlchemyTable.java index cb958aa..3f5e37a 100644 --- a/src/main/java/modtweaker/mods/bloodmagic/handlers/AlchemyTable.java +++ b/src/main/java/modtweaker/mods/bloodmagic/handlers/AlchemyTable.java @@ -79,31 +79,33 @@ public class AlchemyTable { if(!list.remove(recipe)) { LogHelper.logError(String.format("Error removing %s Recipe for %s", name, this.getRecipeInfo(recipe))); } else { - List wrappers = JEIAddonPlugin.recipeRegistry.getRecipeWrappers(JEIAddonPlugin.recipeRegistry.getRecipeCategories(Arrays.asList("BloodMagic:salchemyTable")).get(0)); - final AlchemyTableRecipeJEI[] recipeToRemove = {null}; - wrappers.forEach(wrap -> { - ArrayList wrapperStacks = wrap.getRecipe().getInput(); - int size = recipe.getInput().size(); - if(wrapperStacks.size() == size) { - boolean valid = true; - for(int i = 0; i < size; i++) { - if(wrapperStacks.get(i) instanceof ItemStack) { - ItemStack wrapperStack = (ItemStack) wrapperStacks.get(i); - ItemStack recipeStack = (ItemStack) recipe.getInput().get(i); - if(!wrapperStack.isItemEqual(recipeStack)) { + if (JEIAddonPlugin.recipeRegistry != null) { + List wrappers = JEIAddonPlugin.recipeRegistry.getRecipeWrappers(JEIAddonPlugin.recipeRegistry.getRecipeCategories(Arrays.asList("BloodMagic:salchemyTable")).get(0)); + final AlchemyTableRecipeJEI[] recipeToRemove = {null}; + wrappers.forEach(wrap -> { + ArrayList wrapperStacks = wrap.getRecipe().getInput(); + int size = recipe.getInput().size(); + if (wrapperStacks.size() == size) { + boolean valid = true; + for (int i = 0; i < size; i++) { + if (wrapperStacks.get(i) instanceof ItemStack) { + ItemStack wrapperStack = (ItemStack) wrapperStacks.get(i); + ItemStack recipeStack = (ItemStack) recipe.getInput().get(i); + if (!wrapperStack.isItemEqual(recipeStack)) { + valid = false; + } + } else { valid = false; } - } else { - valid = false; + } + if (valid) { + recipeToRemove[0] = wrap; } } - if(valid) { - recipeToRemove[0] = wrap; - } - } - - }); - MineTweakerAPI.getIjeiRecipeRegistry().removeRecipe(recipeToRemove[0]); + + }); + MineTweakerAPI.getIjeiRecipeRegistry().removeRecipe(recipeToRemove[0]); + } } } else { LogHelper.logError(String.format("Error removing %s Recipe: null object", name)); @@ -179,31 +181,33 @@ public class AlchemyTable { if(recipe != null) { if(this.list.remove(recipe)) { successful.add(recipe); - List wrappers = JEIAddonPlugin.recipeRegistry.getRecipeWrappers(JEIAddonPlugin.recipeRegistry.getRecipeCategories(Arrays.asList("BloodMagic:salchemyTable")).get(0)); - final AlchemyTableRecipeJEI[] recipeToRemove = {null}; - wrappers.forEach(wrap -> { - ArrayList wrapperStacks = wrap.getRecipe().getInput(); - int size = recipe.getInput().size(); - if(wrapperStacks.size() == size) { - boolean valid = true; - for(int i = 0; i < size; i++) { - if(wrapperStacks.get(i) instanceof ItemStack) { - ItemStack wrapperStack = (ItemStack) wrapperStacks.get(i); - ItemStack recipeStack = (ItemStack) recipe.getInput().get(i); - if(!wrapperStack.isItemEqual(recipeStack)) { + if (JEIAddonPlugin.recipeRegistry != null) { + List wrappers = JEIAddonPlugin.recipeRegistry.getRecipeWrappers(JEIAddonPlugin.recipeRegistry.getRecipeCategories(Arrays.asList("BloodMagic:salchemyTable")).get(0)); + final AlchemyTableRecipeJEI[] recipeToRemove = {null}; + wrappers.forEach(wrap -> { + ArrayList wrapperStacks = wrap.getRecipe().getInput(); + int size = recipe.getInput().size(); + if (wrapperStacks.size() == size) { + boolean valid = true; + for (int i = 0; i < size; i++) { + if (wrapperStacks.get(i) instanceof ItemStack) { + ItemStack wrapperStack = (ItemStack) wrapperStacks.get(i); + ItemStack recipeStack = (ItemStack) recipe.getInput().get(i); + if (!wrapperStack.isItemEqual(recipeStack)) { + valid = false; + } + } else { valid = false; } - } else { - valid = false; + } + if (valid) { + recipeToRemove[0] = wrap; } } - if(valid) { - recipeToRemove[0] = wrap; - } - } - - }); - MineTweakerAPI.getIjeiRecipeRegistry().removeRecipe(recipeToRemove[0]); + + }); + MineTweakerAPI.getIjeiRecipeRegistry().removeRecipe(recipeToRemove[0]); + } } else { LogHelper.logError(String.format("Error removing %s Recipe for %s", name, getRecipeInfo(recipe))); } diff --git a/src/main/java/modtweaker/mods/bloodmagic/handlers/Altar.java b/src/main/java/modtweaker/mods/bloodmagic/handlers/Altar.java index a8e0857..43511cd 100644 --- a/src/main/java/modtweaker/mods/bloodmagic/handlers/Altar.java +++ b/src/main/java/modtweaker/mods/bloodmagic/handlers/Altar.java @@ -68,23 +68,23 @@ public class Altar super(Altar.name, map); this.recipes.put(inputs, altarRecipe); } - - + + @Override public void apply() { if(recipes.isEmpty()) return; - + for(Entry, AltarRecipe> entry : recipes.entrySet()) { List key = entry.getKey(); AltarRecipe value = entry.getValue(); AltarRecipe oldValue = map.put(key, value); - + if(oldValue != null) { LogHelper.logWarning(String.format("Overwritten %s Recipe for %s", name, getRecipeInfo( new AbstractMap.SimpleEntry, AltarRecipe>(entry.getKey(), value)))); overwritten.put(key, oldValue); } - + successful.put(key, value); List input = ItemStackWrapper.toStackList(value.getInput()); ItemStack output = (value).getOutput(); @@ -95,44 +95,47 @@ public class Altar if(output.getItem() == ForgeModContainer.getInstance().universalBucket && requiredLP == 1000) { output = BloodMagicAPI.getLifeEssenceBucket(); } - + AltarRecipeJEI recipe = new AltarRecipeJEI(input, output, requiredTier, requiredLP, consumptionRate, drainRate); MineTweakerAPI.getIjeiRecipeRegistry().addRecipe(recipe); } } - + @Override public void undo() { if(successful.isEmpty() && overwritten.isEmpty()) return; - + for(Entry, AltarRecipe> entry : successful.entrySet()) { List key = entry.getKey(); AltarRecipe value = map.remove(key); - + if(value == null) { LogHelper.logError(String.format("Error removing %s Recipe: null object", name)); }else { successful.put(key, value); - List list = JEIAddonPlugin.recipeRegistry.getRecipeWrappers(JEIAddonPlugin.recipeRegistry.getRecipeCategories(Arrays.asList("BloodMagic:altar")).get(0)); - final AltarRecipeJEI[] recipe = {null}; - list.forEach(rec -> { - ItemStack input = ((List) ReflectionHelper.getFinalObject(rec, "input")).get(0); - ItemStack output = ReflectionHelper.getFinalObject(rec, "output"); - if(input.isItemEqual(value.getInput().get(0).toStack()) && output.isItemEqual(value.getOutput())) { - recipe[0] = rec; - } - }); - if(recipe[0] != null) - MineTweakerAPI.getIjeiRecipeRegistry().removeRecipe(recipe[0]); + if (JEIAddonPlugin.recipeRegistry != null) { + + List list = JEIAddonPlugin.recipeRegistry.getRecipeWrappers(JEIAddonPlugin.recipeRegistry.getRecipeCategories(Arrays.asList("BloodMagic:altar")).get(0)); + final AltarRecipeJEI[] recipe = {null}; + list.forEach(rec -> { + ItemStack input = ((List) ReflectionHelper.getFinalObject(rec, "input")).get(0); + ItemStack output = ReflectionHelper.getFinalObject(rec, "output"); + if (input.isItemEqual(value.getInput().get(0).toStack()) && output.isItemEqual(value.getOutput())) { + recipe[0] = rec; + } + }); + if (recipe[0] != null) + MineTweakerAPI.getIjeiRecipeRegistry().removeRecipe(recipe[0]); + } } } - + for(Entry, AltarRecipe> entry : overwritten.entrySet()) { List key = entry.getKey(); AltarRecipe value = entry.getValue(); AltarRecipe oldValue = map.put(key, value); - + if(oldValue != null) { LogHelper.logWarning(String.format("Overwritten %s Recipe which should not exist for %s", name, getRecipeInfo(new AbstractMap.SimpleEntry, AltarRecipe>(entry.getKey(), value)))); } @@ -185,39 +188,45 @@ public class Altar { super(Altar.name, map, inputs); } - - + + @Override public void apply() { if(recipes.isEmpty()) return; - + for(List key : recipes.keySet()) { AltarRecipe oldValue = map.remove(key); if(oldValue != null) { successful.put(key, oldValue); - List list = JEIAddonPlugin.recipeRegistry.getRecipeWrappers(JEIAddonPlugin.recipeRegistry.getRecipeCategories(Arrays.asList("BloodMagic:altar")).get(0)); - final AltarRecipeJEI[] recipe = {null}; - list.forEach(rec -> { - ItemStack input = ((List) ReflectionHelper.getFinalObject(rec, "input")).get(0); - ItemStack output = ReflectionHelper.getFinalObject(rec, "output"); - if(input.isItemEqual(oldValue.getInput().get(0).toStack()) && output.isItemEqual(oldValue.getOutput())) { - recipe[0] = rec; - } - }); - if(recipe[0] != null) - MineTweakerAPI.getIjeiRecipeRegistry().removeRecipe(recipe[0]); + if (JEIAddonPlugin.recipeRegistry != null) { + List list = JEIAddonPlugin.recipeRegistry.getRecipeWrappers(JEIAddonPlugin.recipeRegistry.getRecipeCategories(Arrays.asList("BloodMagic:altar")).get(0)); + final AltarRecipeJEI[] recipe = {null}; + + list.forEach(rec -> { + ItemStack input = ((List) ReflectionHelper.getFinalObject(rec, "input")).get(0); + ItemStack output = ReflectionHelper.getFinalObject(rec, "output"); + if (input.isItemEqual(oldValue.getInput().get(0).toStack()) && output.isItemEqual(oldValue.getOutput())) { + recipe[0] = rec; + } + }); + if (recipe[0] != null) + MineTweakerAPI.getIjeiRecipeRegistry().removeRecipe(recipe[0]); + } + + + } else { LogHelper.logError(String.format("Error removing %s Recipe : null object", name)); } } } - + @Override public void undo() { if(successful.isEmpty()) return; - + for(Entry, AltarRecipe> entry : successful.entrySet()) { if(entry != null) { AltarRecipe oldValue = map.put(entry.getKey(), entry.getValue()); @@ -233,14 +242,14 @@ public class Altar if(output.getItem() == ForgeModContainer.getInstance().universalBucket && requiredLP == 1000) { output = BloodMagicAPI.getLifeEssenceBucket(); } - + AltarRecipeJEI recipe = new AltarRecipeJEI(input, output, requiredTier, requiredLP, consumptionRate, drainRate); MineTweakerAPI.getIjeiRecipeRegistry().removeRecipe(recipe); } } } } - + @Override public String getRecipeInfo(Entry, AltarRecipe> recipe) {