Permalink
Browse files

Added cook time & experience to furnace recipes.

  • Loading branch information...
me4502 committed Sep 30, 2018
1 parent 95bd3c5 commit 51f0e7af3e73fe070ddaea8cbfdd62af08e2881b
@@ -87,7 +87,13 @@ public boolean addRecipe(RecipeManager.Recipe r) {
for (Entry<CraftingItemStack, Character> is : r.getShapedIngredients().entrySet())
((ShapedRecipe) sh).setIngredient(is.getValue(), is.getKey().getItemStack().getData());
} else if (r.getType() == RecipeManager.RecipeType.FURNACE) {
sh = new FurnaceRecipe(r.getResult().getItemStack(), r.getIngredients().toArray(new CraftingItemStack[r.getIngredients().size()])[0].getItemStack().getType());
sh = new FurnaceRecipe(
new NamespacedKey(CraftBookPlugin.inst(), r.getId()),
r.getResult().getItemStack(),
r.getIngredients().toArray(new CraftingItemStack[r.getIngredients().size()])[0].getItemStack().getType(),
r.getExperience(),
r.getCookTime()
);
for (CraftingItemStack is : r.getIngredients())
((FurnaceRecipe) sh).setInput(is.getItemStack().getData());
} else
@@ -118,6 +118,9 @@ public boolean removeRecipe(String name) {
private CraftingItemStack result;
private List<String> shape;
private float experience;
private int cookTime;
@Override
public boolean equals(Object o) {
if(o instanceof Recipe) {
@@ -230,6 +233,10 @@ private void load() throws InvalidCraftingException {
type = RecipeType.getTypeFromName(config.getString("crafting-recipes." + id + ".type"));
if (type != RecipeType.SHAPED) {
ingredients = getItems("crafting-recipes." + id + ".ingredients");
if (type == RecipeType.FURNACE) {
cookTime = config.getInt("crafting-recipes." + id + ".cook-time", 200);
experience = (float) config.getDouble("crafting-recipes." + id + ".experience", 0.0);
}
} else {
items = getShapeIngredients("crafting-recipes." + id + ".ingredients");
shape = config.getStringList("crafting-recipes." + id + ".shape", Collections.singletonList(""));
@@ -278,6 +285,10 @@ public void save() {
resz.put(stack.toString() + ' ', stack.getItemStack().getAmount());
}
config.setProperty("crafting-recipes." + id + ".ingredients", resz);
if (type == RecipeType.FURNACE) {
config.setProperty("crafting-recipes." + id + ".cook-time", cookTime);
config.setProperty("crafting-recipes." + id + ".experience", experience);
}
} else {
LinkedHashMap<String, Character> resz = new LinkedHashMap<>();
for(Map.Entry<CraftingItemStack, Character> craftingItemStackCharacterEntry : items.entrySet())
@@ -378,6 +389,23 @@ public CraftingItemStack getResult() {
return result;
}
// Furnace
public float getExperience() {
return this.experience;
}
public void setExperience(float experience) {
this.experience = experience;
}
public int getCookTime() {
return this.cookTime;
}
public void setCookTime(int cookTime) {
this.cookTime = cookTime;
}
//Advanced data
private HashMap<String, Object> advancedData = new HashMap<>();

0 comments on commit 51f0e7a

Please sign in to comment.