1.10.2: Fixed Nullpointers with bloodmagic and JEI on multiplayer (#492)

* Fixed Nullpointers with JEI on multiplayer

* Version bump
This commit is contained in:
BloodWorkXGaming 2017-06-27 20:41:39 +02:00 committed by Jared
parent 8b49478813
commit 65ef2d3d72
3 changed files with 96 additions and 83 deletions

View file

@ -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

View file

@ -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<AlchemyTableRecipeJEI> wrappers = JEIAddonPlugin.recipeRegistry.getRecipeWrappers(JEIAddonPlugin.recipeRegistry.getRecipeCategories(Arrays.asList("BloodMagic:salchemyTable")).get(0));
final AlchemyTableRecipeJEI[] recipeToRemove = {null};
wrappers.forEach(wrap -> {
ArrayList<Object> 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<AlchemyTableRecipeJEI> wrappers = JEIAddonPlugin.recipeRegistry.getRecipeWrappers(JEIAddonPlugin.recipeRegistry.getRecipeCategories(Arrays.asList("BloodMagic:salchemyTable")).get(0));
final AlchemyTableRecipeJEI[] recipeToRemove = {null};
wrappers.forEach(wrap -> {
ArrayList<Object> 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<AlchemyTableRecipeJEI> wrappers = JEIAddonPlugin.recipeRegistry.getRecipeWrappers(JEIAddonPlugin.recipeRegistry.getRecipeCategories(Arrays.asList("BloodMagic:salchemyTable")).get(0));
final AlchemyTableRecipeJEI[] recipeToRemove = {null};
wrappers.forEach(wrap -> {
ArrayList<Object> 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<AlchemyTableRecipeJEI> wrappers = JEIAddonPlugin.recipeRegistry.getRecipeWrappers(JEIAddonPlugin.recipeRegistry.getRecipeCategories(Arrays.asList("BloodMagic:salchemyTable")).get(0));
final AlchemyTableRecipeJEI[] recipeToRemove = {null};
wrappers.forEach(wrap -> {
ArrayList<Object> 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)));
}

View file

@ -114,17 +114,20 @@ public class Altar
LogHelper.logError(String.format("Error removing %s Recipe: null object", name));
}else {
successful.put(key, value);
List<AltarRecipeJEI> list = JEIAddonPlugin.recipeRegistry.getRecipeWrappers(JEIAddonPlugin.recipeRegistry.getRecipeCategories(Arrays.asList("BloodMagic:altar")).get(0));
final AltarRecipeJEI[] recipe = {null};
list.forEach(rec -> {
ItemStack input = ((List<ItemStack>) 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<AltarRecipeJEI> list = JEIAddonPlugin.recipeRegistry.getRecipeWrappers(JEIAddonPlugin.recipeRegistry.getRecipeCategories(Arrays.asList("BloodMagic:altar")).get(0));
final AltarRecipeJEI[] recipe = {null};
list.forEach(rec -> {
ItemStack input = ((List<ItemStack>) 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]);
}
}
}
@ -196,17 +199,23 @@ public class Altar
AltarRecipe oldValue = map.remove(key);
if(oldValue != null) {
successful.put(key, oldValue);
List<AltarRecipeJEI> list = JEIAddonPlugin.recipeRegistry.getRecipeWrappers(JEIAddonPlugin.recipeRegistry.getRecipeCategories(Arrays.asList("BloodMagic:altar")).get(0));
final AltarRecipeJEI[] recipe = {null};
list.forEach(rec -> {
ItemStack input = ((List<ItemStack>) 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<AltarRecipeJEI> list = JEIAddonPlugin.recipeRegistry.getRecipeWrappers(JEIAddonPlugin.recipeRegistry.getRecipeCategories(Arrays.asList("BloodMagic:altar")).get(0));
final AltarRecipeJEI[] recipe = {null};
list.forEach(rec -> {
ItemStack input = ((List<ItemStack>) 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));
}