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