diff --git a/src/main/java/org/cyclops/evilcraft/tileentity/tickaction/purifier/DisenchantPurifyAction.java b/src/main/java/org/cyclops/evilcraft/tileentity/tickaction/purifier/DisenchantPurifyAction.java index 1f14fd89ac..2d6b4eb204 100644 --- a/src/main/java/org/cyclops/evilcraft/tileentity/tickaction/purifier/DisenchantPurifyAction.java +++ b/src/main/java/org/cyclops/evilcraft/tileentity/tickaction/purifier/DisenchantPurifyAction.java @@ -63,7 +63,7 @@ public boolean work(TilePurifier tile) { Enchantment enchantment = getRandomEnchantment(world, enchantments); setResultingEnchantmentBook(tile, enchantments, enchantment); removePriorWorkPenalty(enchantments, purifyItem); - setRemainingEnchantmentsOnPurifiedItem(enchantments, enchantment, purifyItem); + purifyItem = setRemainingEnchantmentsOnPurifiedItem(enchantments, enchantment, purifyItem); tile.setPurifyItem(purifyItem); } tile.setBuckets(0, tile.getBucketsRest()); @@ -93,12 +93,19 @@ private void removePriorWorkPenalty(Map enchantments, Item purifyItem.setRepairCost(remainingPenalty); } - private void setRemainingEnchantmentsOnPurifiedItem(Map enchantments, Enchantment enchantment, ItemStack purifyItem) { + private ItemStack setRemainingEnchantmentsOnPurifiedItem(Map enchantments, Enchantment enchantment, ItemStack purifyItem) { Map remainingEnchantments = Maps.newHashMap(enchantments); remainingEnchantments.remove(enchantment); + + // Hardcoded conversion to a regular book when enchantment list of enchanted book is empty. + if (remainingEnchantments.isEmpty() && purifyItem.getItem() == Items.ENCHANTED_BOOK) { + purifyItem = new ItemStack(Items.BOOK); + } + if (purifyItem.hasTagCompound() && purifyItem.getTagCompound().hasKey("StoredEnchantments")) { purifyItem.getTagCompound().removeTag("StoredEnchantments"); } EnchantmentHelper.setEnchantments(remainingEnchantments, purifyItem); + return purifyItem; } }