summaryrefslogtreecommitdiff
path: root/java/darkknight/jewelrycraft/util
diff options
context:
space:
mode:
authorOnyxDarkKnight <sor1n.iliutza16@gmail.com>2015-01-29 18:28:37 +0000
committerOnyxDarkKnight <sor1n.iliutza16@gmail.com>2015-01-29 18:28:37 +0000
commit73ca377dc01f859dabd7b07738cb7aeb762272b1 (patch)
tree9c0acccbfbf78e813fb838ab566c96a40c5f36bb /java/darkknight/jewelrycraft/util
parent06f62473f0622efe6decc32b70516a7c5d3d3572 (diff)
Made lots of changes
Diffstat (limited to 'java/darkknight/jewelrycraft/util')
-rw-r--r--java/darkknight/jewelrycraft/util/JewelryNBT.java110
-rw-r--r--java/darkknight/jewelrycraft/util/JewelrycraftUtil.java41
2 files changed, 100 insertions, 51 deletions
diff --git a/java/darkknight/jewelrycraft/util/JewelryNBT.java b/java/darkknight/jewelrycraft/util/JewelryNBT.java
index 11ffc83..db2c321 100644
--- a/java/darkknight/jewelrycraft/util/JewelryNBT.java
+++ b/java/darkknight/jewelrycraft/util/JewelryNBT.java
@@ -1,12 +1,14 @@
package darkknight.jewelrycraft.util;
+import java.util.ArrayList;
import java.util.List;
+import java.util.Random;
+import darkknight.jewelrycraft.item.ItemRing;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@@ -43,12 +45,12 @@ public class JewelryNBT
*
* @param item
* The item you want to add the NBT data on
- * @param jewel
- * The jewel you want to add on the item
+ * @param gem
+ * The gem you want to add on the item
*/
- public static void addJewel(ItemStack item, ItemStack jewel)
+ public static void addGem(ItemStack item, ItemStack gem)
{
- if (jewel != null)
+ if (gem != null)
{
NBTTagCompound itemStackData;
if (item.hasTagCompound()) itemStackData = item.getTagCompound();
@@ -57,9 +59,9 @@ public class JewelryNBT
itemStackData = new NBTTagCompound();
item.setTagCompound(itemStackData);
}
- NBTTagCompound jewelNBT = new NBTTagCompound();
- jewel.writeToNBT(jewelNBT);
- itemStackData.setTag("jewel", jewelNBT);
+ NBTTagCompound gemNBT = new NBTTagCompound();
+ gem.writeToNBT(gemNBT);
+ itemStackData.setTag("gem", gemNBT);
}
}
@@ -70,7 +72,7 @@ public class JewelryNBT
* @param modifier
* The modifier you want to add on the item
*/
- public static void addModifier(ItemStack item, ItemStack modifier)
+ public static void addModifiers(ItemStack item, ArrayList<ItemStack> modifier)
{
if (modifier != null)
{
@@ -81,9 +83,13 @@ public class JewelryNBT
itemStackData = new NBTTagCompound();
item.setTagCompound(itemStackData);
}
- NBTTagCompound modifierNBT = new NBTTagCompound();
- modifier.writeToNBT(modifierNBT);
- itemStackData.setTag("modifier", modifierNBT);
+ for (int i = 0; i < modifier.size(); i++)
+ {
+ NBTTagCompound modifierNBT = new NBTTagCompound();
+ modifier.get(i).writeToNBT(modifierNBT);
+ itemStackData.setTag("modifier" + i, modifierNBT);
+ }
+ itemStackData.setInteger("modifierSize", modifier.size());
}
}
@@ -255,7 +261,8 @@ public class JewelryNBT
itemStackData.setTag("ingotColor", colors);
}
- public static void addJewelColor(ItemStack item, int color)
+ // TODO
+ public static void addGemColor(ItemStack item, int color)
{
NBTTagCompound itemStackData;
if (item.hasTagCompound()) itemStackData = item.getTagCompound();
@@ -265,8 +272,8 @@ public class JewelryNBT
item.setTagCompound(itemStackData);
}
NBTTagCompound colors = new NBTTagCompound();
- colors.setInteger("jewelColor", color);
- itemStackData.setTag("jewelColor", colors);
+ colors.setInteger("gemColor", color);
+ itemStackData.setTag("gemColor", colors);
}
@SuppressWarnings("rawtypes")
@@ -329,21 +336,19 @@ public class JewelryNBT
return false;
}
- public static boolean isJewelX(ItemStack stack, ItemStack jewel)
+ public static boolean isGemX(ItemStack stack, ItemStack gem)
{
- if (jewel(stack) != null && jewel(stack).getItem() == jewel.getItem() && jewel(stack).getItemDamage() == jewel.getItemDamage()) return true;
+ if (gem(stack) != null && gem(stack).getItem() == gem.getItem() && gem(stack).getItemDamage() == gem.getItemDamage()) return true;
return false;
}
public static boolean isModifierX(ItemStack stack, ItemStack modifier)
{
- if (modifier(stack) != null && modifier(stack).getItem() == modifier.getItem() && modifier(stack).getItemDamage() == modifier.getItemDamage()) return true;
- return false;
- }
-
- public static boolean isModifierEffectType(ItemStack stack)
- {
- if (modifier(stack) != null && (isModifierX(stack, new ItemStack(Items.blaze_powder)) || isModifierX(stack, new ItemStack(Items.sugar)) || isModifierX(stack, new ItemStack(Items.iron_pickaxe)) || isModifierX(stack, new ItemStack(Items.feather)) || isModifierX(stack, new ItemStack(Items.potionitem, 1, 8270)))) return true;
+ 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;
+ }
return false;
}
@@ -379,26 +384,50 @@ public class JewelryNBT
// TODO Return components based on NBT
- public static ItemStack jewel(ItemStack stack)
+ public static ItemStack gem(ItemStack stack)
+ {
+ if (stack != null && stack != new ItemStack(Item.getItemById(0), 0, 0) && stack.hasTagCompound() && stack.getTagCompound().hasKey("gem"))
+ {
+ NBTTagCompound jewelNBT = (NBTTagCompound) stack.getTagCompound().getTag("gem");
+ ItemStack gem = new ItemStack(Item.getItemById(0), 0, 0);
+ gem.readFromNBT(jewelNBT);
+ return gem;
+ }
+ 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("jewel"))
+ if (stack != null && stack != new ItemStack(Item.getItemById(0), 0, 0) && stack.hasTagCompound() && stack.getTagCompound().hasKey("gemNumber"))
{
- NBTTagCompound jewelNBT = (NBTTagCompound) stack.getTagCompound().getTag("jewel");
- ItemStack jewel = new ItemStack(Item.getItemById(0), 0, 0);
- jewel.readFromNBT(jewelNBT);
- return jewel;
+ 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;
}
- public static ItemStack modifier(ItemStack stack)
+ //TODO Modifier
+ public static ArrayList<ItemStack> modifier(ItemStack stack)
{
- if (stack != null && stack != new ItemStack(Item.getItemById(0), 0, 0) && stack.hasTagCompound() && stack.getTagCompound().hasKey("modifier"))
+ if (stack != null && stack != new ItemStack(Item.getItemById(0), 0, 0) && stack.hasTagCompound())
{
- NBTTagCompound modifierNBT = (NBTTagCompound) stack.getTagCompound().getTag("modifier");
- ItemStack modifier = new ItemStack(Item.getItemById(0), 0, 0);
- modifier.readFromNBT(modifierNBT);
- return modifier;
+ int size = stack.getTagCompound().getInteger("modifierSize");
+ ArrayList<ItemStack> list = new ArrayList<ItemStack>();
+ 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);
+ list.add(modifier);
+ }
+ return list;
}
return null;
}
@@ -582,12 +611,13 @@ public class JewelryNBT
return 16777215;
}
- public static int jewelColor(ItemStack stack)
+ // TODO
+ public static int gemColor(ItemStack stack)
{
- if (stack != null && stack != new ItemStack(Item.getItemById(0), 0, 0) && stack.hasTagCompound() && stack.getTagCompound().hasKey("jewelColor"))
+ if (stack != null && stack != new ItemStack(Item.getItemById(0), 0, 0) && stack.hasTagCompound() && stack.getTagCompound().hasKey("gemColor"))
{
- NBTTagCompound colors = (NBTTagCompound) stack.getTagCompound().getTag("jewelColor");
- int color = colors.getInteger("jewelColor");
+ NBTTagCompound colors = (NBTTagCompound) stack.getTagCompound().getTag("gemColor");
+ int color = colors.getInteger("gemColor");
return color;
}
return 16777215;
diff --git a/java/darkknight/jewelrycraft/util/JewelrycraftUtil.java b/java/darkknight/jewelrycraft/util/JewelrycraftUtil.java
index 7c938e4..9a45bfd 100644
--- a/java/darkknight/jewelrycraft/util/JewelrycraftUtil.java
+++ b/java/darkknight/jewelrycraft/util/JewelrycraftUtil.java
@@ -11,14 +11,16 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import darkknight.jewelrycraft.item.ItemList;
+import darkknight.jewelrycraft.lib.Reference;
public class JewelrycraftUtil
{
public static ArrayList<ItemStack> modifiers = new ArrayList<ItemStack>();
- public static ArrayList<ItemStack> jewel = 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<Item, ItemStack> oreToIngot = new HashMap<Item, ItemStack>();
public static ArrayList<String> jamcraftPlayers = new ArrayList<String>();
public static Random rand = new Random();
@@ -43,18 +45,25 @@ public class JewelrycraftUtil
// Jewels
for (int i = 0; i < 16; i++)
- jewel.add(new ItemStack(ItemList.crystal, 1, i));
- jewel.add(new ItemStack(Blocks.redstone_block));
- jewel.add(new ItemStack(Blocks.lapis_block));
- jewel.add(new ItemStack(Blocks.obsidian));
- jewel.add(new ItemStack(Items.diamond));
- jewel.add(new ItemStack(Items.emerald));
- jewel.add(new ItemStack(Items.ender_pearl));
- jewel.add(new ItemStack(Items.nether_star));
+ gem.add(new ItemStack(ItemList.crystal, 1, i));
+ gem.add(new ItemStack(Blocks.redstone_block));
+ gem.add(new ItemStack(Blocks.lapis_block));
+ gem.add(new ItemStack(Blocks.obsidian));
+ gem.add(new ItemStack(Items.diamond));
+ gem.add(new ItemStack(Items.emerald));
+ gem.add(new ItemStack(Items.ender_pearl));
+ gem.add(new ItemStack(Items.nether_star));
// Jewelry
jewelry.add(new ItemStack(ItemList.ring));
jewelry.add(new ItemStack(ItemList.necklace));
+
+ // 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);
}
public static void jamcrafters()
@@ -79,6 +88,16 @@ public class JewelrycraftUtil
jamcraftPlayers.add("direwolf20");
}
+ public static ArrayList<ItemStack> addRandomModifiers()
+ {
+ ArrayList<ItemStack> list = new ArrayList<ItemStack>();
+ for(int i = 0; i < new Random().nextInt(modifiers.size()); i++)
+ {
+ list.add(modifiers.get(new Random().nextInt(modifiers.size())));
+ }
+ return list;
+ }
+
public static void addMetals()
{
int index = 0;
@@ -119,9 +138,9 @@ public class JewelrycraftUtil
return false;
}
- public static boolean isJewel(ItemStack item)
+ public static boolean isGem(ItemStack item)
{
- Iterator<ItemStack> i = jewel.iterator();
+ Iterator<ItemStack> i = gem.iterator();
while (i.hasNext())
{