Make loading of ingredients more reliable

This commit is contained in:
Sn0wStorm 2020-10-31 15:59:00 +01:00
parent 0e02355cca
commit af37f248ce
2 changed files with 11 additions and 8 deletions

View File

@ -471,13 +471,15 @@ public class BIngredients {
List<Ingredient> ing = new ArrayList<>(size);
for (; size > 0; size--) {
ItemLoader itemLoader = new ItemLoader(dataVersion, in, in.readUTF());
if (Ingredient.LOADERS.containsKey(itemLoader.getSaveID())) {
Ingredient loaded = Ingredient.LOADERS.get(itemLoader.getSaveID()).apply(itemLoader);
int amount = in.readShort();
if (loaded != null) {
loaded.setAmount(amount);
ing.add(loaded);
}
if (!Ingredient.LOADERS.containsKey(itemLoader.getSaveID())) {
P.p.errorLog("Ingredient Loader not found: " + itemLoader.getSaveID());
break;
}
Ingredient loaded = Ingredient.LOADERS.get(itemLoader.getSaveID()).apply(itemLoader);
int amount = in.readShort();
if (loaded != null) {
loaded.setAmount(amount);
ing.add(loaded);
}
}
return new BIngredients(ing, cookedTime);

View File

@ -132,8 +132,9 @@ public class SimpleItem extends RecipeItem implements Ingredient {
try {
DataInputStream in = loader.getInputStream();
Material mat = Material.getMaterial(in.readUTF());
short dur = in.readShort();
if (mat != null) {
SimpleItem item = new SimpleItem(mat, in.readShort());
SimpleItem item = new SimpleItem(mat, dur);
return item;
}
} catch (IOException e) {