From 3f9029098e0e119f82d6cb9a41ddfb66a8e5be3d Mon Sep 17 00:00:00 2001 From: Sollace Date: Sat, 26 Jan 2019 19:26:52 +0200 Subject: [PATCH] Added recipes for al of the current gems --- .../unicopia/enchanting/SpellRecipe.java | 17 +++++++++++++---- .../unicopia/enchanting/recipes/charge.json | 11 +++++++++++ .../unicopia/enchanting/recipes/fire.json | 11 +++++++++++ .../assets/unicopia/enchanting/recipes/ice.json | 11 +++++++++++ .../unicopia/enchanting/recipes/shield.json | 7 +++---- 5 files changed, 49 insertions(+), 8 deletions(-) create mode 100644 src/main/resources/assets/unicopia/enchanting/recipes/charge.json create mode 100644 src/main/resources/assets/unicopia/enchanting/recipes/fire.json create mode 100644 src/main/resources/assets/unicopia/enchanting/recipes/ice.json diff --git a/src/main/java/com/minelittlepony/unicopia/enchanting/SpellRecipe.java b/src/main/java/com/minelittlepony/unicopia/enchanting/SpellRecipe.java index bd796c2c..238ec067 100644 --- a/src/main/java/com/minelittlepony/unicopia/enchanting/SpellRecipe.java +++ b/src/main/java/com/minelittlepony/unicopia/enchanting/SpellRecipe.java @@ -31,13 +31,22 @@ public class SpellRecipe extends Impl implements IRecipe { for (JsonElement i : json.get("ingredients").getAsJsonArray()) { JsonObject o = i.getAsJsonObject(); - Item item = Item.getByNameOrId(o.get("item").getAsString()); + Item item = o.has("item") ? Item.getByNameOrId(o.get("item").getAsString()) : null; + + if (item != null) { int metadata = Math.max(0, o.has("data") ? o.get("data").getAsInt() : 0); int size = Math.max(1, o.has("count") ? o.get("count").getAsInt() : 1); + String spell = o.has("spell") ? o.get("spell").getAsString() : null; - ingredients.add(new RecipeItem(new ItemStack(item, size, metadata), !o.has("data"))); + ItemStack stack = new ItemStack(item, size, metadata); + + if (spell != null) { + stack = SpellRegistry.instance().enchantStack(stack, spell); + } + + ingredients.add(new RecipeItem(stack, !o.has("data"))); } } @@ -131,8 +140,8 @@ public class SpellRecipe extends Impl implements IRecipe { } if (contained.getItem() == other.getItem() - && (ignoreMeta || other.getMetadata() == contained.getMetadata())) { - + && (ignoreMeta || other.getMetadata() == contained.getMetadata()) + && ItemStack.areItemStackTagsEqual(contained, other)) { return other.getCount() >= (materialMult * contained.getCount()); } diff --git a/src/main/resources/assets/unicopia/enchanting/recipes/charge.json b/src/main/resources/assets/unicopia/enchanting/recipes/charge.json new file mode 100644 index 00000000..96adc37b --- /dev/null +++ b/src/main/resources/assets/unicopia/enchanting/recipes/charge.json @@ -0,0 +1,11 @@ +{ + "type": "unicopia:crafting_spell", + "ingredients": [ + { "item": "unicopia:zap_apple" }, + { "item": "unicopia:gem", "spell": "fire" }, + { "item": "minecraft:redstone" } + ], + "result": { + "spell": "charge" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/unicopia/enchanting/recipes/fire.json b/src/main/resources/assets/unicopia/enchanting/recipes/fire.json new file mode 100644 index 00000000..6862f812 --- /dev/null +++ b/src/main/resources/assets/unicopia/enchanting/recipes/fire.json @@ -0,0 +1,11 @@ +{ + "type": "unicopia:crafting_spell", + "ingredients": [ + { "item": "minecraft:fire_charge" }, + { "item": "minecraft:fire_charge" }, + { "item": "minecraft:lava_bucket" } + ], + "result": { + "spell": "fire" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/unicopia/enchanting/recipes/ice.json b/src/main/resources/assets/unicopia/enchanting/recipes/ice.json new file mode 100644 index 00000000..ef8adf92 --- /dev/null +++ b/src/main/resources/assets/unicopia/enchanting/recipes/ice.json @@ -0,0 +1,11 @@ +{ + "type": "unicopia:crafting_spell", + "ingredients": [ + { "item": "minecraft:snowball" }, + { "item": "minecraft:snowball" }, + { "item": "minecraft:water_bucket" } + ], + "result": { + "spell": "ice" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/unicopia/enchanting/recipes/shield.json b/src/main/resources/assets/unicopia/enchanting/recipes/shield.json index b4cd9d46..9663b70c 100644 --- a/src/main/resources/assets/unicopia/enchanting/recipes/shield.json +++ b/src/main/resources/assets/unicopia/enchanting/recipes/shield.json @@ -1,10 +1,9 @@ { "type": "unicopia:crafting_spell", "ingredients": [ - { - "item": "minecraft:apple", - "data": 0 - } + { "item": "minecraft:egg" }, + { "item": "minecraft:coal" }, + { "item": "minecraft:blaze_powder" } ], "result": { "spell": "shield"