summaryrefslogtreecommitdiff
path: root/java/darkknight/jewelrycraft/util
diff options
context:
space:
mode:
authorOnyxDarkKnight <sor1n.iliutza16@gmail.com>2015-02-03 21:09:09 +0000
committerOnyxDarkKnight <sor1n.iliutza16@gmail.com>2015-02-03 21:09:09 +0000
commit3f4c717de5ebc9b942d65ae45ac87c43bdf8a31b (patch)
tree15c68c8b61dbd0b7f44937a5c790c4b844e50f58 /java/darkknight/jewelrycraft/util
parent73ca377dc01f859dabd7b07738cb7aeb762272b1 (diff)
Made a few modifications to some classes, added earrings and bracelets. Improved coloring algorithm and balanced the Thieving Glove
Diffstat (limited to 'java/darkknight/jewelrycraft/util')
-rw-r--r--java/darkknight/jewelrycraft/util/JewelryNBT.java73
-rw-r--r--java/darkknight/jewelrycraft/util/JewelrycraftUtil.java81
2 files changed, 61 insertions, 93 deletions
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<ItemStack> 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<ItemStack> 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<ItemStack> 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<ItemStack> gems = new ArrayList<ItemStack>();
- 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<ItemStack> modifier(ItemStack stack)
{
if (stack != null && stack != new ItemStack(Item.getItemById(0), 0, 0) && stack.hasTagCompound())
{
int size = stack.getTagCompound().getInteger("modifierSize");
ArrayList<ItemStack> list = new ArrayList<ItemStack>();
- 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<ItemStack> modifiers = new ArrayList<ItemStack>();
+ public static ArrayList<ItemStack> objects = new ArrayList<ItemStack>();
public static ArrayList<ItemStack> gem = new ArrayList<ItemStack>();
public static ArrayList<ItemStack> jewelry = new ArrayList<ItemStack>();
public static ArrayList<ItemStack> metal = new ArrayList<ItemStack>();
public static ArrayList<ItemStack> ores = new ArrayList<ItemStack>();
- public static HashMap<String, Integer> curses = new HashMap<String, Integer>();
+ public static HashMap<String, Integer> curseValues = new HashMap<String, Integer>();
+ public static HashMap<Integer, String> curseNames = new HashMap<Integer, String>();
+ public static HashMap<Integer, String> availableCurseNames = new HashMap<Integer, String>();
+ public static HashMap<String, Integer> availableCurseValues = new HashMap<String, Integer>();
public static HashMap<Item, ItemStack> oreToIngot = new HashMap<Item, ItemStack>();
public static ArrayList<String> jamcraftPlayers = new ArrayList<String>();
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<ItemStack> items = new ArrayList<ItemStack>();
+ ((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<ItemStack> 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<ItemStack> addRandomModifiers(int randValue)
{
ArrayList<ItemStack> list = new ArrayList<ItemStack>();
- 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<ItemStack> 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<ItemStack> 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<ItemStack> i = modifiers.iterator();
+ Iterator<ItemStack> i = objects.iterator();
while (i.hasNext())
{