From 3f4c717de5ebc9b942d65ae45ac87c43bdf8a31b Mon Sep 17 00:00:00 2001 From: OnyxDarkKnight Date: Tue, 3 Feb 2015 21:09:09 +0000 Subject: Made a few modifications to some classes, added earrings and bracelets. Improved coloring algorithm and balanced the Thieving Glove --- java/darkknight/jewelrycraft/util/JewelryNBT.java | 73 ++++--------------- .../jewelrycraft/util/JewelrycraftUtil.java | 81 ++++++++++++---------- 2 files changed, 61 insertions(+), 93 deletions(-) (limited to 'java/darkknight/jewelrycraft/util') diff --git a/java/darkknight/jewelrycraft/util/JewelryNBT.java b/java/darkknight/jewelrycraft/util/JewelryNBT.java index db2c321..3f38f94 100644 --- a/java/darkknight/jewelrycraft/util/JewelryNBT.java +++ b/java/darkknight/jewelrycraft/util/JewelryNBT.java @@ -21,11 +21,8 @@ public class JewelryNBT { // TODO NBT Tag Adding /** - * - * @param item - * The item you want to add the NBT data on - * @param metal - * The metal you want to add on the item + * @param item The item you want to add the NBT data on + * @param metal The metal you want to add on the item */ public static void addMetal(ItemStack item, ItemStack metal) { @@ -42,11 +39,8 @@ public class JewelryNBT } /** - * - * @param item - * The item you want to add the NBT data on - * @param gem - * The gem you want to add on the item + * @param item The item you want to add the NBT data on + * @param gem The gem you want to add on the item */ public static void addGem(ItemStack item, ItemStack gem) { @@ -66,11 +60,8 @@ public class JewelryNBT } /** - * - * @param item - * The item you want to add the NBT data on - * @param modifier - * The modifier you want to add on the item + * @param item The item you want to add the NBT data on + * @param modifier The modifier you want to add on the item */ public static void addModifiers(ItemStack item, ArrayList modifier) { @@ -93,6 +84,10 @@ public class JewelryNBT } } + /** + * @param item The item you want to add the NBT data on + * @param entity The entity to add on the item + */ public static void addEntity(ItemStack item, EntityLivingBase entity) { NBTTagCompound itemStackData; @@ -221,20 +216,6 @@ public class JewelryNBT itemStackData.setTag("dimName", coords); } - public static void addMode(ItemStack item, String modeN) - { - NBTTagCompound itemStackData; - if (item.hasTagCompound()) itemStackData = item.getTagCompound(); - else - { - itemStackData = new NBTTagCompound(); - item.setTagCompound(itemStackData); - } - NBTTagCompound mode = new NBTTagCompound(); - mode.setString("mode", modeN); - itemStackData.setTag("mode", mode); - } - public static void addFakeEnchantment(ItemStack item) { NBTTagCompound itemStackData; @@ -347,7 +328,8 @@ public class JewelryNBT if (modifier(stack) != null) { ArrayList list = modifier(stack); - for(int i = 0; i < list.size(); i++) if(list.get(i).getItem() == modifier.getItem() && list.get(i).getItemDamage() == modifier.getItemDamage()) return true; + for (int i = 0; i < list.size(); i++) + if (list.get(i).getItem() == modifier.getItem() && list.get(i).getItemDamage() == modifier.getItemDamage()) return true; } return false; } @@ -358,12 +340,6 @@ public class JewelryNBT return false; } - public static boolean isModeX(ItemStack stack, String modeN) - { - if (modeName(stack) != null && modeName(stack).equals(modeN)) return true; - return false; - } - public static boolean isEntityX(ItemStack stack, EntityPlayer player, EntityLivingBase entity) { if (entity != null && entity instanceof EntityLivingBase && entity(stack, player) != null && entity(stack, player).equals(entity)) return true; @@ -382,8 +358,7 @@ public class JewelryNBT return false; } - // TODO Return components based on NBT - + // TODO Return components based on NBT public static ItemStack gem(ItemStack stack) { if (stack != null && stack != new ItemStack(Item.getItemById(0), 0, 0) && stack.hasTagCompound() && stack.getTagCompound().hasKey("gem")) @@ -396,32 +371,14 @@ public class JewelryNBT return null; } - public static ArrayList gems(ItemStack stack) - { - if (stack != null && stack != new ItemStack(Item.getItemById(0), 0, 0) && stack.hasTagCompound() && stack.getTagCompound().hasKey("gemNumber")) - { - int no = stack.getTagCompound().getInteger("gemNumber"); - ArrayList gems = new ArrayList(); - for (int i = 1; i <= no; i++) - { - NBTTagCompound gemNBT = (NBTTagCompound) stack.getTagCompound().getTag("gem" + i); - ItemStack gem = new ItemStack(Item.getItemById(0), 0, 0); - gem.readFromNBT(gemNBT); - gems.add(gem); - } - return gems; - } - return null; - } - - //TODO Modifier public static ArrayList modifier(ItemStack stack) { if (stack != null && stack != new ItemStack(Item.getItemById(0), 0, 0) && stack.hasTagCompound()) { int size = stack.getTagCompound().getInteger("modifierSize"); ArrayList list = new ArrayList(); - for(int i = 0; i < size; i++){ + for (int i = 0; i < size; i++) + { ItemStack modifier = new ItemStack(Item.getItemById(0), 0, 0); NBTTagCompound modifierNBT = (NBTTagCompound) stack.getTagCompound().getTag("modifier" + i); modifier.readFromNBT(modifierNBT); diff --git a/java/darkknight/jewelrycraft/util/JewelrycraftUtil.java b/java/darkknight/jewelrycraft/util/JewelrycraftUtil.java index 9a45bfd..b61267e 100644 --- a/java/darkknight/jewelrycraft/util/JewelrycraftUtil.java +++ b/java/darkknight/jewelrycraft/util/JewelrycraftUtil.java @@ -5,6 +5,8 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Random; +import cpw.mods.fml.common.registry.GameData; +import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; @@ -15,12 +17,15 @@ import darkknight.jewelrycraft.lib.Reference; public class JewelrycraftUtil { - public static ArrayList modifiers = new ArrayList(); + public static ArrayList objects = new ArrayList(); public static ArrayList gem = new ArrayList(); public static ArrayList jewelry = new ArrayList(); public static ArrayList metal = new ArrayList(); public static ArrayList ores = new ArrayList(); - public static HashMap curses = new HashMap(); + public static HashMap curseValues = new HashMap(); + public static HashMap curseNames = new HashMap(); + public static HashMap availableCurseNames = new HashMap(); + public static HashMap availableCurseValues = new HashMap(); public static HashMap oreToIngot = new HashMap(); public static ArrayList jamcraftPlayers = new ArrayList(); public static Random rand = new Random(); @@ -28,20 +33,12 @@ public class JewelrycraftUtil public static void addStuff() { // Modifiers - modifiers.add(new ItemStack(Blocks.chest)); - modifiers.add(new ItemStack(Blocks.torch)); - modifiers.add(new ItemStack(Items.book)); - modifiers.add(new ItemStack(Items.dye, 1, 15)); - modifiers.add(new ItemStack(Items.bone)); - modifiers.add(new ItemStack(Items.sugar)); - modifiers.add(new ItemStack(Items.feather)); - modifiers.add(new ItemStack(Items.bed)); - modifiers.add(new ItemStack(Items.iron_pickaxe)); - modifiers.add(new ItemStack(Items.redstone)); - modifiers.add(new ItemStack(Items.diamond_pickaxe)); - modifiers.add(new ItemStack(Items.blaze_powder)); - modifiers.add(new ItemStack(Items.ender_eye)); - modifiers.add(new ItemStack(Items.potionitem, 1, 8270)); + for(Object item: GameData.getItemRegistry()) + { + ArrayList items = new ArrayList(); + ((Item)item).getSubItems((Item)item, null, items); + objects.addAll(items); + } // Jewels for (int i = 0; i < 16; i++) @@ -57,13 +54,15 @@ public class JewelrycraftUtil // Jewelry jewelry.add(new ItemStack(ItemList.ring)); jewelry.add(new ItemStack(ItemList.necklace)); + jewelry.add(new ItemStack(ItemList.bracelet)); + jewelry.add(new ItemStack(ItemList.earrings)); // Curses - curses.put(Reference.MODNAME + ":" + "Blind", 0); - curses.put(Reference.MODNAME + ":" + "Weak", 1); - curses.put(Reference.MODNAME + ":" + "Anemic", 2); - curses.put(Reference.MODNAME + ":" + "Scared", 3); - curses.put(Reference.MODNAME + ":" + "Brave", 4); + addCurse(Reference.MODNAME + ":" + "Blind", 0); + addCurse(Reference.MODNAME + ":" + "Weak", 1); + addCurse(Reference.MODNAME + ":" + "Anemic", 2); + addCurse(Reference.MODNAME + ":" + "Scared", 3); + addCurse(Reference.MODNAME + ":" + "Brave", 4); } public static void jamcrafters() @@ -88,14 +87,24 @@ public class JewelrycraftUtil jamcraftPlayers.add("direwolf20"); } - public static ArrayList addRandomModifiers() + public static void addCurse(String name, int val) + { + curseValues.put(name, val); + curseNames.put(val, name); + availableCurseValues.put(name, val); + availableCurseNames.put(val, name); + } + + public static ArrayList addRandomModifiers(int randValue) { ArrayList list = new ArrayList(); - for(int i = 0; i < new Random().nextInt(modifiers.size()); i++) + for (int i = 0; i < 2 + randValue; i++) { - list.add(modifiers.get(new Random().nextInt(modifiers.size()))); + ItemStack item = objects.get(new Random().nextInt(objects.size())); + item.stackSize = 1 + new Random().nextInt(2); + list.add(item); } - return list; + return list; } public static void addMetals() @@ -109,16 +118,18 @@ public class JewelrycraftUtil { ItemStack nextStack = i.next(); - if ((nextStack.getItem().getUnlocalizedName().toLowerCase().contains("ingot") || nextStack.getItem().getUnlocalizedName().toLowerCase().contains("alloy")) && !nextStack.getItem().getUnlocalizedName().toLowerCase().contains("powder") && !nextStack.getItem().getUnlocalizedName().toLowerCase().contains("dust") && !nextStack.getItem().getUnlocalizedName().toLowerCase().contains("block") && !metal.contains(nextStack)){ + if ((nextStack.getItem().getUnlocalizedName().toLowerCase().contains("ingot") || nextStack.getItem().getUnlocalizedName().toLowerCase().contains("alloy")) && !nextStack.getItem().getUnlocalizedName().toLowerCase().contains("powder") && !nextStack.getItem().getUnlocalizedName().toLowerCase().contains("dust") && !nextStack.getItem().getUnlocalizedName().toLowerCase().contains("block") && !metal.contains(nextStack)) + { metal.add(nextStack); - if(OreDictionary.getOres(OreDictionary.getOreNames()[index].replace("ingot", "ore")) != null){ - ores.addAll(OreDictionary.getOres(OreDictionary.getOreNames()[index].replace("ingot", "ore"))); - Iterator ores = OreDictionary.getOres(OreDictionary.getOreNames()[index].replace("ingot", "ore")).iterator(); - while(ores.hasNext()) - { - ItemStack ore = ores.next(); - oreToIngot.put(ore.getItem(), nextStack); - } + if (OreDictionary.getOres(OreDictionary.getOreNames()[index].replace("ingot", "ore")) != null) + { + ores.addAll(OreDictionary.getOres(OreDictionary.getOreNames()[index].replace("ingot", "ore"))); + Iterator ores = OreDictionary.getOres(OreDictionary.getOreNames()[index].replace("ingot", "ore")).iterator(); + while (ores.hasNext()) + { + ItemStack ore = ores.next(); + oreToIngot.put(ore.getItem(), nextStack); + } } } } @@ -128,7 +139,7 @@ public class JewelrycraftUtil public static boolean isModifier(ItemStack item) { - Iterator i = modifiers.iterator(); + Iterator i = objects.iterator(); while (i.hasNext()) { -- cgit v1.2.3