From f242b3b9e2d62cc2263e9e9288c9feb9613e8132 Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Thu, 22 Aug 2019 20:51:35 -0400 Subject: Update --- .../jewelrycraft/CreativeTabLiquids.java | 6 +- .../darkknight/jewelrycraft/JewelrycraftMod.java | 8 +- .../jewelrycraft/api/ModifierEffects.java | 6 +- .../jewelrycraft/config/ConfigHandler.java | 15 +- .../darkknight/jewelrycraft/curses/CurseList.java | 5 +- .../jewelrycraft/item/ItemBaseJewelry.java | 85 +++++--- .../jewelrycraft/recipes/CraftingRecipes.java | 5 + .../darkknight/jewelrycraft/util/JewelryNBT.java | 216 ++++++++++++++------- .../jewelrycraft/util/JewelrycraftUtil.java | 29 +-- .../jewelrycraft/worldGen/village/JCTrades.java | 1 + 10 files changed, 257 insertions(+), 119 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/darkknight/jewelrycraft/CreativeTabLiquids.java b/src/main/java/darkknight/jewelrycraft/CreativeTabLiquids.java index d3f0739..5d0cec9 100755 --- a/src/main/java/darkknight/jewelrycraft/CreativeTabLiquids.java +++ b/src/main/java/darkknight/jewelrycraft/CreativeTabLiquids.java @@ -6,6 +6,7 @@ import darkknight.jewelrycraft.item.ItemList; import darkknight.jewelrycraft.util.JewelrycraftUtil; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; /** * The Class CreativeTabLiquids. @@ -40,7 +41,8 @@ public class CreativeTabLiquids extends CreativeTabs { */ @Override public void displayAllReleventItems(List list) { - for (int i = 0; i < JewelrycraftUtil.objects.size(); i++) - list.add(ItemList.bucket.getModifiedItemStack(JewelrycraftUtil.objects.get(i))); + for (ItemStack is : JewelrycraftUtil.objects) { + list.add(ItemList.bucket.getModifiedItemStack(is)); + } } } diff --git a/src/main/java/darkknight/jewelrycraft/JewelrycraftMod.java b/src/main/java/darkknight/jewelrycraft/JewelrycraftMod.java index 802724f..bd652fd 100755 --- a/src/main/java/darkknight/jewelrycraft/JewelrycraftMod.java +++ b/src/main/java/darkknight/jewelrycraft/JewelrycraftMod.java @@ -150,6 +150,12 @@ public class JewelrycraftMod { @SubscribeEvent public void oredictRegistered(OreRegisterEvent orev) { + if (orev.Name.startsWith("gem")) { + if (!JewelrycraftUtil.gem.contains(orev.Ore)) { + JewelrycraftUtil.gem.add(orev.Ore); + } + } + if (orev.Name.startsWith("ingot") || orev.Name.startsWith("alloy")) { if (!JewelrycraftUtil.metal.contains(orev.Ore)) { JewelrycraftUtil.metal.add(orev.Ore); @@ -158,7 +164,7 @@ public class JewelrycraftMod { if (orev.Name.startsWith("ore")) { if (!JewelrycraftUtil.ores.contains(orev.Ore)) { - JewelrycraftUtil.metal.add(orev.Ore); + JewelrycraftUtil.ores.add(orev.Ore); } ItemStack ingot = FurnaceRecipes.smelting().getSmeltingResult(orev.Ore); diff --git a/src/main/java/darkknight/jewelrycraft/api/ModifierEffects.java b/src/main/java/darkknight/jewelrycraft/api/ModifierEffects.java index 7b89b8c..b3c832c 100755 --- a/src/main/java/darkknight/jewelrycraft/api/ModifierEffects.java +++ b/src/main/java/darkknight/jewelrycraft/api/ModifierEffects.java @@ -13,6 +13,7 @@ import net.minecraftforge.event.entity.player.PlayerEvent; public class ModifierEffects { protected ItemStack modifier; protected Random rand = new Random(); + protected static ArrayList effects = new ArrayList<>(); /** @@ -21,7 +22,10 @@ public class ModifierEffects { */ public ModifierEffects(ItemStack modifier) { this.modifier = modifier; - effects.add(this); + + if (modifier != null) { + effects.add(this); + } } /** diff --git a/src/main/java/darkknight/jewelrycraft/config/ConfigHandler.java b/src/main/java/darkknight/jewelrycraft/config/ConfigHandler.java index 16cee81..5d7cfcf 100755 --- a/src/main/java/darkknight/jewelrycraft/config/ConfigHandler.java +++ b/src/main/java/darkknight/jewelrycraft/config/ConfigHandler.java @@ -13,24 +13,32 @@ public class ConfigHandler { public static int INGOT_COOLING_TIME; public static int INGOT_MELTING_TIME; + public static int GEM_PLACEMENT_TIME; + public static int RITUAL_TIME; + public static int HEART_DESPAWN_TIME; public static boolean GENERATE_VILLAGE_NETHERSTAR; public static boolean CAN_FURNACE_GENERATE_INGOTS; + public static int MAX_VILLAGE_JEWELERS; public static int JEWELER_WEIGHT; + public static int INGOT_CHEST_MIN; public static int INGOT_CHEST_MAX; public static int INGOT_CHEST_MAX_STACK; + public static int GEM_CHEST_MIN; public static int GEM_CHEST_MAX; + public static int FURNACE_MIN_INGOT_STACK; public static int FURNACE_MAX_INGOT_STACK; public static int MAX_BLACK_HEARTS_PICKUP; public static int MAX_BLUE_HEARTS_PICKUP; + public static boolean CAN_BLUE_HEARTS_SPAWN; public static boolean CAN_BLACK_HEARTS_SPAWN; public static boolean CAN_HOLY_HEARTS_SPAWN; @@ -38,10 +46,13 @@ public class ConfigHandler { public static boolean CRYSTAL_GLOW; public static boolean CRYSTAL_PARTICLES; + public static boolean HEARTS_DESPAWN; + public static boolean JEWELRY_INFO; public static boolean CURSES_ENABLED = true; + public static boolean CURSE_ROTTEN_HEART = true; public static boolean CURSE_FLAMING_SOUL = true; public static boolean CURSE_GREED = true; @@ -55,13 +66,15 @@ public class ConfigHandler { public static boolean CURSE_DEATHS_TOUCH = true; public static boolean CURSE_DOUBLE_DOWN = true; public static boolean CURSE_INCREDIBLE_DEVOTION = true; - public static float DEVOTION_FACTOR = 10.0f; public static boolean CURSE_MONEY_EQUALS_POWER = true; public static boolean CURSE_SCION_OF_HELL = true; + public static float DEVOTION_FACTOR = 10.0f; + public static boolean ENABLE_WORLD_GEN = true; public static boolean ORE_GEN = true; public static boolean CRYSTAL_GEN = true; + public static boolean STRUCTURES[] = { true, true, true, true, true, true }; public static int STRUCTURES_SPAWN_CHANCE[] = { 6, 5, 7, 10, 6, 10 }; diff --git a/src/main/java/darkknight/jewelrycraft/curses/CurseList.java b/src/main/java/darkknight/jewelrycraft/curses/CurseList.java index 249528a..f123863 100755 --- a/src/main/java/darkknight/jewelrycraft/curses/CurseList.java +++ b/src/main/java/darkknight/jewelrycraft/curses/CurseList.java @@ -23,9 +23,10 @@ public class CurseList { public static Curse scionOfHell; public static Curse moneyEqualsPower; public static Curse doubleDown; - public static Curse sacredOath; // Not yet implemented + public static Curse sacredOath; + // None at the moment :) public static void preInit(FMLPreInitializationEvent e) { @@ -60,6 +61,6 @@ public class CurseList { incredibleDevotion = new CurseIncredibleDevotion(Variables.MODNAME + ":" + "Incredible Devotion", 20, CURSE_TEXPACK); - sacredOath = new CurseSacredOath(Variables.MODNAME + ":" + "Sacred Oath", 21, CURSE_TEXPACK); + //sacredOath = new CurseSacredOath(Variables.MODNAME + ":" + "Sacred Oath", 21, CURSE_TEXPACK); } } diff --git a/src/main/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java b/src/main/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java index da0315f..13e8546 100755 --- a/src/main/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java +++ b/src/main/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java @@ -6,6 +6,7 @@ import java.util.List; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import darkknight.jewelrycraft.JewelrycraftMod; +import darkknight.jewelrycraft.api.IJewelryItem; import darkknight.jewelrycraft.api.ModifierEffects; import darkknight.jewelrycraft.config.ConfigHandler; import darkknight.jewelrycraft.util.JewelryNBT; @@ -20,10 +21,13 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; import net.minecraftforge.event.entity.player.PlayerEvent; +@SuppressWarnings({ "rawtypes", "unchecked" }) public abstract class ItemBaseJewelry extends Item { public ItemBaseJewelry() { super(); + setMaxStackSize(1); + setCreativeTab(JewelrycraftMod.jewelrycraft); } @@ -54,10 +58,16 @@ public abstract class ItemBaseJewelry extends Item { */ @Override public String getItemStackDisplayName(ItemStack stack) { - if (JewelryNBT.ingot(stack) != null && Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()) > 0) - return JewelryNBT.ingot(stack).getDisplayName().replace("Ingot", " ").trim() + " " - + ("" + StatCollector.translateToLocal(getUnlocalizedNameInefficiently(stack) + ".name")).trim(); - return ("" + StatCollector.translateToLocal(getUnlocalizedNameInefficiently(stack) + ".name")).trim(); + String itemName = ("" + StatCollector.translateToLocal(getUnlocalizedNameInefficiently(stack) + ".name")) + .trim(); + + if (JewelryNBT.ingot(stack) != null && Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()) > 0) { + String ingotName = JewelryNBT.ingot(stack).getDisplayName().replace("Ingot", " ").trim(); + + return ingotName + " " + itemName; + } + + return itemName; } /** @@ -72,10 +82,12 @@ public abstract class ItemBaseJewelry extends Item { public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) { if (stack.hasTagCompound() && ConfigHandler.JEWELRY_INFO) { ItemStack ingot = JewelryNBT.ingot(stack); + if (ingot != null && Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()) > 0) { - list.add(StatCollector.translateToLocal("info." + Variables.MODID + ".metal") + ": " - + EnumChatFormatting.YELLOW + ingot.getDisplayName() - .replace(StatCollector.translateToLocal("info." + Variables.MODID + ".ingot"), " ")); + String metalInfo = StatCollector.translateToLocal("info." + Variables.MODID + ".metal"); + String ingotInfo = StatCollector.translateToLocal("info." + Variables.MODID + ".ingot"); + + list.add(metalInfo + ": " + EnumChatFormatting.YELLOW + ingot.getDisplayName().replace(ingotInfo, " ")); } ItemStack gem = JewelryNBT.gem(stack); @@ -87,11 +99,14 @@ public abstract class ItemBaseJewelry extends Item { ArrayList modifier = JewelryNBT.modifier(stack); - if (!modifier.isEmpty()) + if (!modifier.isEmpty()) { list.add(StatCollector.translateToLocal("info." + Variables.MODID + ".modifiers") + ": "); - for (int i = 0; i < modifier.size(); i++) + } + + for (int i = 0; i < modifier.size(); i++) { list.add(EnumChatFormatting.DARK_PURPLE + modifier.get(i).getDisplayName() + " x" + modifier.get(i).stackSize); + } } } @@ -100,9 +115,11 @@ public abstract class ItemBaseJewelry extends Item { * @param player */ public void action(ItemStack item, EntityPlayer player) { - for (ModifierEffects mod : ModifierEffects.getEffects()) - if (JewelryNBT.doesModifierExist(item, mod.getModifier())) + for (ModifierEffects mod : ModifierEffects.getEffects()) { + if (JewelryNBT.doesModifierExist(item, mod.getModifier())) { mod.action(item, player, this); + } + } } /** @@ -112,9 +129,12 @@ public abstract class ItemBaseJewelry extends Item { * @return */ public boolean onPlayerAttackedCacellable(ItemStack item, EntityPlayer player, DamageSource source, float amount) { - for (ModifierEffects mod : ModifierEffects.getEffects()) - if (JewelryNBT.doesModifierExist(item, mod.getModifier())) + for (ModifierEffects mod : ModifierEffects.getEffects()) { + if (JewelryNBT.doesModifierExist(item, mod.getModifier())) { return mod.onPlayerAttackedCancellable(item, player, source, this, amount); + } + } + return false; } @@ -125,9 +145,12 @@ public abstract class ItemBaseJewelry extends Item { * @return */ public boolean onEntityAttackedCacellable(ItemStack item, EntityPlayer player, Entity target, float amount) { - for (ModifierEffects mod : ModifierEffects.getEffects()) - if (JewelryNBT.doesModifierExist(item, mod.getModifier())) + for (ModifierEffects mod : ModifierEffects.getEffects()) { + if (JewelryNBT.doesModifierExist(item, mod.getModifier())) { return mod.onEntityAttackedCancellable(item, player, target, this, amount); + } + } + return false; } @@ -150,32 +173,42 @@ public abstract class ItemBaseJewelry extends Item { * @return */ public void onEntityAttacked(ItemStack item, EntityPlayer player, Entity target, float amount) { - for (ModifierEffects mod : ModifierEffects.getEffects()) - if (JewelryNBT.doesModifierExist(item, mod.getModifier())) + for (ModifierEffects mod : ModifierEffects.getEffects()) { + if (JewelryNBT.doesModifierExist(item, mod.getModifier())) { mod.onEntityAttacked(item, player, target, this, amount); + } + } } public void onPlayerDead(ItemStack item, EntityPlayer player, DamageSource source) { - for (ModifierEffects mod : ModifierEffects.getEffects()) - if (JewelryNBT.doesModifierExist(item, mod.getModifier())) + for (ModifierEffects mod : ModifierEffects.getEffects()) { + if (JewelryNBT.doesModifierExist(item, mod.getModifier())) { mod.onPlayerDead(item, player, source, this); + } + } } public void onPlayerRespawn(ItemStack item, PlayerEvent.Clone event) { - for (ModifierEffects mod : ModifierEffects.getEffects()) - if (JewelryNBT.doesModifierExist(item, mod.getModifier())) + for (ModifierEffects mod : ModifierEffects.getEffects()) { + if (JewelryNBT.doesModifierExist(item, mod.getModifier())) { mod.onPlayerRespawn(item, event, this); + } + } } public void onJewelryEquipped(ItemStack item) { - for (ModifierEffects mod : ModifierEffects.getEffects()) - if (JewelryNBT.doesModifierExist(item, mod.getModifier())) + for (ModifierEffects mod : ModifierEffects.getEffects()) { + if (JewelryNBT.doesModifierExist(item, mod.getModifier())) { mod.onJewelryEquipped(item, this); + } + } } public void onJewelryUnequipped(ItemStack item) { - for (ModifierEffects mod : ModifierEffects.getEffects()) - if (JewelryNBT.doesModifierExist(item, mod.getModifier())) + for (ModifierEffects mod : ModifierEffects.getEffects()) { + if (JewelryNBT.doesModifierExist(item, mod.getModifier())) { mod.onJewelryUnequipped(item, this); + } + } } -} +} \ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/recipes/CraftingRecipes.java b/src/main/java/darkknight/jewelrycraft/recipes/CraftingRecipes.java index f47e48e..2d7b2a1 100755 --- a/src/main/java/darkknight/jewelrycraft/recipes/CraftingRecipes.java +++ b/src/main/java/darkknight/jewelrycraft/recipes/CraftingRecipes.java @@ -20,10 +20,12 @@ public class CraftingRecipes { // Items GameRegistry.addRecipe(new ItemStack(ItemList.thiefGloves), "x x", "yxy", "yxy", 'x', ItemList.shadowIngot, 'y', new ItemStack(Blocks.wool, 1, 15)); + // Disable ingot molds for balance reasons // GameRegistry.addRecipe(new // ItemStack(ItemList.clayMolds, 1, 0), // "xx", 'x', Items.clay_ball); + GameRegistry.addRecipe(new ItemStack(ItemList.clayMolds, 1, 1), " x ", "x x", " x ", 'x', Items.clay_ball); GameRegistry.addRecipe(new ItemStack(ItemList.clayMolds, 1, 2), "x x", "x x", " x ", 'x', Items.clay_ball); GameRegistry.addRecipe(new ItemStack(ItemList.clayMolds, 1, 3), "xxx", "x x", "xxx", 'x', Items.clay_ball); @@ -44,6 +46,7 @@ public class CraftingRecipes { new Object[] { new ItemStack(Items.book), new ItemStack(ItemList.molds, 1, 3) }); GameRegistry.addShapelessRecipe(new ItemStack(ItemList.guide), new Object[] { new ItemStack(Items.book), new ItemStack(ItemList.molds, 1, 4) }); + // Blocks GameRegistry.addRecipe( new ShapedOreRecipe(new ItemStack(BlockList.molder), "x x", "xxx", 'x', Blocks.cobblestone)); @@ -55,6 +58,7 @@ public class CraftingRecipes { Items.iron_ingot, 'y', Blocks.emerald_block)); GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BlockList.shadowBlock, 1), "xxx", "xxx", "xxx", 'x', ItemList.shadowIngot)); + // Smelting GameRegistry.addSmelting(BlockList.shadowOre, new ItemStack(ItemList.shadowIngot), 1.5f); GameRegistry.addSmelting(new ItemStack(ItemList.clayMolds, 1, 0), new ItemStack(ItemList.molds, 1, 0), @@ -67,6 +71,7 @@ public class CraftingRecipes { 0.2F); GameRegistry.addSmelting(new ItemStack(ItemList.clayMolds, 1, 4), new ItemStack(ItemList.molds, 1, 4), 0.2F); + isInitialized = true; } } diff --git a/src/main/java/darkknight/jewelrycraft/util/JewelryNBT.java b/src/main/java/darkknight/jewelrycraft/util/JewelryNBT.java index 3d42750..17090ab 100755 --- a/src/main/java/darkknight/jewelrycraft/util/JewelryNBT.java +++ b/src/main/java/darkknight/jewelrycraft/util/JewelryNBT.java @@ -11,12 +11,14 @@ public class JewelryNBT { public static void addItem(ItemStack item, ItemStack target) { if (target != null) { NBTTagCompound itemStackData; - if (item.hasTagCompound()) + + if (item.hasTagCompound()) { itemStackData = item.getTagCompound(); - else { + } else { itemStackData = new NBTTagCompound(); item.setTagCompound(itemStackData); } + NBTTagCompound targetNBT = new NBTTagCompound(); target.writeToNBT(targetNBT); itemStackData.setTag("target", targetNBT); @@ -31,12 +33,14 @@ public class JewelryNBT { */ public static void addMetal(ItemStack item, ItemStack metal) { NBTTagCompound itemStackData; - if (item.hasTagCompound()) + + if (item.hasTagCompound()) { itemStackData = item.getTagCompound(); - else { + } else { itemStackData = new NBTTagCompound(); item.setTagCompound(itemStackData); } + if (metal != null) { NBTTagCompound ingotNBT = new NBTTagCompound(); metal.writeToNBT(ingotNBT); @@ -53,12 +57,14 @@ public class JewelryNBT { public static void addGem(ItemStack item, ItemStack gem) { if (gem != null) { NBTTagCompound itemStackData; - if (item.hasTagCompound()) + + if (item.hasTagCompound()) { itemStackData = item.getTagCompound(); - else { + } else { itemStackData = new NBTTagCompound(); item.setTagCompound(itemStackData); } + NBTTagCompound gemNBT = new NBTTagCompound(); gem.writeToNBT(gemNBT); itemStackData.setTag("gem", gemNBT); @@ -74,17 +80,20 @@ public class JewelryNBT { public static void addModifiers(ItemStack item, ArrayList modifier) { if (modifier != null) { NBTTagCompound itemStackData; - if (item.hasTagCompound()) + + if (item.hasTagCompound()) { itemStackData = item.getTagCompound(); - else { + } else { itemStackData = new NBTTagCompound(); item.setTagCompound(itemStackData); } + 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()); } } @@ -95,12 +104,14 @@ public class JewelryNBT { */ public static void addIngotColor(ItemStack item, int color) { NBTTagCompound itemStackData; - if (item.hasTagCompound()) + + if (item.hasTagCompound()) { itemStackData = item.getTagCompound(); - else { + } else { itemStackData = new NBTTagCompound(); item.setTagCompound(itemStackData); } + itemStackData.setInteger("ingotColor", color); } @@ -111,12 +122,14 @@ public class JewelryNBT { */ public static void addGemColor(ItemStack item, int color) { NBTTagCompound itemStackData; - if (item.hasTagCompound()) + + if (item.hasTagCompound()) { itemStackData = item.getTagCompound(); - else { + } else { itemStackData = new NBTTagCompound(); item.setTagCompound(itemStackData); } + itemStackData.setInteger("gemColor", color); } @@ -128,14 +141,18 @@ public class JewelryNBT { */ public static boolean hasTag(ItemStack item, String tag) { NBTTagCompound itemStackData; - if (item.hasTagCompound()) + + if (item.hasTagCompound()) { itemStackData = item.getTagCompound(); - else { + } else { itemStackData = new NBTTagCompound(); item.setTagCompound(itemStackData); } - if (itemStackData.hasKey(tag)) + + if (itemStackData.hasKey(tag)) { return true; + } + return false; } @@ -145,9 +162,14 @@ public class JewelryNBT { * @return */ public static boolean isGemX(ItemStack stack, ItemStack gem) { - if (gem(stack) != null && gem(stack).getItem() == gem.getItem() - && gem(stack).getItemDamage() == gem.getItemDamage()) - return true; + if (gem(stack) != null) { + if (gem(stack).getItem() == gem.getItem()) { + if (gem(stack).getItemDamage() == gem.getItemDamage()) { + return true; + } + } + } + return false; } @@ -159,28 +181,40 @@ public class JewelryNBT { public static boolean doesModifierExist(ItemStack stack, ItemStack modifier) { 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()) { + if (list.get(i).getItemDamage() == modifier.getItemDamage()) { + return true; + } + } + } } + return false; } public static int modifierSize(ItemStack stack, ItemStack modifier) { 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 list.get(i).stackSize; + + for (int i = 0; i < list.size(); i++) { + if (list.get(i).getItem() == modifier.getItem()) { + if (list.get(i).getItemDamage() == modifier.getItemDamage()) { + return list.get(i).stackSize; + } + } + } } + return -1; } public static int numberOfModifiers(ItemStack stack) { - if (modifier(stack) != null) + if (modifier(stack) != null) { return modifier(stack).size(); + } + return -1; } @@ -190,21 +224,34 @@ public class JewelryNBT { * @return */ public static boolean isIngotX(ItemStack stack, ItemStack ingot) { - if (ingot(stack) != null && ingot(stack).getItem() == ingot.getItem() - && ingot(stack).getItemDamage() == ingot.getItemDamage()) - return true; + if (ingot(stack) != null) { + if (ingot(stack).getItem() == ingot.getItem()) { + if (ingot(stack).getItemDamage() == ingot.getItemDamage()) + return true; + } + } + return false; } // TODO Return components based on NBT public static ItemStack item(ItemStack stack) { - if (stack != null && stack != new ItemStack(Item.getItemById(0), 0, 0) && stack.hasTagCompound() - && stack.getTagCompound().hasKey("target")) { - NBTTagCompound itemNBT = (NBTTagCompound) stack.getTagCompound().getTag("target"); - ItemStack target = new ItemStack(Item.getItemById(0), 0, 0); - target.readFromNBT(itemNBT); - return target; + if (stack != null) { + if (stack != new ItemStack(Item.getItemById(0), 0, 0)) { + if (stack.hasTagCompound()) { + if (stack.getTagCompound().hasKey("target")) { + NBTTagCompound itemNBT = (NBTTagCompound) stack.getTagCompound().getTag("target"); + + ItemStack target = new ItemStack(Item.getItemById(0), 0, 0); + + target.readFromNBT(itemNBT); + + return target; + } + } + } } + return null; } @@ -213,13 +260,20 @@ public class JewelryNBT { * @return */ 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; + if (stack != null) { + if (stack != new ItemStack(Item.getItemById(0), 0, 0)) { + if (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; } @@ -228,17 +282,28 @@ public class JewelryNBT { * @return */ 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++) { - ItemStack modifier = new ItemStack(Item.getItemById(0), 0, 0); - NBTTagCompound modifierNBT = (NBTTagCompound) stack.getTagCompound().getTag("modifier" + i); - modifier.readFromNBT(modifierNBT); - list.add(modifier); + if (stack != null) { + if (stack != new ItemStack(Item.getItemById(0), 0, 0)) { + if (stack.hasTagCompound()) { + int size = stack.getTagCompound().getInteger("modifierSize"); + + ArrayList list = new ArrayList<>(); + + 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 list; } + return null; } @@ -247,13 +312,22 @@ public class JewelryNBT { * @return */ public static ItemStack ingot(ItemStack stack) { - if (stack != null && stack != new ItemStack(Item.getItemById(0), 0, 0) && stack.hasTagCompound() - && stack.getTagCompound().hasKey("ingot")) { - NBTTagCompound ingotNBT = (NBTTagCompound) stack.getTagCompound().getTag("ingot"); - ItemStack ingot = new ItemStack(Item.getItemById(0), 0, 0); - ingot.readFromNBT(ingotNBT); - return ingot; + if (stack != null) { + if (stack != new ItemStack(Item.getItemById(0), 0, 0)) { + if (stack.hasTagCompound()) { + if (stack.getTagCompound().hasKey("ingot")) { + NBTTagCompound ingotNBT = (NBTTagCompound) stack.getTagCompound().getTag("ingot"); + + ItemStack ingot = new ItemStack(Item.getItemById(0), 0, 0); + + ingot.readFromNBT(ingotNBT); + + return ingot; + } + } + } } + return null; } @@ -262,9 +336,16 @@ public class JewelryNBT { * @return */ public static int ingotColor(ItemStack stack) { - if (stack != null && stack != new ItemStack(Item.getItemById(0), 0, 0) && stack.hasTagCompound() - && stack.getTagCompound().hasKey("ingotColor")) - return stack.getTagCompound().getInteger("ingotColor"); + if (stack != null) { + if (stack != new ItemStack(Item.getItemById(0), 0, 0)) { + if (stack.hasTagCompound()) { + if (stack.getTagCompound().hasKey("ingotColor")) { + return stack.getTagCompound().getInteger("ingotColor"); + } + } + } + } + return 16777215; } @@ -274,10 +355,15 @@ public class JewelryNBT { * @return */ public static int gemColor(ItemStack stack) { - if (stack != null && stack != new ItemStack(Item.getItemById(0), 0, 0) && stack.hasTagCompound() - && stack.getTagCompound().hasKey("gemColor")) - return stack.getTagCompound().getInteger("gemColor"); + if (stack != null) { + if (stack != new ItemStack(Item.getItemById(0), 0, 0)) { + if (stack.hasTagCompound()) { + if (stack.getTagCompound().hasKey("gemColor")) + return stack.getTagCompound().getInteger("gemColor"); + } + } + } + return 16777215; } - -} +} \ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/util/JewelrycraftUtil.java b/src/main/java/darkknight/jewelrycraft/util/JewelrycraftUtil.java index 80dfdf1..cdcdd12 100755 --- a/src/main/java/darkknight/jewelrycraft/util/JewelrycraftUtil.java +++ b/src/main/java/darkknight/jewelrycraft/util/JewelrycraftUtil.java @@ -1,10 +1,7 @@ package darkknight.jewelrycraft.util; import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Random; +import java.util.*; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.relauncher.Side; @@ -106,10 +103,6 @@ public class JewelrycraftUtil { } } - private static boolean itemHasSubtypes(Object item) { - return ((Item) item).getHasSubtypes() && FMLCommonHandler.instance().getSide() == Side.CLIENT; - } - @SideOnly(Side.CLIENT) public static void generateColors() { @@ -180,17 +173,6 @@ public class JewelrycraftUtil { .getIcon(0, item.getItemDamage()).getIconName().equals("soul_sand"); } - /* - * @SideOnly(Side.CLIENT) public static int getMostCommonColour(Map map) { List - * list = new LinkedList(map.entrySet()); Collections.sort(list, new - * Comparator() { public int compare(Object o1, Object o2) { return - * ((Comparable) ((Map.Entry) o1).getValue()) .compareTo(((Map.Entry) - * o2).getValue()); } }); Map.Entry me = (Map.Entry) list.get(list.size() - 1); - * for (int i = 0; i < list.size(); i++) { float alpha = Float - * .valueOf(list.get(i).toString().split("=")[1]); if (alpha < 180) me = - * (Map.Entry) list.get(i); } int rgb = (Integer) me.getKey(); return rgb; } - */ - @SideOnly(Side.CLIENT) public static boolean isGray(int[] rgbArr) { int rgbSum = rgbArr[0] + rgbArr[1] + rgbArr[2]; @@ -224,8 +206,13 @@ public class JewelrycraftUtil { public static void addCursePoints(EntityPlayer player, int points) { NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); - playerInfo.setInteger("cursePoints", - playerInfo.hasKey("cursePoints") ? (playerInfo.getInteger("cursePoints") + points) : points); + int cursePoints; + if (playerInfo.hasKey("cursePoints")) + cursePoints = (playerInfo.getInteger("cursePoints") + points); + else + cursePoints = points; + + playerInfo.setInteger("cursePoints", cursePoints); playerInfo.setBoolean("playerCursePointsChanged", true); } diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/village/JCTrades.java b/src/main/java/darkknight/jewelrycraft/worldGen/village/JCTrades.java index f23dee6..eef3a99 100755 --- a/src/main/java/darkknight/jewelrycraft/worldGen/village/JCTrades.java +++ b/src/main/java/darkknight/jewelrycraft/worldGen/village/JCTrades.java @@ -134,6 +134,7 @@ public class JCTrades implements IVillageTradeHandler { ingredient2 = new ItemStack(Blocks.emerald_block, 2 + randValue); } } + recipeList.addToListWithCheck(new MerchantRecipe(ingredient, ingredient2, result)); } } -- cgit v1.2.3