diff --git a/src/main/java/vazkii/botania/common/core/BotaniaCreativeTab.java b/src/main/java/vazkii/botania/common/core/BotaniaCreativeTab.java index 74329c2ec..dfdb3f45e 100644 --- a/src/main/java/vazkii/botania/common/core/BotaniaCreativeTab.java +++ b/src/main/java/vazkii/botania/common/core/BotaniaCreativeTab.java @@ -98,6 +98,7 @@ public final class BotaniaCreativeTab extends CreativeTabs { addBlock(ModBlocks.forestEye); addBlock(ModBlocks.enderEye); addItem(ModItems.enderHand); + addItem(ModItems.spellCloth); addItem(ModItems.craftingHalo); addItem(ModItems.spawnerMover); addBlock(ModBlocks.spawnerClaw); diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/SpellClothRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/SpellClothRecipe.java new file mode 100644 index 000000000..5849d8115 --- /dev/null +++ b/src/main/java/vazkii/botania/common/crafting/recipe/SpellClothRecipe.java @@ -0,0 +1,75 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Jan 25, 2015, 6:16:13 PM (GMT)] + */ +package vazkii.botania.common.crafting.recipe; + +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; +import vazkii.botania.common.item.ModItems; + +public class SpellClothRecipe implements IRecipe { + + @Override + public boolean matches(InventoryCrafting var1, World var2) { + boolean foundCloth = false; + boolean foundEnchanted = false; + + for(int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if(stack != null) { + if(stack.isItemEnchanted() && !foundEnchanted) + foundEnchanted = true; + + else if(stack.getItem() == ModItems.spellCloth && !foundCloth) + foundCloth = true; + + else return false; // Found an invalid item, breaking the recipe + } + } + + return foundCloth && foundEnchanted; + } + + @Override + public ItemStack getCraftingResult(InventoryCrafting var1) { + ItemStack stackToDisenchant = null; + for(int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if(stack != null && stack.isItemEnchanted()) { + stackToDisenchant = stack.copy(); + break; + } + } + + if(stackToDisenchant == null) + return null; + + NBTTagCompound cmp = (NBTTagCompound) stackToDisenchant.getTagCompound().copy(); + cmp.removeTag("ench"); // Remove enchantments + stackToDisenchant.setTagCompound(cmp); + + return stackToDisenchant; + } + + @Override + public int getRecipeSize() { + return 10; + } + + @Override + public ItemStack getRecipeOutput() { + return null; + } + +} diff --git a/src/main/java/vazkii/botania/common/item/ItemSpellCloth.java b/src/main/java/vazkii/botania/common/item/ItemSpellCloth.java new file mode 100644 index 000000000..33843917f --- /dev/null +++ b/src/main/java/vazkii/botania/common/item/ItemSpellCloth.java @@ -0,0 +1,59 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Jan 25, 2015, 6:14:13 PM (GMT)] + */ +package vazkii.botania.common.item; + +import java.awt.Color; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.RecipeSorter; +import net.minecraftforge.oredict.RecipeSorter.Category; +import vazkii.botania.common.crafting.recipe.SpellClothRecipe; +import vazkii.botania.common.lib.LibItemNames; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class ItemSpellCloth extends ItemMod { + + public ItemSpellCloth() { + setMaxDamage(35); + setMaxStackSize(1); + setNoRepair(); + setUnlocalizedName(LibItemNames.SPELL_CLOTH); + + GameRegistry.addRecipe(new SpellClothRecipe()); + RecipeSorter.register("botania:spellCloth", SpellClothRecipe.class, Category.SHAPELESS, ""); + } + + @Override + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { + return Color.HSBtoRGB(0.75F, ((float) par1ItemStack.getMaxDamage() - (float) par1ItemStack.getItemDamage()) / par1ItemStack.getMaxDamage() * 0.5F, 1F); + } + + @Override + public boolean hasContainerItem() { + return true; + } + + @Override + public ItemStack getContainerItem(ItemStack itemStack) { + itemStack.setItemDamage(itemStack.getItemDamage() + 1); + return itemStack; + } + + @Override + public boolean doesContainerItemLeaveCraftingGrid(ItemStack par1ItemStack) { + return false; + } + +} diff --git a/src/main/java/vazkii/botania/common/item/ModItems.java b/src/main/java/vazkii/botania/common/item/ModItems.java index 53002eabc..4f35d1b04 100644 --- a/src/main/java/vazkii/botania/common/item/ModItems.java +++ b/src/main/java/vazkii/botania/common/item/ModItems.java @@ -197,6 +197,7 @@ public final class ModItems { public static Item cobbleRod; public static Item smeltRod; public static Item worldSeed; + public static Item spellCloth; public static void init() { lexicon = new ItemLexicon(); @@ -301,6 +302,7 @@ public final class ModItems { cobbleRod = new ItemCobbleRod(); smeltRod = new ItemSmeltRod(); worldSeed = new ItemWorldSeed(); + spellCloth = new ItemSpellCloth(); OreDictionary.registerOre(LibOreDict.LEXICON, lexicon); for(int i = 0; i < 16; i++) { diff --git a/src/main/java/vazkii/botania/common/lib/LibItemNames.java b/src/main/java/vazkii/botania/common/lib/LibItemNames.java index 1d5b57316..94a6c2b50 100644 --- a/src/main/java/vazkii/botania/common/lib/LibItemNames.java +++ b/src/main/java/vazkii/botania/common/lib/LibItemNames.java @@ -116,6 +116,7 @@ public final class LibItemNames { public static final String COBBLE_ROD = "cobbleRod"; public static final String SMELT_ROD = "smeltRod"; public static final String WORLD_SEED = "worldSeed"; + public static final String SPELL_CLOTH = "spellCloth"; public static final String[] LENS_NAMES = new String[] { "lensNormal", diff --git a/src/main/resources/assets/botania/lang/en_US.lang b/src/main/resources/assets/botania/lang/en_US.lang index db0f8a1cd..6a361cbe4 100644 --- a/src/main/resources/assets/botania/lang/en_US.lang +++ b/src/main/resources/assets/botania/lang/en_US.lang @@ -806,6 +806,7 @@ item.botania:clip.name=Lens Clip item.botania:cobbleRod.name=Rod of the Depths item.botania:smeltRod.name=Rod of the Molten Core item.botania:worldSeed.name=World Seed +item.botania:spellCloth.name=Spellbinding Cloth # BREW NAMES botania.brew.fallback=Fallback diff --git a/src/main/resources/assets/botania/textures/items/enchantCloth.png b/src/main/resources/assets/botania/textures/items/enchantCloth.png deleted file mode 100644 index 6f68337bc..000000000 Binary files a/src/main/resources/assets/botania/textures/items/enchantCloth.png and /dev/null differ diff --git a/src/main/resources/assets/botania/textures/items/spellCloth.png b/src/main/resources/assets/botania/textures/items/spellCloth.png new file mode 100644 index 000000000..a6041282a Binary files /dev/null and b/src/main/resources/assets/botania/textures/items/spellCloth.png differ