diff options
| author | OnyxDarkKnight <sor1n.iliutza16@gmail.com> | 2015-02-03 21:09:09 +0000 |
|---|---|---|
| committer | OnyxDarkKnight <sor1n.iliutza16@gmail.com> | 2015-02-03 21:09:09 +0000 |
| commit | 3f4c717de5ebc9b942d65ae45ac87c43bdf8a31b (patch) | |
| tree | 15c68c8b61dbd0b7f44937a5c790c4b844e50f58 /java | |
| parent | 73ca377dc01f859dabd7b07738cb7aeb762272b1 (diff) | |
Made a few modifications to some classes, added earrings and bracelets. Improved coloring algorithm and balanced the Thieving Glove
Diffstat (limited to 'java')
41 files changed, 1026 insertions, 2724 deletions
diff --git a/java/darkknight/jewelrycraft/block/BlockDisplayer.java b/java/darkknight/jewelrycraft/block/BlockDisplayer.java index 6b029b9..3bb8fbb 100644 --- a/java/darkknight/jewelrycraft/block/BlockDisplayer.java +++ b/java/darkknight/jewelrycraft/block/BlockDisplayer.java @@ -69,10 +69,10 @@ public class BlockDisplayer extends BlockContainer { te.object = item.copy(); te.quantity += item.stackSize; + te.object.stackSize = 1; te.hasObject = true; - if (!entityPlayer.capabilities.isCreativeMode) item.stackSize = 0; + if (!entityPlayer.capabilities.isCreativeMode) entityPlayer.inventory.decrStackSize(entityPlayer.inventory.currentItem, item.stackSize); te.isDirty = true; - te.markDirty(); } else if (te.object.getItem() == item.getItem() && te.object != null && te.object != new ItemStack(Item.getItemById(0), 0, 0) && te.object.getItemDamage() == item.getItemDamage()) { @@ -81,14 +81,12 @@ public class BlockDisplayer extends BlockContainer te.quantity += item.stackSize; if (!entityPlayer.capabilities.isCreativeMode) entityPlayer.inventory.decrStackSize(entityPlayer.inventory.currentItem, item.stackSize); te.isDirty = true; - te.markDirty(); } else if (!te.object.hasTagCompound() && !item.hasTagCompound()) { te.quantity += item.stackSize; if (!entityPlayer.capabilities.isCreativeMode) entityPlayer.inventory.decrStackSize(entityPlayer.inventory.currentItem, item.stackSize); te.isDirty = true; - te.markDirty(); } } } @@ -113,18 +111,17 @@ public class BlockDisplayer extends BlockContainer te.quantity += item.stackSize; if (!entityPlayer.capabilities.isCreativeMode) entityPlayer.inventory.decrStackSize(inv, item.stackSize); te.isDirty = true; - te.markDirty(); } } } } - else if(te.hasObject && te.object.getItem() != null) + else if(entityPlayer.capabilities.isCreativeMode && te.hasObject && te.object.getItem() != null) { te.quantity += 64; - te.isDirty = true; - te.markDirty(); + te.isDirty = true; } } + te.isDirty = true; } return true; } @@ -145,6 +142,7 @@ public class BlockDisplayer extends BlockContainer player.inventory.addItemStackToInventory(te.object); te.object.stackSize = 1; te.quantity -= te.object.getMaxStackSize(); + te.isDirty = true; } else { @@ -153,9 +151,9 @@ public class BlockDisplayer extends BlockContainer te.hasObject = false; te.object = new ItemStack(Item.getItemById(0), 0, 0); te.quantity = 0; + te.isDirty = true; } te.isDirty = true; - te.markDirty(); } else { @@ -163,7 +161,8 @@ public class BlockDisplayer extends BlockContainer { player.inventory.addItemStackToInventory(te.object); te.object.stackSize = 1; - --te.quantity; + te.quantity--; + te.isDirty = true; } else { @@ -172,9 +171,9 @@ public class BlockDisplayer extends BlockContainer te.hasObject = false; te.object = new ItemStack(Item.getItemById(0), 0, 0); te.quantity = 0; + te.isDirty = true; } te.isDirty = true; - te.markDirty(); } } } diff --git a/java/darkknight/jewelrycraft/block/BlockMoltenMetal.java b/java/darkknight/jewelrycraft/block/BlockMoltenMetal.java index f005e04..da3c5c1 100644 --- a/java/darkknight/jewelrycraft/block/BlockMoltenMetal.java +++ b/java/darkknight/jewelrycraft/block/BlockMoltenMetal.java @@ -2,6 +2,12 @@ package darkknight.jewelrycraft.block; import java.awt.image.BufferedImage; import java.io.IOException; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; import java.util.Random; import javax.imageio.ImageIO; @@ -221,17 +227,13 @@ public class BlockMoltenMetal extends BlockFluidClassic world.setBlock(x, y, z, this, meta, 3); JewelrycraftMod.saveData.setString(stringFromLocation(x, y, z, world.provider.dimensionId), originData); String[] data = originData.split(":"); - JewelrycraftMod.netWrapper.sendToAll(new PacketSendLiquidData(world.provider.dimensionId, x, y, z, Integer.parseInt(data[0]), Integer.parseInt(data[1]))); + JewelrycraftMod.netWrapper.sendToAll(new PacketSendLiquidData(world.provider.dimensionId, x, y, z, Integer.parseInt(data[0]), Integer.parseInt(data[1]), Integer.parseInt(data[2]))); } } @SideOnly(Side.CLIENT) public static int color(IBlockAccess world, int i, int j, int k, boolean forcecolor, Item itemC) throws IOException { - String domain = "", texture; - IResourceManager rm = Minecraft.getMinecraft().getResourceManager(); - BufferedImage icon; - ItemStack item = new ItemStack(BlockList.moltenMetal); String ingotData = JewelrycraftMod.clientData.getString(String.valueOf(i) + " " + String.valueOf(j) + " " + String.valueOf(k) + " " + Minecraft.getMinecraft().theWorld.provider.dimensionId); if (ingotData == "") { @@ -241,14 +243,15 @@ public class BlockMoltenMetal extends BlockFluidClassic else { String[] splitData = ingotData.split(":"); - if (splitData.length == 2) + if (splitData.length == 3) { - int itemID, itemDamage; + int itemID, itemDamage, color; try { itemID = Integer.parseInt(splitData[0]); itemDamage = Integer.parseInt(splitData[1]); - JewelryNBT.addMetal(item, new ItemStack(Item.getItemById(itemID), 1, itemDamage)); + color = Integer.parseInt(splitData[2]); + return color; } catch (Exception e) { @@ -256,53 +259,9 @@ public class BlockMoltenMetal extends BlockFluidClassic } } } - if (forcecolor) JewelryNBT.addMetal(item, new ItemStack(itemC)); - int x = 0, y = 0, ok = 0, red, green, blue; - if (item != null && JewelryNBT.ingot(item) != null && JewelryNBT.ingot(item).getIconIndex() != null && JewelryNBT.ingotColor(item) == 16777215) - { - IIcon itemIcon = JewelryNBT.ingot(item).getItem().getIcon(JewelryNBT.ingot(item), 0); - String ingotIconName = itemIcon.getIconName(); - - if (ingotIconName.substring(0, ingotIconName.indexOf(":") + 1) != "") domain = ingotIconName.substring(0, ingotIconName.indexOf(":") + 1).replace(":", " ").trim(); - else domain = "minecraft"; - - texture = ingotIconName.substring(ingotIconName.lastIndexOf(":") + 1) + ".png"; - ResourceLocation ingot = null; - TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); - - if (texturemanager.getResourceLocation(JewelryNBT.ingot(item).getItemSpriteNumber()).toString().contains("items")) ingot = new ResourceLocation(domain.toLowerCase(), "textures/items/" + texture); - else ingot = new ResourceLocation(domain.toLowerCase(), "textures/blocks/" + texture); - - icon = ImageIO.read(rm.getResource(ingot).getInputStream()); - while (ok == 0) - { - red = (icon.getRGB(x, y) >> 16) & 0xFF; - green = (icon.getRGB(x, y) >> 8) & 0xFF; - blue = icon.getRGB(x, y) & 0xFF; - if (!isColorPretty(red, green, blue)) - { - if (x < icon.getTileWidth() - 1) x++; - if (x >= icon.getTileWidth() - 1 && y < icon.getTileWidth() - 1) - { - x = 0; - y++; - } - if (x == icon.getTileWidth() - 1 && y == icon.getTileWidth() - 1) ok = 1; - } - else ok = 1; - } - JewelryNBT.addIngotColor(item, icon.getRGB(x, y)); - } - if (JewelryNBT.ingot(item) != null) return JewelryNBT.ingotColor(item); return 16777215; } - public static boolean isColorPretty(int r, int g, int b) - { - if ((r >= 100 && g >= 100 && b >= 100 && r < 200 && b < 200 && g < 200) || ((r >= 100 && (g < 100 || b < 100)) || (g >= 100 && (r < 100 || b < 100)) || (b >= 100 && (g < 100 || r < 100)))) return true; - else return false; - } - public static String stringFromLocation(int x, int y, int z, int dimID) { return x + " " + y + " " + z + " " + dimID; diff --git a/java/darkknight/jewelrycraft/block/BlockSmelter.java b/java/darkknight/jewelrycraft/block/BlockSmelter.java index 71ba64b..a4d379b 100644 --- a/java/darkknight/jewelrycraft/block/BlockSmelter.java +++ b/java/darkknight/jewelrycraft/block/BlockSmelter.java @@ -1,5 +1,6 @@ package darkknight.jewelrycraft.block; +import java.io.IOException; import java.util.Random; import net.minecraft.block.Block; @@ -22,6 +23,7 @@ import net.minecraft.world.World; import darkknight.jewelrycraft.JewelrycraftMod; import darkknight.jewelrycraft.config.ConfigHandler; import darkknight.jewelrycraft.item.ItemList; +import darkknight.jewelrycraft.item.ItemMoltenMetalBucket; import darkknight.jewelrycraft.network.PacketSendLiquidData; import darkknight.jewelrycraft.tileentity.TileEntityMolder; import darkknight.jewelrycraft.tileentity.TileEntitySmelter; @@ -55,6 +57,7 @@ public class BlockSmelter extends BlockContainer entityitem.motionX = 0; entityitem.motionZ = 0; entityitem.motionY = 0.11000000298023224D; + entityitem.delayBeforeCanPickup = 0; world.spawnEntityInWorld(entityitem); } @@ -66,8 +69,22 @@ public class BlockSmelter extends BlockContainer if (te.hasMetal) dropItem(world, (double) te.xCoord, (double) te.yCoord, (double) te.zCoord, te.metal.copy()); if (te.hasMoltenMetal && te.moltenMetal != null && Item.getIdFromItem(te.moltenMetal.getItem()) > 0) { - JewelrycraftMod.saveData.setString(i + " " + j + " " + k + " " + world.provider.dimensionId, Item.getIdFromItem(te.moltenMetal.getItem()) + ":" + te.moltenMetal.getItemDamage()); - JewelrycraftMod.netWrapper.sendToAll(new PacketSendLiquidData(world.provider.dimensionId, i, j, k, Item.getIdFromItem(te.moltenMetal.getItem()), te.moltenMetal.getItemDamage())); + ItemStack metal = te.moltenMetal; + ItemStack item = te.moltenMetal; + if (Item.getIdFromItem(metal.getItem()) == Block.getIdFromBlock(Blocks.stained_glass) || Item.getIdFromItem(metal.getItem()) == Block.getIdFromBlock(Blocks.stained_hardened_clay) || Item.getIdFromItem(metal.getItem()) == Block.getIdFromBlock(Blocks.wool) || Item.getIdFromItem(metal.getItem()) == Block.getIdFromBlock(Blocks.carpet)) metal.setItemDamage(15 - metal.getItemDamage()); + int color = 16777215; + JewelryNBT.addMetal(item, metal); + try + { + color = ItemMoltenMetalBucket.color(item, 1); + System.out.println(color); + } + catch (IOException e) + { + e.printStackTrace(); + } + JewelrycraftMod.saveData.setString(i + " " + j + " " + k + " " + world.provider.dimensionId, Item.getIdFromItem(metal.getItem()) + ":" + metal.getItemDamage() + ":" + color); + JewelrycraftMod.netWrapper.sendToAll(new PacketSendLiquidData(world.provider.dimensionId, i, j, k, Item.getIdFromItem(metal.getItem()), metal.getItemDamage(), color)); world.setBlock(i, j, k, BlockList.moltenMetal, 0, 3); int quant = (int) (te.quantity * 10); @@ -96,8 +113,8 @@ public class BlockSmelter extends BlockContainer te.quantity = 0f; te.hasMoltenMetal = false; ItemStack metalBucket = new ItemStack(ItemList.bucket, 1); - ItemStack ingot = te.moltenMetal; - if (Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_glass) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_glass_pane) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_hardened_clay) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.wool) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.carpet)) ingot.setItemDamage(15 - ingot.getItemDamage()); + ItemStack ingot = te.moltenMetal.copy(); + if (Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_glass) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_hardened_clay) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.wool) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.carpet)) ingot.setItemDamage(15 - ingot.getItemDamage()); JewelryNBT.addMetal(metalBucket, ingot); --item.stackSize; entityPlayer.inventory.addItemStackToInventory(metalBucket); @@ -106,17 +123,20 @@ public class BlockSmelter extends BlockContainer } if (te != null && !world.isRemote) { - int index = -1; - for (int a = 0; a < JewelrycraftUtil.jamcraftPlayers.size(); a++) - if (entityPlayer.getDisplayName().equals(JewelrycraftUtil.jamcraftPlayers.get(a))) index = a; - boolean canPlace = (item != null && (JewelrycraftUtil.isMetal(item) || JewelrycraftUtil.isOre(item) || index >= 0)); - boolean isOre = false; - boolean oreCoincidesWithMetal = false; - boolean itemCoincidesWithMetal = false; - boolean itemCoincidesWithMoltenMetal = false; - boolean overflow = false; - if (item != null && item.getItem() != null) + if (te.hasMetal && entityPlayer.isSneaking()) { + dropItem(world, (double) te.xCoord, (double) te.yCoord, (double) te.zCoord, te.metal.copy()); + te.hasMetal = false; + te.melting = -1; + te.isDirty = true; + } + if (item != null && item.getItem() != null && !(item.getItem() instanceof ItemMoltenMetalBucket)) + { + int index = -1; + for (int a = 0; a < JewelrycraftUtil.jamcraftPlayers.size(); a++) + if (entityPlayer.getDisplayName().equals(JewelrycraftUtil.jamcraftPlayers.get(a))) index = a; + boolean canPlace = (item != null && (JewelrycraftUtil.isMetal(item) || JewelrycraftUtil.isOre(item) || index >= 0)); + boolean isOre = false, oreCoincidesWithMetal = false, itemCoincidesWithMetal = false, itemCoincidesWithMoltenMetal = false, overflow = false; isOre = JewelrycraftUtil.isOre(item); if (te.metal != null && te.metal.getItem() != null) itemCoincidesWithMetal = item.getItem().equals(te.metal.getItem()) && item.getItemDamage() == te.metal.getItemDamage(); if (te.moltenMetal != null && te.moltenMetal.getItem() != null) @@ -125,45 +145,52 @@ public class BlockSmelter extends BlockContainer if (isOre) oreCoincidesWithMetal = te.moltenMetal.getItem().equals(JewelrycraftUtil.getIngotFromOre(item.getItem()).getItem()) && te.moltenMetal.getItemDamage() == JewelrycraftUtil.getIngotFromOre(item.getItem()).getItemDamage(); } overflow = isOre ? (te.metal.stackSize * 0.2f + te.quantity < 0.8f) : (te.metal.stackSize * 0.1f + te.quantity < 0.9f); - } - boolean isValid = te.hasMoltenMetal ? itemCoincidesWithMoltenMetal : true; - if (te.quantity < 0.9f && !te.pouring && canPlace && isValid) - { - boolean check = isOre ? (oreCoincidesWithMetal && te.quantity < 0.8f) : itemCoincidesWithMoltenMetal; - boolean check2 = isOre ? oreCoincidesWithMetal : itemCoincidesWithMetal; - if ((!te.hasMetal && !te.hasMoltenMetal) || (!te.hasMetal && te.hasMoltenMetal && check)) + boolean isValid = te.hasMoltenMetal ? itemCoincidesWithMoltenMetal : true; + if (te.quantity < 0.9f && !te.pouring && canPlace && isValid) { - entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage.Jewelrycraft.smelter.nowsmeltingingot", item.getDisplayName()))); - te.metal = item.copy(); - te.metal.stackSize = 1; - te.hasMetal = true; - te.melting = ConfigHandler.ingotMeltingTime; - if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize; + boolean check = isOre ? (oreCoincidesWithMetal && te.quantity < 0.8f) : itemCoincidesWithMoltenMetal; + boolean check2 = isOre ? oreCoincidesWithMetal : itemCoincidesWithMetal; + if ((!te.hasMetal && !te.hasMoltenMetal) || (!te.hasMetal && te.hasMoltenMetal && check)) + { + entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage.Jewelrycraft.smelter.nowsmeltingingot", item.getDisplayName()))); + te.metal = item.copy(); +// if (Item.getIdFromItem(te.metal.getItem()) == Block.getIdFromBlock(Blocks.stained_glass) || Item.getIdFromItem(te.metal.getItem()) == Block.getIdFromBlock(Blocks.stained_hardened_clay) || Item.getIdFromItem(te.metal.getItem()) == Block.getIdFromBlock(Blocks.wool) || Item.getIdFromItem(te.metal.getItem()) == Block.getIdFromBlock(Blocks.carpet)) te.metal.setItemDamage(15 - te.metal.getItemDamage()); + te.metal.stackSize = 1; + te.hasMetal = true; + te.melting = ConfigHandler.ingotMeltingTime; + if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize; + te.isDirty = true; + } + else if ((te.hasMetal && te.hasMoltenMetal && check2 && overflow) || (te.hasMetal && !te.hasMoltenMetal && itemCoincidesWithMetal && overflow)) + { + entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("Smelting extra " + (isOre ? "ores" : "ingots") + " (" + (te.metal.stackSize + 1) + ")"))); + te.metal.stackSize++; + te.hasMetal = true; + te.melting += ConfigHandler.ingotMeltingTime; + if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize; + te.isDirty = true; + } te.isDirty = true; } - else if ((te.hasMetal && te.hasMoltenMetal && check2 && overflow) || (te.hasMetal && !te.hasMoltenMetal && itemCoincidesWithMetal && overflow)) - { - entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("Smelting extra " + (isOre ? "ores" : "ingots") + " (" + (te.metal.stackSize + 1) + ")"))); - te.metal.stackSize++; - te.hasMetal = true; - te.melting = ConfigHandler.ingotMeltingTime; - if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize; - te.isDirty = true; - } - te.isDirty = true; + else if (item != null && (te.hasMetal || te.hasMoltenMetal) && !itemCoincidesWithMoltenMetal && te.quantity < 0.9f) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("Item does not match contents!"))); + else if (item != null && !item.getUnlocalizedName().toLowerCase().contains("ingot") && te.quantity < 0.9f) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage.Jewelrycraft.smelter.itemrenamedtoingot"))); + else if (item != null && te.quantity >= 0.9f) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("Smelter is at full capacity."))); } - else if (item == null && te.hasMoltenMetal && te.moltenMetal.getItem() != null) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage.Jewelrycraft.smelter.hasmolteningot", te.moltenMetal.getDisplayName()))); - else if (item != null && (te.hasMetal || te.hasMoltenMetal) && !itemCoincidesWithMoltenMetal && te.quantity < 0.9f) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("Item does not match contents!"))); - else if (item != null && !item.getUnlocalizedName().toLowerCase().contains("ingot") && te.quantity < 0.9f) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage.Jewelrycraft.smelter.itemrenamedtoingot"))); - else if (item != null && te.quantity >= 0.9f) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("Smelter is at full capacity."))); - - if (te.hasMetal && entityPlayer.isSneaking()) + else if (item != null && item.getItem() != null && item.getItem() instanceof ItemMoltenMetalBucket && !te.hasMoltenMetal && !te.hasMetal) { - dropItem(world, (double) te.xCoord, (double) te.yCoord, (double) te.zCoord, te.metal.copy()); - te.hasMetal = false; - te.melting = -1; + te.hasMoltenMetal = true; + ItemStack ingot = JewelryNBT.ingot(item); + if (Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_glass) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_hardened_clay) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.wool) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.carpet)) ingot.setItemDamage(15 - ingot.getItemDamage()); + te.moltenMetal = ingot; + te.quantity = 0.9f; te.isDirty = true; + if (!entityPlayer.capabilities.isCreativeMode) + { + --item.stackSize; + dropItem(world, entityPlayer.posX, entityPlayer.posY, entityPlayer.posZ, new ItemStack(Items.bucket)); + } } + else if (item == null && te.hasMoltenMetal && te.moltenMetal.getItem() != null) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage.Jewelrycraft.smelter.hasmolteningot", te.moltenMetal.getDisplayName()))); world.setTileEntity(i, j, k, te); } return true; @@ -186,7 +213,7 @@ public class BlockSmelter extends BlockContainer te.pouring = true; te.isDirty = true; } - else if (te.hasMetal && te.melting > 0) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage.Jewelrycraft.smelter.metalismelting", te.metal.getDisplayName()) + " (" + ((ConfigHandler.ingotMeltingTime - te.melting) * 100 / ConfigHandler.ingotMeltingTime) + "%)")); + else if (te.hasMetal && te.melting > 0) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage.Jewelrycraft.smelter.metalismelting", te.metal.getDisplayName()) + " (" + (((ConfigHandler.ingotMeltingTime*te.metal.stackSize) - te.melting) * 100 / (ConfigHandler.ingotMeltingTime*te.metal.stackSize)) + "%)")); else if (te.hasMoltenMetal && !isConnectedToMolder(world, i, j, k)) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage.Jewelrycraft.smelter.molderismissing"))); else if (!me.hasMold && te.hasMoltenMetal) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage.Jewelrycraft.smelter.molderhasnomold"))); else if (me.hasMoltenMetal && te.hasMoltenMetal) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage.Jewelrycraft.smelter.molderhasmoltenmetal"))); diff --git a/java/darkknight/jewelrycraft/client/GuiGuide.java b/java/darkknight/jewelrycraft/client/GuiGuide.java index 6112d5d..879c9b3 100644 --- a/java/darkknight/jewelrycraft/client/GuiGuide.java +++ b/java/darkknight/jewelrycraft/client/GuiGuide.java @@ -19,10 +19,9 @@ import darkknight.jewelrycraft.block.BlockList; import darkknight.jewelrycraft.container.GuiRectangle; import darkknight.jewelrycraft.container.GuiTab; import darkknight.jewelrycraft.container.GuiTabBlocks; +import darkknight.jewelrycraft.container.GuiTabGemsAndIngots; import darkknight.jewelrycraft.container.GuiTabItems; -import darkknight.jewelrycraft.container.GuiTabJewelsAndModifiers; -import darkknight.jewelrycraft.container.GuiTabNecklaces; -import darkknight.jewelrycraft.container.GuiTabRings; +import darkknight.jewelrycraft.container.GuiTabModifiers; public class GuiGuide extends GuiContainer { @@ -41,7 +40,7 @@ public class GuiGuide extends GuiContainer this.world = world; tabs = new GuiTab[] - { new GuiTabBlocks(0), new GuiTabItems(1), new GuiTabJewelsAndModifiers(2)}; + { new GuiTabBlocks(0), new GuiTabItems(1), new GuiTabGemsAndIngots(2), new GuiTabModifiers(3)}; activeTab = tabs[0]; } diff --git a/java/darkknight/jewelrycraft/config/ConfigHandler.java b/java/darkknight/jewelrycraft/config/ConfigHandler.java index ec7f0c1..3d28829 100644 --- a/java/darkknight/jewelrycraft/config/ConfigHandler.java +++ b/java/darkknight/jewelrycraft/config/ConfigHandler.java @@ -1,5 +1,7 @@ package darkknight.jewelrycraft.config; +import java.io.File; + import net.minecraftforge.common.config.Configuration; import cpw.mods.fml.common.event.FMLPreInitializationEvent; @@ -8,7 +10,7 @@ public class ConfigHandler public static Configuration config; public static int ingotCoolingTime = 100; public static int ingotMeltingTime = 1500; - public static int jewelryCraftingTime = 1000; + public static int jewelryCraftingTime = 200; private static boolean isInitialized = false; public static boolean generateVillageNetherstar = false; @@ -27,7 +29,7 @@ public class ConfigHandler { if (!isInitialized) { - config = new Configuration(e.getSuggestedConfigurationFile()); + config = new Configuration(new File(e.getModConfigurationDirectory(), "JewelryCraftv2.0.cfg")); config.load(); diff --git a/java/darkknight/jewelrycraft/container/GuiTabBlocks.java b/java/darkknight/jewelrycraft/container/GuiTabBlocks.java index 507808b..237466c 100644 --- a/java/darkknight/jewelrycraft/container/GuiTabBlocks.java +++ b/java/darkknight/jewelrycraft/container/GuiTabBlocks.java @@ -26,53 +26,28 @@ public class GuiTabBlocks extends GuiTab @Override public void drawBackground(GuiGuide gui, int x, int y, int page) { - ArrayList<String> text = new ArrayList<String>(); + String text = ""; ArrayList<ItemStack> items = new ArrayList<ItemStack>(); int xPos = (page % 2 == 0) ? 107 : -35; switch (page) { case 1: - text.add(" This ore is extremely"); - text.add("rare and can be found"); - text.add("only between Y level 5"); - text.add("and 8. It can only be"); - text.add("mined using a diamond"); - text.add("pickaxe."); + text = "This ore is extremely rare and can be found only between Y-level 5 and 8. It can only be mined using a diamond pickaxe."; Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), new ItemStack(BlockList.shadowOre), text, 90f); break; case 2: - text.add(" The Shadow Block is"); - text.add("crafted using 9 shadow"); - text.add("ingots. It has been"); - text.add("discovered that it"); - text.add("poseses abnormal"); - text.add("properties in the"); - text.add("shadow. The darker it"); + text = "The Shadow Block is crafted using 9 shadow ingots. Magicians believed it held the ability to merge with the shadows. It becomes more transparent as it"; items.add(new ItemStack(BlockList.shadowBlock)); for (int i = 1; i <= 9; i++) items.add(new ItemStack(ItemList.shadowIngot)); Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), false, text, items, x, y); break; case 3: - text.add("is, the more"); - text.add("transparent it will be,"); - text.add("until it becomes"); - text.add("walkable through. If a"); - text.add("comparator is attached"); - text.add("to it, the output"); - text.add("strength will be equal"); - text.add("to the value of"); - text.add("darkness it is in."); + text = "gets darker. If a comparator is attached to it, the output strength will be equal to the value of darkness it is in."; Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); break; case 4: - text.add(" The smelter is one of"); - text.add("the first blocks needed"); - text.add("to get started with"); - text.add("Jewelrycraft. Requiring"); - text.add("just some cobble and"); - text.add("a couple buckets, it's"); - text.add("the most important"); + text = "The smelter is one of the first blocks needed to get started with Jewelrycraft. Requiring just some cobble and a couple buckets. It is required in order to"; items.add(new ItemStack(BlockList.smelter)); items.add(new ItemStack(Blocks.cobblestone)); items.add(new ItemStack(Items.bucket)); @@ -86,37 +61,15 @@ public class GuiTabBlocks extends GuiTab Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), false, text, items, x, y); break; case 5: - text.add("block as it can melt"); - text.add("ingots which can be"); - text.add("made into pieces of"); - text.add("jewellery, like rings"); - text.add("or necklaces. To use"); - text.add("the block all you need"); - text.add("to do is right click"); - text.add("on it with any ingot."); - text.add("If left clicked while"); - text.add("smelting, a message"); - text.add("will appear saying the"); - text.add("percentage it is done."); + text = "melt ingots or even ores which can be made into rings, necklaces, bracelets or earrings. To use the block all you need to do is right click on it with any ore or ingot. It can melt multimple ingots/ores at a time. Crouch (default: Shift) + Right Click will remove all items"; Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); break; case 6: - text.add("If left clicked when"); - text.add("it's done smelting,"); - text.add("a message will be"); - text.add("displayed, mentioning"); - text.add("the contents of the"); - text.add("block."); + text = "added. If right clicked when done smelting, it will say what the block contains."; Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); break; case 7: - text.add(" The molder is a key"); - text.add("piece in creating"); - text.add("jewellery. You need"); - text.add("to pour the molten"); - text.add("metal out of the"); - text.add("smelter somewhere."); - text.add("That somewhere is the"); + text = "The molder is a key piece in creating jewellery. You need to pour the molten metal out of the smelter somewhere. That somewhere is the"; items.add(new ItemStack(BlockList.molder)); items.add(new ItemStack(Blocks.cobblestone)); @@ -127,43 +80,15 @@ public class GuiTabBlocks extends GuiTab Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), false, text, items, x, y); break; case 8: - text.add("molder. But before"); - text.add("pouring the molten"); - text.add("metal in it, you must"); - text.add("first add a mold."); - text.add("You can do that by"); - text.add("simply right clicking"); - text.add("the block with the"); - text.add("mold of your choice."); - text.add("If you want to get the"); - text.add("mold out, simply crouch"); - text.add("and right click it with"); - text.add("an empty hand."); + text = "molder. But before pouring the molten metal in it, you must first add a mold. You can do that by simply right clicking the block with the mold of your choice. If you want to get the mold out, simply crouch and Right Click it with an empty hand. Once you"; Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); break; case 9: - text.add(" Once you have a mold"); - text.add("inside, left click on"); - text.add("the smelter and wait"); - text.add("for the metal to cool"); - text.add("down. When it's done,"); - text.add("left click on the"); - text.add("molder to get the"); - text.add("jewellery. " + EnumChatFormatting.DARK_RED + "Be aware"); - text.add(EnumChatFormatting.DARK_RED + "that this block must be"); - text.add(EnumChatFormatting.DARK_RED + "placed directly in front"); - text.add(EnumChatFormatting.DARK_RED + "of the smelter,"); - text.add(EnumChatFormatting.DARK_RED + "otherwise it won't work!"); + text = "have a mold inside, left click on the smelter and wait for the metal to cool down. When it's done, left click on the molder to get the jewellery. Be aware that this block must be placed directly in front of the smelter, otherwise it won't work!"; Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); break; case 10: - text.add(" Your jewellery on"); - text.add("their own don't do"); - text.add("much. They need to be"); - text.add("modified a bit and the"); - text.add("only way to do that is"); - text.add("by using this block."); - text.add("Simply right click the"); + text = "This table allows you to add a gem to a piece of jewellery. Right click the block while holding a jewellery to add it in. Then do the same with a gem (you"; if (del == 0) values++; del++; if (del >= 300) del = 0; @@ -180,39 +105,15 @@ public class GuiTabBlocks extends GuiTab Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), false, text, items, x, y); break; case 11: - text.add("block while holding the"); - text.add("jewellery to place it in."); - text.add("After that just add in"); - text.add("a jewel or a modifier,"); - text.add("or even both, to the"); - text.add("block. To do that simply"); - text.add("right click with them on"); - text.add("the block. Once it's"); - text.add("done modifying, left"); - text.add("click on it to retrieve"); - text.add("the modified item. If"); - text.add("you wish to know how"); + text = "can find a list with all possible gems in this guide). Crouch + Right Click to retreive placed items. Left Click the block to see the progress the crafting has made. Once the crafting is done, Left Click the block to get the item. You are able to recraft a"; Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); break; case 12: - text.add("much is left before the"); - text.add("transformation is done,"); - text.add("simply left click on the"); - text.add("table in the process."); - text.add(" A list with all the"); - text.add("possible modifiers is"); - text.add("located in a separate"); - text.add("tab."); + text = "jewellery by readding the modified version to this block and adding a different gem to it. Once the crafting is done, the current gem will be replaced by the new one. There is also a 50% chance that you will get back the old gem."; Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); break; case 13: - text.add(" This block can store"); - text.add("any jewellery in it"); - text.add("and activate their"); - text.add("effects as it were a"); - text.add("player. However, it"); - text.add("does not work with"); - text.add("everything. You can"); + text = "This block can store any jewellery in it and activate their effects as it were a player. To do that simply right click the block with a jewellery. Crouch +"; items.add(new ItemStack(BlockList.jewelAltar)); items.add(new ItemStack(Blocks.end_stone)); items.add(new ItemStack(Blocks.wool, 1, 5)); @@ -226,24 +127,11 @@ public class GuiTabBlocks extends GuiTab Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), false, text, items, x, y); break; case 14: - text.add("find out which jewellery"); - text.add("works by looking in"); - text.add("their apropriate tab."); - text.add(" Each item will have a"); - text.add("note where it is"); - text.add("mentioned their effect"); - text.add("when placed in this"); - text.add("block."); + text = "Right Click to retreive the jewellery."; Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); break; case 15: - text.add(" The Storage"); - text.add("Displayer, as the"); - text.add("name suggests, can"); - text.add("store a large amount"); - text.add("of a single item/block"); - text.add("placed in it. This will"); - text.add("display all possible"); + text = "The Storage Displayer, as the name suggests, can store a large amount (Up to: " + Integer.MAX_VALUE + ") of a single item/block placed in it. It will"; items.add(new ItemStack(BlockList.displayer)); items.add(null); items.add(new ItemStack(Items.iron_ingot)); @@ -257,28 +145,15 @@ public class GuiTabBlocks extends GuiTab Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), false, text, items, x, y); break; case 16: - text.add("infromation about the"); - text.add("object in it, such as"); - text.add("the name, durability,"); - text.add("enchantments and many"); - text.add("more. Below the name"); - text.add("is shown the amount"); - text.add("stored. To store"); - text.add("something in it simply"); - text.add("right click with that"); - text.add("object on it and the"); - text.add("whole amount of items"); - text.add("or blocks will be"); + text = "display all possible infromation about the object in it, such as the name, durability, enchantments etc. To store something in it simply right click with that object on it and the whole amount of items or blocks you are holding will be immediately stored inside."; Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); break; case 17: - text.add("immediately stored"); - text.add("inside. To retrieve"); - text.add("a single item just"); - text.add("left click the block."); - text.add("If you wish to get"); - text.add("a whole stack, just"); - text.add("crouch and left click."); + text = "If a displayer already contains an item and you have that in your inventory, you can simply hold right click on it with an empty hand to add all of your items of that type from your inventory. To retrieve a single item just left click the block. If you wish to"; + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 18: + text = "get a whole stack, Crouch + Left Click on it. In creative mode you can simply hold Right Click on a displayer containing an object and it will add 64 of it with every right click, without it being in your inventory."; Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); break; default: diff --git a/java/darkknight/jewelrycraft/container/GuiTabJewelsAndModifiers.java b/java/darkknight/jewelrycraft/container/GuiTabGemsAndIngots.java index d586348..7e9c815 100644 --- a/java/darkknight/jewelrycraft/container/GuiTabJewelsAndModifiers.java +++ b/java/darkknight/jewelrycraft/container/GuiTabGemsAndIngots.java @@ -9,11 +9,11 @@ import org.lwjgl.opengl.GL11; import darkknight.jewelrycraft.client.GuiGuide; import darkknight.jewelrycraft.util.JewelrycraftUtil; -public class GuiTabJewelsAndModifiers extends GuiTab +public class GuiTabGemsAndIngots extends GuiTab { - public GuiTabJewelsAndModifiers(int id) + public GuiTabGemsAndIngots(int id) { - super("Gems, modifiers and ingots", id); + super("Gems and ingots", id); } public ItemStack getIcon() @@ -25,41 +25,33 @@ public class GuiTabJewelsAndModifiers extends GuiTab public void drawBackground(GuiGuide gui, int x, int y, int page) { int xPos = (page % 2 == 0) ? 107 : -35; + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); for (int i = (page - 1) * 9; i < page * 9; i++) if (i < JewelrycraftUtil.gem.size()) { gui.getFont().drawString(EnumChatFormatting.DARK_BLUE + "\u00a7n" + "Gems", gui.getLeft() + xPos + 40, gui.getTop(), 0); gui.renderItem(JewelrycraftUtil.gem.get(i), gui.getLeft() + xPos + 10, gui.getTop() + 22 + 16 * (i - 9 * (page - 1)), 30f); - gui.getFont().drawString(JewelrycraftUtil.gem.get(i).getDisplayName(), gui.getLeft() + xPos + 20, gui.getTop() + 12 + 16 * (i - 9 * (page - 1)), 0); + gui.getFont().drawString(String.format("%-1.18s", JewelrycraftUtil.gem.get(i).getDisplayName()), gui.getLeft() + xPos + 20, gui.getTop() + 12 + 16 * (i - 9 * (page - 1)), 0); GL11.glDisable(GL11.GL_LIGHTING); } page -= (JewelrycraftUtil.gem.size() / 9 + 1); for (int i = (page - 1) * 9; i < page * 9; i++) { - if (i < JewelrycraftUtil.modifiers.size() && page > 0) - { - gui.getFont().drawString(EnumChatFormatting.DARK_BLUE + "\u00a7n" + "Modifiers", gui.getLeft() + xPos + 40, gui.getTop(), 0); - gui.renderItem(JewelrycraftUtil.modifiers.get(i), gui.getLeft() + xPos + 10, gui.getTop() + 22 + 16 * (i - 9 * (page - 1)), 30f); - gui.getFont().drawString(JewelrycraftUtil.modifiers.get(i).getDisplayName(), gui.getLeft() + xPos + 20, gui.getTop() + 12 + 16 * (i - 9 * (page - 1)), 0); - GL11.glDisable(GL11.GL_LIGHTING); - } - } - page -= (JewelrycraftUtil.modifiers.size() / 9 + 1); - for (int i = (page - 1) * 9; i < page * 9; i++) - { if (i < JewelrycraftUtil.metal.size() && page > 0) { gui.getFont().drawString(EnumChatFormatting.DARK_BLUE + "\u00a7n" + "Ingots", gui.getLeft() + xPos + 40, gui.getTop(), 0); gui.renderItem(JewelrycraftUtil.metal.get(i).copy(), gui.getLeft() + xPos + 10, gui.getTop() + 22 + 16 * (i - 9 * (page - 1)), 30f); - gui.getFont().drawString(JewelrycraftUtil.metal.get(i).copy().getDisplayName(), gui.getLeft() + xPos + 20, gui.getTop() + 12 + 16 * (i - 9 * (page - 1)), 0); + gui.getFont().drawString(String.format("%-1.18s", JewelrycraftUtil.metal.get(i).copy().getDisplayName()), gui.getLeft() + xPos + 20, gui.getTop() + 12 + 16 * (i - 9 * (page - 1)), 0); GL11.glDisable(GL11.GL_LIGHTING); } } + GL11.glDisable(GL11.GL_BLEND); } public int getMaxPages() { - return JewelrycraftUtil.gem.size() / 9 + JewelrycraftUtil.modifiers.size() / 9 + JewelrycraftUtil.metal.size() / 9 + 2; + return JewelrycraftUtil.gem.size() / 9 + JewelrycraftUtil.metal.size() / 9 + 2; } @Override diff --git a/java/darkknight/jewelrycraft/container/GuiTabItems.java b/java/darkknight/jewelrycraft/container/GuiTabItems.java index 60d4fb6..5950218 100644 --- a/java/darkknight/jewelrycraft/container/GuiTabItems.java +++ b/java/darkknight/jewelrycraft/container/GuiTabItems.java @@ -11,6 +11,8 @@ import net.minecraft.util.EnumChatFormatting; import darkknight.jewelrycraft.block.BlockList; import darkknight.jewelrycraft.client.GuiGuide; import darkknight.jewelrycraft.item.ItemList; +import darkknight.jewelrycraft.util.JewelryNBT; +import darkknight.jewelrycraft.util.JewelrycraftUtil; public class GuiTabItems extends GuiTab { @@ -28,31 +30,19 @@ public class GuiTabItems extends GuiTab @Override public void drawBackground(GuiGuide gui, int x, int y, int page) { - ArrayList<String> text = new ArrayList<String>(); + String text = ""; ArrayList<ItemStack> items = new ArrayList<ItemStack>(); int xPos = (page % 2 == 0) ? 107 : -35; switch (page) { case 1: - text.add(" Shadow ingots are"); - text.add("obtained by smelting"); - text.add("shadow ore. They are"); - text.add("used in a few recipes"); - text.add("and an important key"); - text.add("for making some"); - text.add("jewellery work."); + text = "Shadow ingots are obtained by smelting shadow ore. They are used in a few recipes and an important key for making some jewellery work."; items.add(new ItemStack(BlockList.shadowOre)); items.add(new ItemStack(ItemList.shadowIngot)); Page.addSmeltingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text, items, x, y); break; case 2: - text.add(" These gloves allow"); - text.add("you to steal the trades"); - text.add("the pesky Testificates"); - text.add("have to offer."); - text.add(" To use these simply"); - text.add("open their gui at least"); - text.add("once, then crouch and"); + text = "These gloves give you the chance to steal the trades those pesky Testificates have to offer. To use these simply open their gui at least once, then Crouch and"; items.add(new ItemStack(ItemList.thiefGloves)); items.add(new ItemStack(ItemList.shadowIngot)); items.add(null); @@ -66,62 +56,18 @@ public class GuiTabItems extends GuiTab Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), false, text, items, x, y); break; case 3: - text.add("right click on the them"); - text.add("to steal the trades."); - text.add("A villager has 7 of the"); - text.add("same trade item. So, for"); - text.add("example, if he wants 2"); - text.add("emeralds in exchange"); - text.add("for 4 diamonds, you will"); - text.add("get 28 diamonds from"); - text.add("him, because 7*4=28."); - text.add("However, if you have"); - text.add("traded with him before,"); - text.add("then he will have that"); + text = "right click on the them to hopefully steal the trades. If you traded with him before, then you have a chance of getting the traded emeralds back as well. This has a maximum of 10 uses before it breaks."; Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); break; case 4: - text.add("many times less of the"); - text.add("item. This has a maximum"); - text.add("of 10 uses before it"); - text.add("breaks."); - Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); - break; - case 5: - text.add(" In order to get the"); - text.add("ingot back from the"); - text.add("smelter you need a"); - text.add("mold for it. However,"); - text.add("this mold can't be used."); - text.add("It is too soft. It needs"); - text.add("to be hardened in"); - text.add("order for it to be used."); + text = "In order to get the ingot back from the smelter you need a mold for it. However, this mold can't be used. It is too soft. It needs to be hardened in order for it to be used."; items.add(new ItemStack(ItemList.clayMolds, 1, 0)); items.add(new ItemStack(Items.clay_ball)); items.add(new ItemStack(Items.clay_ball)); Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), true, text, items, x, y); break; - case 6: - text.add(" By smelting the clay_ball"); - text.add("mold you get a harder"); - text.add("version which can be"); - text.add("used to create ingots."); - text.add("Simply right click with"); - text.add("this on a molder to"); - text.add("attach it and you're"); - text.add("ready to go."); - items.add(new ItemStack(ItemList.clayMolds, 1, 0)); - items.add(new ItemStack(ItemList.molds, 1, 0)); - Page.addSmeltingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text, items, x, y); - break; - case 7: - text.add(" In order to create a"); - text.add("ring you need a mold"); - text.add("for it. However, this"); - text.add("one can't be used. It is"); - text.add("too soft. It needs to be"); - text.add("hardened in order for"); - text.add("it to be used."); + case 5: + text = "To create a ring you need a mold for it. However, this one is too soft to be used. It needs to be hardened in order for it to be used."; items.add(new ItemStack(ItemList.clayMolds, 1, 1)); items.add(null); items.add(new ItemStack(Items.clay_ball)); @@ -134,27 +80,8 @@ public class GuiTabItems extends GuiTab items.add(null); Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), false, text, items, x, y); break; - case 8: - text.add(" By smelting the clay_ball"); - text.add("mold you get a harder"); - text.add("version which can be"); - text.add("used to create rings."); - text.add("Simply right click with"); - text.add("this on a molder to"); - text.add("attach it and you're"); - text.add("ready to go."); - items.add(new ItemStack(ItemList.clayMolds, 1, 1)); - items.add(new ItemStack(ItemList.molds, 1, 1)); - Page.addSmeltingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text, items, x, y); - break; - case 9: - text.add(" In order to create a"); - text.add("necklace you need a"); - text.add("mold for it. However,"); - text.add("this one can't be used."); - text.add("It is too soft. It needs"); - text.add("to be hardened in"); - text.add("order for it to be used."); + case 6: + text = "To create a necklace you need a mold for it. However, this one can't be used. It is too soft. It needs to be hardened in order for it to be used."; items.add(new ItemStack(ItemList.clayMolds, 1, 2)); items.add(new ItemStack(Items.clay_ball)); items.add(null); @@ -167,25 +94,46 @@ public class GuiTabItems extends GuiTab items.add(null); Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), false, text, items, x, y); break; - case 10: - text.add(" By smelting the clay_ball"); - text.add("mold you get a harder"); - text.add("version which can be"); - text.add("used to create"); - text.add("necklaces. Simply right"); - text.add("click with this on a"); - text.add("molder to attach it and"); - text.add("you're ready to go."); - items.add(new ItemStack(ItemList.clayMolds, 1, 2)); - items.add(new ItemStack(ItemList.molds, 1, 2)); + case 7: + text = "To create a bracelet you need a mold for it. However, this one can't be used. It is too soft. It needs to be hardened in order for it to be used."; + items.add(new ItemStack(ItemList.clayMolds, 1, 3)); + items.add(new ItemStack(Items.clay_ball)); + items.add(new ItemStack(Items.clay_ball)); + items.add(new ItemStack(Items.clay_ball)); + items.add(new ItemStack(Items.clay_ball)); + items.add(null); + items.add(new ItemStack(Items.clay_ball)); + items.add(new ItemStack(Items.clay_ball)); + items.add(new ItemStack(Items.clay_ball)); + items.add(new ItemStack(Items.clay_ball)); + Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), false, text, items, x, y); + break; + case 8: + text = "To create a necklace you need a mold for it. However, this one can't be used. It is too soft. It needs to be hardened in order for it to be used."; + items.add(new ItemStack(ItemList.clayMolds, 1, 4)); + items.add(null); + items.add(null); + items.add(null); + items.add(new ItemStack(Items.clay_ball)); + items.add(null); + items.add(new ItemStack(Items.clay_ball)); + items.add(null); + items.add(null); + items.add(null); + Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), false, text, items, x, y); + break; + case 9: + if (del == 0) values++; + del++; + if (del >= 300) del = 0; + if (values > 4) values = 0; + text = "By smelting a clay mold you get a harder version which can be used to create jewellery. Simply right click with this on a molder to attach it and you're ready to go."; + items.add(new ItemStack(ItemList.clayMolds, 1, values)); + items.add(new ItemStack(ItemList.molds, 1, values)); Page.addSmeltingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text, items, x, y); break; - case 11: - text.add(" Crystals don't do"); - text.add("much. They can be dyed"); - text.add("in any color and used"); - text.add("as jewels to create a"); - text.add("nice jewellery."); + case 10: + text = "Crystals don't do much as of yet. They can be dyed in any color and used as gems to create a nice jewellery."; items.add(new ItemStack(ItemList.crystal, 1, 15)); items.add(null); items.add(new ItemStack(Blocks.glass)); @@ -198,7 +146,7 @@ public class GuiTabItems extends GuiTab items.add(null); Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), false, text, items, x, y); break; - case 12: + case 11: if (del == 0) values++; del++; if (del >= 300) del = 0; @@ -213,42 +161,37 @@ public class GuiTabItems extends GuiTab items.add(new ItemStack(ItemList.crystal, 1, values)); Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop() + 60, true, text, items, x, y); break; - case 13: + case 12: if (del == 0) values++; del++; if (del >= 300) del = 0; - if (values >= 3) values = 0; - text.add(" It's this exact guide."); - text.add("I don't even know why"); - text.add("you're reading this."); - text.add("I added this recipe in"); - text.add("case you lose the"); - text.add("original. In case you"); - text.add("don't have it, I suggest"); - text.add("adding NEI so you can"); + if (values > 4) values = 0; + text = "It's this exact guide. I don't even know why you're reading this. I added this recipe in case you lose the original. Even if this is more helpful than NEI, I do suggest"; items.add(new ItemStack(ItemList.guide)); items.add(new ItemStack(ItemList.molds, 1, values)); items.add(new ItemStack(Items.book)); Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), true, text, items, x, y); break; - case 14: + case 13: String link = "HERE"; - if (x >= gui.getLeft() + 138 && x <= gui.getLeft() + 168 && y >= gui.getTop() + 98 && y <= gui.getTop() + 108) link = EnumChatFormatting.DARK_BLUE + "HERE" + EnumChatFormatting.BLACK; - text.add("see all the recipes."); - text.add("Since you are reading"); - text.add("this, how about making"); - text.add("a youtube video"); - text.add("spotlighting this mod."); - text.add("I'd really appreciate it."); - text.add("After that you can"); - text.add("share it in the main"); - text.add("thread " + link + "."); - text.add(" This mod was made by"); - text.add("DarkKnight (or sor1n"); - text.add("depending from where"); - text.add("you got this)"); + if (x >= gui.getLeft() && x <= gui.getLeft() + 30 && y >= gui.getTop() + 104 && y <= gui.getTop() + 124) link = EnumChatFormatting.DARK_BLUE + "HERE" + EnumChatFormatting.BLACK; + text = "installing it so you can see all the recipes. Since you are reading this, how about making a youtube video spotlighting this mod. I'd really appreciate it. After that you can share it in the main thread " + link + "." + " This mod was made by DarkKnight (or sor1n, depends"; Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); break; + case 14: + text = "where you got this mod from) and the help of domi1819 and bspkrs."; + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 15: + ItemStack item = new ItemStack(ItemList.bucket); + if (del == 0) values++; + del++; + if (del >= 300) del = 0; + if (values > JewelrycraftUtil.metal.size() - 1) values = 0; + JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values).copy()); + text = "These buckets contain molten metal. To obtain one simply Right Click a full Smelter to get a bucket. You can pour the metal, other than that it has no use. You can place the molten metal back in a Smelter by Right Clicking one with it."; + Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop() - 5, item, text, 40f, 0, 0, true, 45, 10); + break; default: ; } @@ -256,12 +199,12 @@ public class GuiTabItems extends GuiTab public int getMaxPages() { - return 13; + return 15; } public void mouseClick(GuiGuide gui, int x, int y, int button) { - if (gui.page == 13 && x >= gui.getLeft() + 138 && x <= gui.getLeft() + 168 && y >= gui.getTop() + 98 && y <= gui.getTop() + 108) + if (gui.page == 13 && x >= gui.getLeft() && x <= gui.getLeft() + 30 && y >= gui.getTop() + 104 && y <= gui.getTop() + 124) { try { diff --git a/java/darkknight/jewelrycraft/container/GuiTabModifiers.java b/java/darkknight/jewelrycraft/container/GuiTabModifiers.java new file mode 100644 index 0000000..6a0143d --- /dev/null +++ b/java/darkknight/jewelrycraft/container/GuiTabModifiers.java @@ -0,0 +1,50 @@ +package darkknight.jewelrycraft.container; + +import java.util.ArrayList; + +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import darkknight.jewelrycraft.block.BlockList; +import darkknight.jewelrycraft.client.GuiGuide; +import darkknight.jewelrycraft.item.ItemList; + +public class GuiTabModifiers extends GuiTab +{ + public GuiTabModifiers(int id) + { + super("Modifiers", id); + } + + public ItemStack getIcon() + { + return new ItemStack(Items.blaze_powder); + } + + @Override + public void drawBackground(GuiGuide gui, int x, int y, int page) + { + String text = ""; + int xPos = (page % 2 == 0) ? 107 : -35; + switch (page) + { + case 1: + text = "This is a test to see if the program works or not! And it does seem to be working. Yaaay! Thank God I made this. This is so much easier :D"; + Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), new ItemStack(Items.blaze_powder), text, 40f); + break; + default:; + } + } + + public int getMaxPages() + { + return 1; + } + + @Override + public void drawForeground(GuiGuide gui, int x, int y, int page) + { + } + +} diff --git a/java/darkknight/jewelrycraft/container/GuiTabNecklaces.java b/java/darkknight/jewelrycraft/container/GuiTabNecklaces.java deleted file mode 100644 index 531de4a..0000000 --- a/java/darkknight/jewelrycraft/container/GuiTabNecklaces.java +++ /dev/null @@ -1,405 +0,0 @@ -package darkknight.jewelrycraft.container; - -import java.util.ArrayList; - -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; -import darkknight.jewelrycraft.client.GuiGuide; -import darkknight.jewelrycraft.item.ItemList; -import darkknight.jewelrycraft.util.JewelryNBT; -import darkknight.jewelrycraft.util.JewelrycraftUtil; - -public class GuiTabNecklaces extends GuiTab -{ - int jValues; - - public GuiTabNecklaces(int id) - { - super("Necklaces", id); - jValues = 0; - } - - public ItemStack getIcon() - { - ItemStack it = new ItemStack(ItemList.necklace); - JewelryNBT.addMetal(it, new ItemStack(Items.iron_ingot)); - JewelryNBT.addGem(it, new ItemStack(Blocks.redstone_block)); - return it; - } - - @Override - public void drawBackground(GuiGuide gui, int x, int y, int page) - { - ArrayList<String> text = new ArrayList<String>(); - ArrayList<ItemStack> gems = new ArrayList<ItemStack>(); - ItemStack item = new ItemStack(ItemList.necklace); - int xPos = (page % 2 == 0) ? 107 : -35; - switch (page) - { - case 1: - if (del == 0) values++; - del++; - if (del >= 300) del = 0; - if (values > JewelrycraftUtil.metal.size() - 1) values = 0; - - JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values).copy()); - JewelryNBT.addGem(item, new ItemStack(Items.ender_pearl)); - - text.add(EnumChatFormatting.DARK_GREEN + "gem: " + EnumChatFormatting.BLACK + "Ender Pearl"); - text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "None"); - text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Any"); - text.add(" This ring teleports"); - text.add("you and anyone around "); - text.add("in any location from the"); - text.add("same dimension. Just"); - text.add("right click once in a"); - text.add("location to se the "); - text.add("position. Then right "); - text.add("click any time you want"); - Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); - break; - case 2: - text.add("to teleport there."); - text.add(EnumChatFormatting.DARK_RED + "\u00a7nAltar Effect"); - text.add(" This teleports anyone"); - text.add("or anything that steps"); - text.add("or goes near the altar"); - text.add("to the necklaces"); - text.add("coordonates, as long"); - text.add("as that is in the same"); - text.add("dimension."); - Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); - break; - case 3: - if (del == 0) values++; - del++; - if (del >= 300) del = 0; - if (values > JewelrycraftUtil.metal.size() - 1) values = 0; - - JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values).copy()); - JewelryNBT.addGem(item, new ItemStack(Items.ender_pearl)); - JewelryNBT.addModifiers(item, JewelrycraftUtil.addRandomModifiers()); - - text.add(EnumChatFormatting.DARK_GREEN + "gem: " + EnumChatFormatting.BLACK + "Ender Pearl"); - text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "Bed"); - text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Any"); - text.add(" Just like the other"); - text.add("necklace this teleports"); - text.add("you and anybody close"); - text.add("to you to the set"); - text.add("destination. The only"); - text.add("difference is that you"); - text.add("can travel between"); - text.add("dimensions with this."); - Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); - break; - case 4: - text.add(EnumChatFormatting.DARK_RED + "\u00a7nAltar Effect"); - text.add(" This teleports anyone"); - text.add("or anything that step"); - text.add("on or around the altar"); - text.add("to the set location, with"); - text.add("the benefit of it being"); - text.add("capable of"); - text.add("inter-dimensional"); - text.add("travels."); - Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); - break; - case 5: - gems.add(null); - gems.add(new ItemStack(Items.diamond)); - gems.add(new ItemStack(Items.emerald)); - gems.add(new ItemStack(Items.nether_star)); - - if (del == 0) - { - values++; - jValues++; - } - del++; - if (del >= 300) del = 0; - if (values > JewelrycraftUtil.metal.size() - 1) values = 0; - if (jValues > gems.size() - 1) jValues = 0; - - JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values).copy()); - JewelryNBT.addGem(item, gems.get(jValues)); - JewelryNBT.addModifiers(item, JewelrycraftUtil.addRandomModifiers()); - - text.add(EnumChatFormatting.DARK_GREEN + "gem: " + EnumChatFormatting.BLACK + "None, Diamond"); - text.add("Emerald or Nether Star"); - text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "Blaze Powder"); - text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Any"); - text.add(" This necklace gives"); - text.add("you and those around"); - text.add("you " + EnumChatFormatting.DARK_RED + "Fire Resistance"); - text.add("when activated and in"); - text.add("your inventory. To"); - text.add("deactivate it simply"); - text.add("right click with it."); - Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); - break; - case 6: - text.add("Depending on the gem"); - text.add("used, you and the"); - text.add("others get " + EnumChatFormatting.DARK_RED + "Fire"); - text.add(EnumChatFormatting.DARK_RED + "Resistance" + EnumChatFormatting.BLACK + " I if you"); - text.add("haven't got any gem,"); - text.add("II for Diamond,"); - text.add("III for Emerald and"); - text.add("VIII for Nether Star."); - Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); - break; - case 7: - gems.add(null); - gems.add(new ItemStack(Items.diamond)); - gems.add(new ItemStack(Items.emerald)); - gems.add(new ItemStack(Items.nether_star)); - - if (del == 0) - { - values++; - jValues++; - } - del++; - if (del >= 300) del = 0; - if (values > JewelrycraftUtil.metal.size() - 1) values = 0; - if (jValues > gems.size() - 1) jValues = 0; - - JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values).copy()); - JewelryNBT.addGem(item, gems.get(jValues)); - JewelryNBT.addModifiers(item, JewelrycraftUtil.addRandomModifiers()); - - text.add(EnumChatFormatting.DARK_GREEN + "gem: " + EnumChatFormatting.BLACK + "None, Diamond"); - text.add("Emerald or Nether Star"); - text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "Sugar"); - text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Any"); - text.add(" This necklace gives"); - text.add("you and those around"); - text.add("you " + EnumChatFormatting.DARK_RED + "Speed" + EnumChatFormatting.BLACK + " when"); - text.add("activated and in your"); - text.add("inventory. To"); - text.add("deactivate it simply"); - text.add("right click with it."); - Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); - break; - case 8: - text.add("Depending on the gem"); - text.add("used, you and the"); - text.add("others get " + EnumChatFormatting.DARK_RED + "Speed" + EnumChatFormatting.BLACK + " I"); - text.add("if you haven't got any"); - text.add("gem, II for Diamond,"); - text.add("III for Emerald and"); - text.add("VIII for Nether Star."); - Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); - break; - case 9: - gems.add(null); - gems.add(new ItemStack(Items.diamond)); - gems.add(new ItemStack(Items.emerald)); - gems.add(new ItemStack(Items.nether_star)); - - if (del == 0) - { - values++; - jValues++; - } - del++; - if (del >= 300) del = 0; - if (values > JewelrycraftUtil.metal.size() - 1) values = 0; - if (jValues > gems.size() - 1) jValues = 0; - - JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values).copy()); - JewelryNBT.addGem(item, gems.get(jValues)); - JewelryNBT.addModifiers(item, JewelrycraftUtil.addRandomModifiers()); - - text.add(EnumChatFormatting.DARK_GREEN + "gem: " + EnumChatFormatting.BLACK + "None, Diamond"); - text.add("Emerald or Nether Star"); - text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "Iron Pickaxe"); - text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Any"); - text.add(" This necklace gives"); - text.add("you and those around"); - text.add("you " + EnumChatFormatting.DARK_RED + "Haste" + EnumChatFormatting.BLACK + " when"); - text.add("activated and in your"); - text.add("inventory. To"); - text.add("deactivate it simply"); - text.add("right click with it."); - Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); - break; - case 10: - text.add("Depending on the gem"); - text.add("used, you and the"); - text.add("others get " + EnumChatFormatting.DARK_RED + "Haste" + EnumChatFormatting.BLACK + " I"); - text.add("if you haven't got any"); - text.add("gem, II for Diamond,"); - text.add("III for Emerald and"); - text.add("VIII for Nether Star."); - Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); - break; - case 11: - gems.add(null); - gems.add(new ItemStack(Items.diamond)); - gems.add(new ItemStack(Items.emerald)); - gems.add(new ItemStack(Items.nether_star)); - - if (del == 0) - { - values++; - jValues++; - } - del++; - if (del >= 300) del = 0; - if (values > JewelrycraftUtil.metal.size() - 1) values = 0; - if (jValues > gems.size() - 1) jValues = 0; - - JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values).copy()); - JewelryNBT.addGem(item, gems.get(jValues)); - JewelryNBT.addModifiers(item, JewelrycraftUtil.addRandomModifiers()); - - text.add(EnumChatFormatting.DARK_GREEN + "gem: " + EnumChatFormatting.BLACK + "None, Diamond"); - text.add("Emerald or Nether Star"); - text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "Feather"); - text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Any"); - text.add(" This necklace gives"); - text.add("you and those around"); - text.add("you " + EnumChatFormatting.DARK_RED + "Jump Boost" + EnumChatFormatting.BLACK + " when"); - text.add("activated and in your"); - text.add("inventory. To"); - text.add("deactivate it simply"); - text.add("right click with it."); - Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); - break; - case 12: - text.add("Depending on the gem"); - text.add("used, you and the"); - text.add("others get " + EnumChatFormatting.DARK_RED + "Jump Boost"); - text.add("I if you haven't got any"); - text.add("gem, II for Diamond,"); - text.add("III for Emerald and"); - text.add("VIII for Nether Star."); - Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); - break; - case 13: - gems.add(null); - gems.add(new ItemStack(Items.diamond)); - gems.add(new ItemStack(Items.emerald)); - gems.add(new ItemStack(Items.nether_star)); - - if (del == 0) - { - values++; - jValues++; - } - del++; - if (del >= 300) del = 0; - if (values > JewelrycraftUtil.metal.size() - 1) values = 0; - if (jValues > gems.size() - 1) jValues = 0; - - JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values).copy()); - JewelryNBT.addGem(item, gems.get(jValues)); - JewelryNBT.addModifiers(item, JewelrycraftUtil.addRandomModifiers()); - - text.add(EnumChatFormatting.DARK_GREEN + "gem: " + EnumChatFormatting.BLACK + "None, Diamond"); - text.add("Emerald or Nether Star"); - text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "8min Potion of"); - text.add("Invisibility"); - text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Any"); - text.add(" This necklace gives"); - text.add("you and those around"); - text.add("you " + EnumChatFormatting.DARK_RED + "Invisibility" + EnumChatFormatting.BLACK + " when"); - text.add("activated and in your"); - text.add("inventory. To"); - text.add("deactivate it simply"); - Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); - break; - case 14: - text.add("right click with it."); - text.add("Depending on the gem"); - text.add("used, you and the"); - text.add("others get " + EnumChatFormatting.DARK_RED + "Invisibility" + EnumChatFormatting.BLACK + " I"); - text.add("if you haven't got any"); - text.add("gem, II for Diamond,"); - text.add("III for Emerald and"); - text.add("VIII for Nether Star."); - Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); - break; - case 15: - gems.add(null); - gems.add(new ItemStack(Items.diamond)); - gems.add(new ItemStack(Items.emerald)); - gems.add(new ItemStack(Items.nether_star)); - - if (del == 0) - { - values++; - jValues++; - } - del++; - if (del >= 300) del = 0; - if (values > JewelrycraftUtil.metal.size() - 1) values = 0; - if (jValues > gems.size() - 1) jValues = 0; - - JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values).copy()); - JewelryNBT.addGem(item, gems.get(jValues)); - JewelryNBT.addModifiers(item, JewelrycraftUtil.addRandomModifiers()); - - text.add(EnumChatFormatting.DARK_GREEN + "gem: " + EnumChatFormatting.BLACK + "None, Diamond"); - text.add("Emerald or Nether Star"); - text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "Bone Meal"); - text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Any"); - text.add(" This hydrates the"); - text.add("farm blocks under you"); - text.add("in a defined area. If"); - text.add("you right click with this,"); - text.add("it will help plants in"); - text.add("that area grow faster."); - text.add("The are it affects is"); - Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); - break; - case 16: - text.add("determined by the gem"); - text.add("used. For none, the"); - text.add("area is a block, diamond"); - text.add("is 3x3, emerald 5x5 and"); - text.add("nether star 11x11."); - text.add(EnumChatFormatting.DARK_RED + "\u00a7nAltar Effect"); - text.add(" In the altar, this"); - text.add("has the ability to"); - text.add("hydrate any tilted land"); - text.add("and speed up the"); - text.add("growth of plants in a"); - text.add("7x3x7 area."); - Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); - break; - case 17: - JewelryNBT.addMetal(item, new ItemStack(ItemList.shadowIngot)); - JewelryNBT.addGem(item, new ItemStack(Items.nether_star)); - JewelryNBT.addModifiers(item, JewelrycraftUtil.addRandomModifiers()); - - text.add(EnumChatFormatting.DARK_GREEN + "gem: " + EnumChatFormatting.BLACK + "Nether Star"); - text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "Diamond Pick"); - text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Shadow Ingot"); - text.add(" This will break all"); - text.add("blocks in a 3x3x1 area."); - text.add("Just right click on a"); - text.add("block and let the mining"); - text.add("begin."); - Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); - break; - default: - ; - } - } - - public int getMaxPages() - { - return 17; - } - - @Override - public void drawForeground(GuiGuide gui, int x, int y, int page) - { - } - -} diff --git a/java/darkknight/jewelrycraft/container/GuiTabRings.java b/java/darkknight/jewelrycraft/container/GuiTabRings.java deleted file mode 100644 index 1e30659..0000000 --- a/java/darkknight/jewelrycraft/container/GuiTabRings.java +++ /dev/null @@ -1,613 +0,0 @@ -package darkknight.jewelrycraft.container; - -import java.util.ArrayList; - -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; -import darkknight.jewelrycraft.client.GuiGuide; -import darkknight.jewelrycraft.item.ItemList; -import darkknight.jewelrycraft.util.JewelryNBT; -import darkknight.jewelrycraft.util.JewelrycraftUtil; - -public class GuiTabRings extends GuiTab -{ - int jValues; - - public GuiTabRings(int id) - { - super("Rings", id); - jValues = 0; - } - - public ItemStack getIcon() - { - ItemStack it = new ItemStack(ItemList.ring); - JewelryNBT.addMetal(it, new ItemStack(Items.gold_ingot)); - JewelryNBT.addGem(it, new ItemStack(Items.ender_pearl)); - return it; - } - - @Override - public void drawBackground(GuiGuide gui, int x, int y, int page) - { - ArrayList<String> text = new ArrayList<String>(); - ArrayList<ItemStack> Gems = new ArrayList<ItemStack>(); - ItemStack item = new ItemStack(ItemList.ring); - int xPos = (page % 2 == 0) ? 107 : -35; - switch (page) - { - case 1: - if (del == 0) values++; - del++; - if (del >= 300) del = 0; - if (values > JewelrycraftUtil.metal.size() - 1) values = 0; - - JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values).copy()); - JewelryNBT.addGem(item, new ItemStack(Items.ender_pearl)); - - text.add(EnumChatFormatting.DARK_GREEN + "Gem: " + EnumChatFormatting.BLACK + "Ender Pearl"); - text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "None"); - text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Any"); - text.add(" This ring allows you"); - text.add("to teleport in any"); - text.add("location from the same"); - text.add("dimension. Simply right"); - text.add("click once in a location"); - text.add("to se the position. Then"); - text.add("right click any time you"); - text.add("want to teleport there."); - Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); - break; - case 2: - text.add(EnumChatFormatting.DARK_RED + "\u00a7nAltar Effect"); - text.add(" If this ring is placed"); - text.add("in the altar and if the"); - text.add("ring has coordonates"); - text.add("memorized, then anyone"); - text.add("who steps on the block"); - text.add("will get teleported in"); - text.add("that location, as long"); - text.add("as it is in the same"); - text.add("dimension. This works"); - text.add("for other entities as"); - text.add("well, not just players."); - Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); - break; - case 3: - if (del == 0) values++; - del++; - if (del >= 300) del = 0; - if (values > JewelrycraftUtil.metal.size() - 1) values = 0; - - JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values).copy()); - JewelryNBT.addGem(item, new ItemStack(Items.ender_pearl)); - JewelryNBT.addModifiers(item, JewelrycraftUtil.addRandomModifiers()); - - text.add(EnumChatFormatting.DARK_GREEN + "Gem: " + EnumChatFormatting.BLACK + "Ender Pearl"); - text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "Bed"); - text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Any"); - text.add(" Just like the other"); - text.add("ring that had only an"); - text.add("ender pearl as a Gem,"); - text.add("by adding a bed as a"); - text.add("modifier to it you can"); - text.add("travel between"); - text.add("dimensions."); - Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); - break; - case 4: - text.add(EnumChatFormatting.DARK_RED + "\u00a7nAltar Effect"); - text.add(" Just like the other"); - text.add("one, when in the altar"); - text.add("if somebody steps on"); - text.add("the block they get"); - text.add("teleported in that spot."); - text.add("The only difference is"); - text.add("that you can teleport"); - text.add("between dimesnions with"); - text.add("this. It works for mobs"); - text.add("and other entities as"); - text.add("well."); - Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); - break; - case 5: - Gems.add(null); - Gems.add(new ItemStack(Items.diamond)); - Gems.add(new ItemStack(Items.emerald)); - Gems.add(new ItemStack(Items.nether_star)); - - if (del == 0) - { - values++; - jValues++; - } - del++; - if (del >= 300) del = 0; - if (values > JewelrycraftUtil.metal.size() - 1) values = 0; - if (jValues > Gems.size() - 1) jValues = 0; - - JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values).copy()); - JewelryNBT.addGem(item, Gems.get(jValues)); - JewelryNBT.addModifiers(item, JewelrycraftUtil.addRandomModifiers()); - - text.add(EnumChatFormatting.DARK_GREEN + "Gem: " + EnumChatFormatting.BLACK + "None, Diamond"); - text.add("Emerald or Nether Star"); - text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "Blaze Powder"); - text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Any"); - text.add(" This ring grants you"); - text.add(EnumChatFormatting.DARK_RED + "Fire Resistance" + EnumChatFormatting.BLACK + " when"); - text.add("activated and in your"); - text.add("inventory. To deactivate"); - text.add("it simply right click with"); - text.add("it. Depending on the"); - text.add("Gem you used, you"); - Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); - break; - case 6: - text.add("get " + EnumChatFormatting.DARK_RED + "Fire Resistance" + EnumChatFormatting.BLACK + " I"); - text.add("if you haven't got any"); - text.add("Gem, II for Diamond,"); - text.add("III for Emerald and"); - text.add("VIII for Nether Star."); - Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); - break; - case 7: - Gems.add(null); - Gems.add(new ItemStack(Items.diamond)); - Gems.add(new ItemStack(Items.emerald)); - Gems.add(new ItemStack(Items.nether_star)); - - if (del == 0) - { - values++; - jValues++; - } - del++; - if (del >= 300) del = 0; - if (values > JewelrycraftUtil.metal.size() - 1) values = 0; - if (jValues > Gems.size() - 1) jValues = 0; - - JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values).copy()); - JewelryNBT.addGem(item, Gems.get(jValues)); - JewelryNBT.addModifiers(item, JewelrycraftUtil.addRandomModifiers()); - - text.add(EnumChatFormatting.DARK_GREEN + "Gem: " + EnumChatFormatting.BLACK + "None, Diamond"); - text.add("Emerald or Nether Star"); - text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "Sugar"); - text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Any"); - text.add(" This ring grants you"); - text.add(EnumChatFormatting.DARK_RED + "Speed" + EnumChatFormatting.BLACK + " when activated"); - text.add("and in your inventory."); - text.add("To deactivate it simply"); - text.add("right click with it."); - text.add("Depending on the"); - text.add("Gem you used, you"); - Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); - break; - case 8: - text.add("get " + EnumChatFormatting.DARK_RED + "Speed" + EnumChatFormatting.BLACK + " I if you"); - text.add("haven't got any Gem,"); - text.add("II for Diamond,"); - text.add("III for Emerald and"); - text.add("VIII for Nether Star."); - Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); - break; - case 9: - Gems.add(null); - Gems.add(new ItemStack(Items.diamond)); - Gems.add(new ItemStack(Items.emerald)); - Gems.add(new ItemStack(Items.nether_star)); - - if (del == 0) - { - values++; - jValues++; - } - del++; - if (del >= 300) del = 0; - if (values > JewelrycraftUtil.metal.size() - 1) values = 0; - if (jValues > Gems.size() - 1) jValues = 0; - - JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values).copy()); - JewelryNBT.addGem(item, Gems.get(jValues)); - JewelryNBT.addModifiers(item, JewelrycraftUtil.addRandomModifiers()); - - text.add(EnumChatFormatting.DARK_GREEN + "Gem: " + EnumChatFormatting.BLACK + "None, Diamond"); - text.add("Emerald or Nether Star"); - text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "Iron Pickaxe"); - text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Any"); - text.add(" This ring grants you"); - text.add(EnumChatFormatting.DARK_RED + "Haste" + EnumChatFormatting.BLACK + " when activated"); - text.add("and in your inventory."); - text.add("To deactivate it simply"); - text.add("right click with it."); - text.add("Depending on the"); - text.add("Gem you used, you"); - Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); - break; - case 10: - text.add("get " + EnumChatFormatting.DARK_RED + "Haste" + EnumChatFormatting.BLACK + " I if you"); - text.add("haven't got any Gem,"); - text.add("II for Diamond,"); - text.add("III for Emerald and"); - text.add("VIII for Nether Star."); - Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); - break; - case 11: - Gems.add(null); - Gems.add(new ItemStack(Items.diamond)); - Gems.add(new ItemStack(Items.emerald)); - Gems.add(new ItemStack(Items.nether_star)); - - if (del == 0) - { - values++; - jValues++; - } - del++; - if (del >= 300) del = 0; - if (values > JewelrycraftUtil.metal.size() - 1) values = 0; - if (jValues > Gems.size() - 1) jValues = 0; - - JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values).copy()); - JewelryNBT.addGem(item, Gems.get(jValues)); - JewelryNBT.addModifiers(item, JewelrycraftUtil.addRandomModifiers()); - - text.add(EnumChatFormatting.DARK_GREEN + "Gem: " + EnumChatFormatting.BLACK + "None, Diamond"); - text.add("Emerald or Nether Star"); - text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "Feather"); - text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Any"); - text.add(" This ring grants you"); - text.add(EnumChatFormatting.DARK_RED + "Jump Boost" + EnumChatFormatting.BLACK + " when"); - text.add("activated and in your"); - text.add("inventory, as well as"); - text.add("remove any fall damage."); - text.add("To deactivate it simply"); - text.add("right click with it."); - Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); - break; - case 12: - text.add("Depending on the Gem"); - text.add("you used, you get"); - text.add(EnumChatFormatting.DARK_RED + "Jump Boost" + EnumChatFormatting.BLACK + " I if you"); - text.add("haven't got any Gem,"); - text.add("II for Diamond,"); - text.add("III for Emerald and"); - text.add("VIII for Nether Star."); - Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); - break; - case 13: - Gems.add(null); - Gems.add(new ItemStack(Items.diamond)); - Gems.add(new ItemStack(Items.emerald)); - Gems.add(new ItemStack(Items.nether_star)); - - if (del == 0) - { - values++; - jValues++; - } - del++; - if (del >= 300) del = 0; - if (values > JewelrycraftUtil.metal.size() - 1) values = 0; - if (jValues > Gems.size() - 1) jValues = 0; - - JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values).copy()); - JewelryNBT.addGem(item, Gems.get(jValues)); - JewelryNBT.addModifiers(item, JewelrycraftUtil.addRandomModifiers()); - - text.add(EnumChatFormatting.DARK_GREEN + "Gem: " + EnumChatFormatting.BLACK + "None, Diamond"); - text.add("Emerald or Nether Star"); - text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "8min Potion of"); - text.add("Invisibility"); - text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Any"); - text.add(" This ring grants you"); - text.add(EnumChatFormatting.DARK_RED + "Invisibility" + EnumChatFormatting.BLACK + " when"); - text.add("activated and in your"); - text.add("inventory, as well as"); - text.add("remove any fall damage."); - text.add("To deactivate it simply"); - Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); - break; - case 14: - text.add("right click with it."); - text.add("Depending on the Gem"); - text.add("you used, you get"); - text.add(EnumChatFormatting.DARK_RED + "Invisibility" + EnumChatFormatting.BLACK + " I if you"); - text.add("haven't got any Gem,"); - text.add("II for Diamond,"); - text.add("III for Emerald and"); - text.add("VIII for Nether Star."); - Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); - break; - case 15: - if (del == 0) values++; - del++; - if (del >= 300) del = 0; - if (values > JewelrycraftUtil.metal.size() - 1) values = 0; - - JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values).copy()); - JewelryNBT.addGem(item, new ItemStack(Items.nether_star)); - JewelryNBT.addModifiers(item, JewelrycraftUtil.addRandomModifiers()); - - text.add(EnumChatFormatting.DARK_GREEN + "Gem: " + EnumChatFormatting.BLACK + "Nether Star"); - text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "Book"); - text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Any"); - text.add(" This has the power"); - text.add("to " + EnumChatFormatting.DARK_PURPLE + "Enchant" + EnumChatFormatting.BLACK + ", " + EnumChatFormatting.DARK_PURPLE + "Disenchant" + EnumChatFormatting.BLACK + ""); - text.add("or even" + EnumChatFormatting.DARK_PURPLE + " Transfer"); - text.add(EnumChatFormatting.DARK_PURPLE + "Enchantments" + EnumChatFormatting.BLACK + ". To"); - text.add("change its mode simply"); - text.add("right click it. However,"); - text.add("this ring only works"); - text.add("when it is being held."); - Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); - break; - case 16: - text.add(EnumChatFormatting.DARK_PURPLE + "\u00a7nDisenchanting" + EnumChatFormatting.BLACK + ""); - text.add(" If the ring is held"); - text.add("and an enchanted item"); - text.add("is placed beside it in"); - text.add("the hotbar, the ring"); - text.add("will remove all the"); - text.add("enchantments from the"); - text.add("item and store them in"); - text.add("enchanted books, which"); - text.add("are placed in your"); - text.add("inventory. Be careful"); - text.add("however, because if"); - Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); - break; - case 17: - text.add("there is no room in"); - text.add("your inventory for the"); - text.add("books, the enchantments"); - text.add("will go in the void with"); - text.add("no way of recovering"); - text.add("them. Unfortunately,"); - text.add("disenchanting is not"); - text.add("free. It requires 2"); - text.add("levels of experience"); - text.add("per ench and some of"); - text.add("your blood. It will also"); - text.add("damage the item a bit."); - Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); - break; - case 18: - text.add(EnumChatFormatting.DARK_PURPLE + "\u00a7nEnchanting" + EnumChatFormatting.BLACK + ""); - text.add(" This mode allows you"); - text.add("to give a random"); - text.add("enchantment to an item"); - text.add("that can hold"); - text.add("enchantments in the"); - text.add("first place. However,"); - text.add("each enchanting comes"); - text.add("with a cost. The player"); - text.add("is required to have at"); - text.add("least 1 level of xp."); - text.add("The higher the number"); - Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); - break; - case 19: - text.add("the better, as the level"); - text.add("of the enchantment will"); - text.add("be equal with the amount"); - text.add("of levels, but this value"); - text.add("can never go over 6."); - text.add("This gives allows people"); - text.add("to get an enchantment"); - text.add("of a higher value than"); - text.add("normal (5 being the"); - text.add("limit normally)."); - Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); - break; - case 20: - text.add(EnumChatFormatting.DARK_PURPLE + "\u00a7nEnchantment Transfer" + EnumChatFormatting.BLACK + ""); - text.add(" This mode is very"); - text.add("special as it lets you"); - text.add("transfer enchantments"); - text.add("from an item or block to"); - text.add("another, not caring if"); - text.add("the item/block can"); - text.add("actually hold enchants."); - text.add("Just place the ench"); - text.add("item on the left of the"); - text.add("ring and to the right of"); - text.add("the ring, the item you"); - Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); - break; - case 21: - text.add("want to transfer the"); - text.add("enchs to. The ring can"); - text.add("only transfer an ench"); - text.add("at a time, after each"); - text.add("transfer it requiring a"); - text.add("cooldown."); - text.add(EnumChatFormatting.DARK_RED + " Again, this ring only"); - text.add(EnumChatFormatting.DARK_RED + "works when it is in the"); - text.add(EnumChatFormatting.DARK_RED + "players hotbar and"); - text.add(EnumChatFormatting.DARK_RED + "being held!"); - Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); - break; - case 22: - if (del == 0) values++; - del++; - if (del >= 300) del = 0; - if (values > JewelrycraftUtil.metal.size() - 1) values = 0; - - JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values).copy()); - JewelryNBT.addGem(item, new ItemStack(Items.ender_pearl)); - JewelryNBT.addModifiers(item, JewelrycraftUtil.addRandomModifiers()); - - text.add(EnumChatFormatting.DARK_GREEN + "Gem: " + EnumChatFormatting.BLACK + "Ender Pearl"); - text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "Chest"); - text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Any"); - text.add(" This ring can link"); - text.add("to any chest and"); - text.add("access its inventory."); - text.add("To link to a chest just"); - text.add("crouch and right click"); - text.add("on the one you want."); - text.add("Then right click again"); - text.add("to open that inventory."); - Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); - break; - case 23: - text.add("This only works if you"); - text.add("are in range to the"); - text.add("chest. You can go"); - text.add("about 128 blocks"); - text.add("before it stops"); - text.add("working. After that"); - text.add("a message will be"); - text.add("displayed saying the"); - text.add("amount of blocks you"); - text.add("need to be closer in"); - text.add("order for it to work"); - text.add("again."); - Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); - break; - case 24: - if (del == 0) values++; - del++; - if (del >= 300) del = 0; - if (values > JewelrycraftUtil.metal.size() - 1) values = 0; - - JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values).copy()); - JewelryNBT.addGem(item, new ItemStack(Blocks.obsidian)); - JewelryNBT.addModifiers(item, JewelrycraftUtil.addRandomModifiers()); - - text.add(EnumChatFormatting.DARK_GREEN + "Gem: " + EnumChatFormatting.BLACK + "Obsidian"); - text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "Eye of Ender"); - text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Any"); - text.add(" This ring is connected"); - text.add("to your ender chest."); - text.add("Just right click it"); - text.add("anywhere to open the"); - text.add("ender chest gui."); - Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); - break; - case 25: - if (del == 0) values++; - del++; - if (del >= 300) del = 0; - if (values > JewelrycraftUtil.metal.size() - 1) values = 0; - - JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values).copy()); - JewelryNBT.addGem(item, new ItemStack(Items.nether_star)); - JewelryNBT.addModifiers(item, JewelrycraftUtil.addRandomModifiers()); - - text.add(EnumChatFormatting.DARK_GREEN + "Gem: " + EnumChatFormatting.BLACK + "Nether Star"); - text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "Chest"); - text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Any"); - text.add(" This ring can store"); - text.add("any entity in it. To do"); - text.add("that right click an"); - text.add("to store it in the ring"); - text.add("(crouch and right click"); - text.add("if right clicking the"); - text.add("entity opens a GUI,"); - text.add("such as villagers)."); - Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); - break; - case 26: - text.add("Right click again on the"); - text.add("ground to release the"); - text.add("entity in that spot."); - Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); - break; - case 27: - if (del == 0) - { - values++; - jValues++; - } - del++; - if (del >= 300) del = 0; - if (values > JewelrycraftUtil.metal.size() - 1) values = 0; - if (jValues > JewelrycraftUtil.gem.size() - 1) jValues = 0; - - JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values).copy()); - JewelryNBT.addGem(item, JewelrycraftUtil.gem.get(jValues).copy()); - JewelryNBT.addModifiers(item, JewelrycraftUtil.addRandomModifiers()); - - text.add(EnumChatFormatting.DARK_GREEN + "Gem: " + EnumChatFormatting.BLACK + "Any"); - text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "Bone Meal"); - text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Any"); - text.add(" While having it in"); - text.add("the inventory it will"); - text.add("hydrate any farmland"); - text.add("you step on. If you"); - text.add("right click with this"); - text.add("on a plant, it will"); - text.add("speed up the growth a"); - text.add("bit. Better keep right"); - Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); - break; - case 28: - text.add("clicking if you want to"); - text.add("see an actual effect."); - text.add(EnumChatFormatting.DARK_RED + "\u00a7nAltar Effect"); - text.add(" In the altar, the ring"); - text.add("has the ability to"); - text.add("hydrate any tilted land"); - text.add("and speed up the"); - text.add("growth of plants in a"); - text.add("3x3x3 area."); - Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); - break; - case 29: - if (del == 0) values++; - del++; - if (del >= 300) del = 0; - if (values > JewelrycraftUtil.metal.size() - 1) values = 0; - - JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values).copy()); - JewelryNBT.addGem(item, new ItemStack(Items.ender_pearl)); - JewelryNBT.addModifiers(item, JewelrycraftUtil.addRandomModifiers()); - - text.add(EnumChatFormatting.DARK_GREEN + "Gem: " + EnumChatFormatting.BLACK + "Ender Pearl"); - text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "Diamond Pick"); - text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Any"); - text.add(" You can right click"); - text.add("any block (or crouch"); - text.add("right click) to store"); - text.add("that block inside it."); - text.add("Right click on the"); - text.add("ground to place it"); - text.add("there. It can also"); - text.add("create golems/withers."); - Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); - break; - case 30: - JewelryNBT.addMetal(item, new ItemStack(ItemList.shadowIngot)); - JewelryNBT.addGem(item, new ItemStack(Items.nether_star)); - JewelryNBT.addModifiers(item, JewelrycraftUtil.addRandomModifiers()); - - text.add(EnumChatFormatting.DARK_GREEN + "Gem: " + EnumChatFormatting.BLACK + "Nether Star"); - text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "Diamond Pick"); - text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Shadow Ingot"); - text.add(" Right clicking with"); - text.add("this on any block will"); - text.add("cause that block to"); - text.add("break instantly."); - Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); - break; - default: - ; - } - } - - public int getMaxPages() - { - return 30; - } - - @Override - public void drawForeground(GuiGuide gui, int x, int y, int page) - { - } - -} diff --git a/java/darkknight/jewelrycraft/container/Page.java b/java/darkknight/jewelrycraft/container/Page.java index 77a0fa2..69de204 100644 --- a/java/darkknight/jewelrycraft/container/Page.java +++ b/java/darkknight/jewelrycraft/container/Page.java @@ -1,20 +1,24 @@ package darkknight.jewelrycraft.container; import java.util.ArrayList; - -import org.lwjgl.opengl.GL11; +import java.util.List; import net.minecraft.client.Minecraft; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; + import darkknight.jewelrycraft.client.GuiGuide; public class Page { - public static void addCraftingRecipeTextPage(GuiGuide gui, int x, int y, boolean isSmall, ArrayList<String> text, ArrayList<ItemStack> items, int mouseX, int mouseY) + public static void addCraftingRecipeTextPage(GuiGuide gui, int x, int y, boolean isSmall, String text, ArrayList<ItemStack> items, int mouseX, int mouseY) { y += 5; + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); gui.getFont().drawString(EnumChatFormatting.DARK_BLUE + "\u00a7n" + items.get(0).getDisplayName(), x + Math.abs(70 - gui.getFont().getStringWidth(items.get(0).getDisplayName()) / 2) - 10, y - 2, 0); GL11.glColor4f(1, 1, 1, 1); Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("jewelrycraft", "textures/gui/guidePageFlip.png")); @@ -27,7 +31,9 @@ public class Page if (items.size() > 1 && items.get(1) != null) { gui.renderItem(items.get(1), x + 8, y + 16 + 10, 30f); - if (x - gui.getLeft() >= x + 8) gui.drawHoverString(text, x, y); + List<String> list = new ArrayList<String>(); + list.add(text); + if (x - gui.getLeft() >= x + 8) gui.drawHoverString(list, x, y); name.add(items.get(1).getDisplayName()); if (mouseX >= x && mouseX <= x + 16 && mouseY >= y + 10 && mouseY <= y + 26) gui.drawHoverString(name, x - 8, y + 10); name.removeAll(name); @@ -57,12 +63,11 @@ public class Page name.removeAll(name); GL11.glDisable(GL11.GL_LIGHTING); } - for (int i = 0; i < text.size(); i++) - gui.getFont().drawString(text.get(i), x, y + 55 + i * 12, 0); + drawText(gui, text, x, y + 25); } else { - gui.drawTexturedModalRect(x, y + 10, 145, 0, 111, 54); + gui.drawTexturedModalRect(x, y + 12, 145, 0, 111, 54); gui.renderItem(items.get(0), x + 91, y + 28 + 10, 30f); if (items.size() > 1 && items.get(1) != null) { @@ -114,80 +119,103 @@ public class Page } if (items.size() > 7 && items.get(7) != null) { - gui.renderItem(items.get(7), x + 8, y + 57, 30f); + gui.renderItem(items.get(7), x + 8, y + 54, 30f); name.add(items.get(7).getDisplayName()); - if (mouseX >= x && mouseX <= x + 16 && mouseY >= y + 47 && mouseY <= y + 47 + 16) gui.drawHoverString(name, x + 8, y + 47); + if (mouseX >= x && mouseX <= x + 16 && mouseY >= y + 44 && mouseY <= y + 44 + 16) gui.drawHoverString(name, x + 8, y + 44); name.removeAll(name); GL11.glDisable(GL11.GL_LIGHTING); } if (items.size() > 8 && items.get(8) != null) { - gui.renderItem(items.get(8), x + 28, y + 57, 30f); + gui.renderItem(items.get(8), x + 28, y + 54, 30f); name.add(items.get(8).getDisplayName()); - if (mouseX >= x + 20 && mouseX <= x + 16 + 20 && mouseY >= y + 47 && mouseY <= y + 47 + 16) gui.drawHoverString(name, x + 28, y + 47); + if (mouseX >= x + 20 && mouseX <= x + 16 + 20 && mouseY >= y + 44 && mouseY <= y + 44 + 16) gui.drawHoverString(name, x + 28, y + 44); name.removeAll(name); GL11.glDisable(GL11.GL_LIGHTING); } if (items.size() > 9 && items.get(9) != null) { - gui.renderItem(items.get(9), x + 45, y + 57, 30f); + gui.renderItem(items.get(9), x + 45, y + 54, 30f); name.add(items.get(9).getDisplayName()); - if (mouseX >= x + 40 && mouseX <= x + 16 + 40 && mouseY >= y + 47 && mouseY <= y + 47 + 16) gui.drawHoverString(name, x + 45, y + 47); + if (mouseX >= x + 40 && mouseX <= x + 16 + 40 && mouseY >= y + 44 && mouseY <= y + 44 + 16) gui.drawHoverString(name, x + 45, y + 44); name.removeAll(name); GL11.glDisable(GL11.GL_LIGHTING); } - for (int i = 0; i < text.size(); i++) - gui.getFont().drawString(text.get(i), x, y + 62 + i * 12, 0); + drawText(gui, text, x, y + 32); GL11.glColor4f(1, 1, 1, 1); } + GL11.glDisable(GL11.GL_BLEND); } - public static void addSmeltingRecipeTextPage(GuiGuide gui, int x, int y, ArrayList<String> text, ArrayList<ItemStack> items, int mouseX, int mouseY) + public static void addSmeltingRecipeTextPage(GuiGuide gui, int x, int y, String text, ArrayList<ItemStack> items, int mouseX, int mouseY) { ArrayList<String> name = new ArrayList<String>(); - gui.getFont().drawString(EnumChatFormatting.DARK_BLUE + "\u00a7n" + items.get(1).getDisplayName(), x + Math.abs(70 - gui.getFont().getStringWidth(items.get(0).getDisplayName()) / 2), y + 2, 0); + gui.getFont().drawString(EnumChatFormatting.DARK_BLUE + "\u00a7n" + items.get(1).getDisplayName(), x + 30 - items.get(0).getDisplayName().length() / 2, y + 2, 0); GL11.glColor4f(1, 1, 1, 1); Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("jewelrycraft", "textures/gui/guidePageFlip" + ".png")); - gui.drawTexturedModalRect(x, y + 10, 145, 100, 111, 46); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + gui.drawTexturedModalRect(x, y + 10, 145, 100, 111, 56); - gui.renderItem(items.get(0), x + 13, y + 20 + 10, 50f); + gui.renderItem(items.get(0), x + 13, y + 20 + 10, 35f); name.add(items.get(0).getDisplayName()); if (mouseX >= x && mouseX <= x + 20 && mouseY >= y + 20 && mouseY <= y + 20 + 16) gui.drawHoverString(name, x, y + 20); name.removeAll(name); GL11.glDisable(GL11.GL_LIGHTING); - gui.renderItem(items.get(1), x + 77, y + 28 + 10, 50f); - - for (int i = 0; i < text.size(); i++) - gui.getFont().drawString(text.get(i), x, y + 60 + i * 12, 0); + gui.renderItem(items.get(1), x + 77, y + 28 + 10, 35f); + drawText(gui, text, x, y + 30); GL11.glColor4f(1, 1, 1, 1); + GL11.glDisable(GL11.GL_BLEND); } - public static void addImageTextPage(GuiGuide gui, int x, int y, ItemStack item, ArrayList<String> text, float size) + public static void addImageTextPage(GuiGuide gui, int x, int y, ItemStack item, String text, float size) { y += 5; + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); gui.getFont().drawString(EnumChatFormatting.DARK_BLUE + "\u00a7n" + item.getDisplayName(), x + Math.abs(70 - gui.getFont().getStringWidth(item.getDisplayName()) / 2) - 10, y + 2, 0); GL11.glColor4f(1, 1, 1, 1); gui.renderItem(item, x + 13, y + 18, size); - for (int i = 0; i < text.size(); i++) - gui.getFont().drawString(text.get(i), x, y + 30 + i * 12, 0); + drawText(gui, text, x, y); + GL11.glDisable(GL11.GL_BLEND); } - public static void addImageTextPage(GuiGuide gui, int x, int y, ItemStack item, ArrayList<String> text, float size, int txtX, int txtY, boolean showName, int imgX, int imgY) + public static void addImageTextPage(GuiGuide gui, int x, int y, ItemStack item, String text, float size, int txtX, int txtY, boolean showName, int imgX, int imgY) { y += 5; + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); if (showName) gui.getFont().drawString(EnumChatFormatting.DARK_BLUE + "\u00a7n" + item.getDisplayName(), x + Math.abs(70 - gui.getFont().getStringWidth(item.getDisplayName()) / 2) - 10, y + 2, 0); GL11.glColor4f(1, 1, 1, 1); gui.renderItem(item, x + 13 + imgX, y + 18 + imgY, size); - for (int i = 0; i < text.size(); i++) - gui.getFont().drawString(text.get(i), x + txtX, y + 30 + txtY + i * 12, 0); + drawText(gui, text, x + txtX, y + txtY); + GL11.glDisable(GL11.GL_BLEND); } - public static void addTextPage(GuiGuide gui, int x, int y, ArrayList<String> text) + public static void addTextPage(GuiGuide gui, int x, int y, String text) { y -= 25; - for (int i = 0; i < text.size(); i++) - gui.getFont().drawString(text.get(i), x, y + 30 + i * 12, 0); + drawText(gui, text, x, y); GL11.glColor4f(1, 1, 1, 1); } + + public static void drawText(GuiGuide gui, String text, int x, int y) + { + String[] s = text.split(" "); + String displayText = ""; + ArrayList<String> textLines = new ArrayList<String>(); + for (int i = 0; i < s.length; i++) + { + if ((displayText + s[i] + " ").length() <= 24) displayText += s[i] + " "; + else + { + textLines.add(displayText.trim()); + displayText = s[i] + " "; + } + } + textLines.add(displayText.trim()); + for (int i = 0; i < textLines.size(); i++) + gui.getFont().drawString(textLines.get(i), x, y + 30 + i * 12, 0); + } } diff --git a/java/darkknight/jewelrycraft/events/BucketHandler.java b/java/darkknight/jewelrycraft/events/BucketHandler.java index 6eef59b..a7b40cd 100644 --- a/java/darkknight/jewelrycraft/events/BucketHandler.java +++ b/java/darkknight/jewelrycraft/events/BucketHandler.java @@ -44,8 +44,7 @@ public class BucketHandler } private ItemStack fillCustomBucket(World world, MovingObjectPosition pos) - { - + { Block block = world.getBlock(pos.blockX, pos.blockY, pos.blockZ); Item bucket = buckets.get(block); @@ -57,13 +56,14 @@ public class BucketHandler if (ingotData != null && ingotData != "") { String[] splitData = ingotData.split(":"); - if (splitData.length == 2) + if (splitData.length == 3) { - int itemID, itemDamage; + int itemID, itemDamage, color; try { itemID = Integer.parseInt(splitData[0]); itemDamage = Integer.parseInt(splitData[1]); + color = Integer.parseInt(splitData[2]); JewelryNBT.addMetal(item, new ItemStack(Item.getItemById(itemID), 1, itemDamage)); } catch (Exception e) diff --git a/java/darkknight/jewelrycraft/events/EntityEventHandler.java b/java/darkknight/jewelrycraft/events/EntityEventHandler.java index c791d74..7229318 100644 --- a/java/darkknight/jewelrycraft/events/EntityEventHandler.java +++ b/java/darkknight/jewelrycraft/events/EntityEventHandler.java @@ -16,6 +16,7 @@ import net.minecraftforge.client.event.EntityViewRenderEvent; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.entity.living.LivingDeathEvent; import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; +import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.event.world.WorldEvent; import org.lwjgl.opengl.GL11; @@ -25,10 +26,9 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import darkknight.jewelrycraft.JewelrycraftMod; -import darkknight.jewelrycraft.container.JewelryInventory; import darkknight.jewelrycraft.item.ItemList; -import darkknight.jewelrycraft.lib.Reference; import darkknight.jewelrycraft.network.PacketClearColorCache; +import darkknight.jewelrycraft.network.PacketRequestPlayerInfo; import darkknight.jewelrycraft.util.BlockUtils; import darkknight.jewelrycraft.util.JewelrycraftUtil; import darkknight.jewelrycraft.util.PlayerUtils; @@ -56,100 +56,76 @@ public class EntityEventHandler if (shouldGiveManual) { ItemStack manual = new ItemStack(ItemList.guide); - if (!player.inventory.addItemStackToInventory(manual)) - { - BlockUtils.dropItemStackInWorld(player.worldObj, player.posX, player.posY, player.posZ, manual); - } + if (!player.inventory.addItemStackToInventory(manual)) BlockUtils.dropItemStackInWorld(player.worldObj, player.posX, player.posY, player.posZ, manual); persistTag.setBoolean("givenGuide", true); } boolean render = persistTag.getBoolean("fancyRender"); JewelrycraftMod.fancyRender = render; - // System.out.println("FancyRender: " + JewelrycraftMod.fancyRender - // + " Render:" + render); } + JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo()); } @SubscribeEvent public void onEntityUpdate(LivingUpdateEvent event) { final Entity entity = event.entity; - if (!entity.worldObj.isRemote && entity instanceof EntityPlayer) + if (entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) entity; - NBTTagCompound persistTag = PlayerUtils.getModPlayerPersistTag(player, "Jewelrycraft"); - for (String l : JewelrycraftUtil.curses.keySet()) - if (!persistTag.hasKey(l) || player.getHealth() >= 19F) persistTag.setInteger(l, -1); - if (!player.isDead && player.getHealth() > 0F && player.getHealth() < 19F) persistTag.setInteger(Reference.MODNAME + ":" + "Blind", 0); - // boolean render = persistTag.getBoolean("fancyRender"); - // System.out.println("FancyRender: " + JewelrycraftMod.fancyRender - // + " Render:" + render); - // circle(player.worldObj, player.posX, player.posY, player.posZ, - // 4); + NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, "Jewelrycraft"); + playerInfo.setBoolean("fancyRender", JewelrycraftMod.fancyRender); + if (!player.worldObj.isRemote) + { +// System.out.println(playerInfo.getInteger("curseTime") + " " + playerInfo.getBoolean("reselectCurses")); + if (playerInfo.hasKey("reselectCurses") && !playerInfo.getBoolean("reselectCurses")) + { + playerInfo.setInteger("curseTime", playerInfo.getInteger("curseTime") - 100); + if (playerInfo.getInteger("curseTime") <= 0) playerInfo.setBoolean("reselectCurses", true); + } + } } - if (entity instanceof EntityPlayer) + } + + @SubscribeEvent + public void onPlayerRespawn(PlayerEvent.Clone event) + { + EntityPlayer player = event.entityPlayer; + if (!player.worldObj.isRemote) { - EntityPlayer player = (EntityPlayer) entity; - NBTTagCompound persistTag = PlayerUtils.getModPlayerPersistTag(player, "Jewelrycraft"); - persistTag.setBoolean("fancyRender", JewelrycraftMod.fancyRender); + NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, "Jewelrycraft"); + if (playerInfo.hasKey("cursePoints") && playerInfo.getInteger("cursePoints") > 0) + { + int points = playerInfo.getInteger("cursePoints"); + addCurse(player, playerInfo, "curse1"); + if (points > 50) addCurse(player, playerInfo, "curse2"); + if(!playerInfo.hasKey("curseTime") || !playerInfo.hasKey("reselectCurses") || playerInfo.getBoolean("reselectCurses")) + { + playerInfo.setInteger("curseTime", 23000); + playerInfo.setBoolean("reselectCurses", false); + } + } } + JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo()); } - // public static void circle(World world, double x, double y, double z, int - // radius) - // { - // for (int i = 0; i < radius; i++) - // for (int j = 0; j < radius; j++) - // for (int k = 0; k < radius; k++) - // { - // double distance = (radius - i) * (radius - i) + (radius - j) * (radius - - // j) + (radius - k) * (radius - k); - // - // if (distance - 1 == (radius * radius) || distance - 2 == (radius * - // radius)) - // { - // Minecraft.getMinecraft().effectRenderer.addEffect(new - // EntityShadowsFX(world, x + i - radius + 1F, y + j - radius / 2 - 1.5f, z - // + k - radius + 1F, 2F, 0.05F)); - // Minecraft.getMinecraft().effectRenderer.addEffect(new - // EntityShadowsFX(world, x - i + radius - 1F, y + j - radius / 2 - 1.5f, z - // + k - radius + 1F, 2F, 0.05F)); - // - // Minecraft.getMinecraft().effectRenderer.addEffect(new - // EntityShadowsFX(world, x + i - radius + 1F, y + j - radius / 2 - 1.5f, z - // - k + radius - 1F, 2F, 0.05F)); - // Minecraft.getMinecraft().effectRenderer.addEffect(new - // EntityShadowsFX(world, x - i + radius - 1F, y + j - radius / 2 - 1.5f, z - // - k + radius - 1F, 2F, 0.05F)); - // } - // } - // - // for (int i = 0; i < radius; i++) - // for (int j = radius - 1; j >= 0; j--) - // for (int k = 0; k < radius; k++) - // { - // double distance = (radius - i) * (radius - i) + (radius - j) * (radius - - // j) + (radius - k) * (radius - k); - // - // if (distance - 1 == (radius * radius) || distance - 2 == (radius * - // radius)) - // { - // Minecraft.getMinecraft().effectRenderer.addEffect(new - // EntityShadowsFX(world, x + i - radius + 1F, y - j + radius / 2 + 0.5f, z - // + k - radius + 1F, 2F, 0.05F)); - // Minecraft.getMinecraft().effectRenderer.addEffect(new - // EntityShadowsFX(world, x - i + radius - 1F, y - j + radius / 2 + 0.5f, z - // + k - radius + 1F, 2F, 0.05F)); - // - // Minecraft.getMinecraft().effectRenderer.addEffect(new - // EntityShadowsFX(world, x + i - radius + 1F, y - j + radius / 2 + 0.5f, z - // - k + radius - 1F, 2F, 0.05F)); - // Minecraft.getMinecraft().effectRenderer.addEffect(new - // EntityShadowsFX(world, x - i + radius - 1F, y - j + radius / 2 + 0.5f, z - // - k + radius - 1F, 2F, 0.05F)); - // } - // } - // } + public void addCurse(EntityPlayer player, NBTTagCompound playerInfo, String curse) + { + if ((!playerInfo.hasKey(curse) || playerInfo.getInteger(curse) == -1) && JewelrycraftUtil.availableCurseNames.size() > 0) + { + String name = JewelrycraftUtil.availableCurseNames.get(JewelrycraftUtil.rand.nextInt(JewelrycraftUtil.availableCurseNames.size())); + int grade = player.worldObj.rand.nextInt(2); + playerInfo.setByte(name, (byte) grade); + JewelrycraftUtil.availableCurseNames.remove(JewelrycraftUtil.curseValues.get(name)); + playerInfo.setInteger(curse, grade); + } + } + + @SubscribeEvent + public void playerFileSave(PlayerEvent.SaveToFile event) + { + JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo()); + } @SubscribeEvent public void onEntityDead(LivingDeathEvent event) @@ -158,10 +134,19 @@ public class EntityEventHandler if (!entity.worldObj.isRemote && entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) entity; - NBTTagCompound persistTag = PlayerUtils.getModPlayerPersistTag(player, "Jewelrycraft"); - for (String l : JewelrycraftUtil.curses.keySet()) - if (persistTag.getInteger(l) == 0) persistTag.setInteger(l, -1); + NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, "Jewelrycraft"); + if (playerInfo.hasKey("reselectCurses") && playerInfo.getBoolean("reselectCurses")) + { + for (String l : JewelrycraftUtil.curseValues.keySet()) + if (playerInfo.getInteger(l) == 0 || playerInfo.getInteger("Deaths") == 2) playerInfo.setByte(l, (byte) -1); + for (int i = 1; i <= 2; i++) + if ((playerInfo.hasKey(("curse" + i).toString()) && playerInfo.getInteger(("curse" + i).toString()) == 0) || playerInfo.getInteger("Deaths") == 2) playerInfo.setInteger(("curse" + i).toString(), -1); + JewelrycraftUtil.availableCurseNames.putAll(JewelrycraftUtil.curseNames); + } + if (!playerInfo.hasKey("Deaths") || playerInfo.getInteger("Deaths") == 2) playerInfo.setInteger("Deaths", 0); + playerInfo.setInteger("Deaths", playerInfo.getInteger("Deaths") + 1); } + JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo()); } @SubscribeEvent @@ -196,6 +181,7 @@ public class EntityEventHandler e.printStackTrace(); } } + JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo()); } diff --git a/java/darkknight/jewelrycraft/events/ScreenHandler.java b/java/darkknight/jewelrycraft/events/ScreenHandler.java index 300968a..237a452 100644 --- a/java/darkknight/jewelrycraft/events/ScreenHandler.java +++ b/java/darkknight/jewelrycraft/events/ScreenHandler.java @@ -1,8 +1,11 @@ package darkknight.jewelrycraft.events; +import java.awt.Color; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiChat; +import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.settings.KeyBinding; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; @@ -11,6 +14,7 @@ import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.registry.ClientRegistry; @@ -36,22 +40,37 @@ public class ScreenHandler extends Gui } @SubscribeEvent - public void onEntityJoinWorld(RenderGameOverlayEvent event) + public void renderScreen(RenderGameOverlayEvent event) { - if (cooldown == 0) - { - JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo()); - cooldown = 500; - } - else cooldown--; - - if (event.isCancelable() || event.type != ElementType.EXPERIENCE || tagCache == null) return; - mc.renderEngine.bindTexture(new ResourceLocation("jewelrycraft", "textures/gui/curses1.png")); - for (String l : JewelrycraftUtil.curses.keySet()) - if (tagCache.getInteger(l) > -1){ - int tag = JewelrycraftUtil.curses.get(l) + 1; - int size = 32; - this.drawTexturedModalRect(2 + size * tag, 2, tag % size * size, tag / size * size, size, size); + if (event.isCancelable() || event.type != ElementType.ALL || tagCache == null) return; + mc.renderEngine.bindTexture(new ResourceLocation("jewelrycraft", "textures/gui/curses.png")); + int count = 0; + for (String l : JewelrycraftUtil.curseValues.keySet()) + if (tagCache.getByte(l) > -1){ + int tag = JewelrycraftUtil.curseValues.get(l); + int size = 16; + this.drawRect(0, (size + 6) * count, 24 + mc.fontRenderer.getStringWidth(l.split(":")[1]), 4 + (size + 6) * count + 16, 0xaf000000); + this.drawRect(2, 2 + (size + 6) * count, 22 + mc.fontRenderer.getStringWidth(l.split(":")[1]), 2 + (size + 6) * count + 16, 0x95700064); + count++; + } + count = 0; + for (String l : JewelrycraftUtil.curseValues.keySet()) + if (tagCache.getByte(l) > -1){ + int tag = JewelrycraftUtil.curseValues.get(l); + int size = 16; + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_LIGHTING); + this.drawTexturedModalRect(2, 2 + (size + 6) * count, tag % size * size, tag / size * size, size, size); + count++; } + count = 0; + for (String l : JewelrycraftUtil.curseValues.keySet()) + if (tagCache.getByte(l) > -1){ + int tag = JewelrycraftUtil.curseValues.get(l); + int size = 16; + mc.fontRenderer.drawStringWithShadow(l.split(":")[1], 20, 7 + (size + 6) * count, 16777215); + if(tagCache.getByte(l) == 1) mc.fontRenderer.drawStringWithShadow("Leech", mc.fontRenderer.getStringWidth(l.split(":")[1]) + 25, 7 + (size + 6) * count, 16777215); + count++; + } } }
\ No newline at end of file diff --git a/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java b/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java new file mode 100644 index 0000000..9d65a60 --- /dev/null +++ b/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java @@ -0,0 +1,201 @@ +package darkknight.jewelrycraft.item; + +import java.awt.Graphics2D; +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; +import java.awt.Image; +import java.awt.Transparency; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import javax.imageio.ImageIO; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.client.resources.IResourceManager; +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; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import darkknight.jewelrycraft.util.JewelryNBT; + +public class ItemBaseJewelry extends Item +{ + public ItemBaseJewelry() + { + super(); + this.setMaxStackSize(1); + } + + @Override + public boolean requiresMultipleRenderPasses() + { + return true; + } + + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack stack, int pass) + { + try + { + return color(stack, pass); + } + catch (IOException e) + { + e.printStackTrace(); + } + return 16777215; + } + + public static int color(ItemStack stack, int pass) throws IOException + { + String domain = "", texture; + IResourceManager rm = Minecraft.getMinecraft().getResourceManager(); + BufferedImage icon; + if (pass == 0 && stack != null && JewelryNBT.ingot(stack) != null && Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()) > 0 && JewelryNBT.ingot(stack).getIconIndex() != null && JewelryNBT.ingotColor(stack) == 16777215) + { + ItemStack in = JewelryNBT.ingot(stack); + if (Item.getIdFromItem(in.getItem()) == Block.getIdFromBlock(Blocks.stained_glass) || Item.getIdFromItem(in.getItem()) == Block.getIdFromBlock(Blocks.stained_hardened_clay) || Item.getIdFromItem(in.getItem()) == Block.getIdFromBlock(Blocks.wool) || Item.getIdFromItem(in.getItem()) == Block.getIdFromBlock(Blocks.carpet)) in.setItemDamage(15 - in.getItemDamage()); + IIcon itemIcon = in.getItem().getIcon(in, 0); + String ingotIconName = itemIcon.getIconName(); + + if (ingotIconName.substring(0, ingotIconName.indexOf(":") + 1) != "") domain = ingotIconName.substring(0, ingotIconName.indexOf(":") + 1).replace(":", " ").trim(); + else domain = "minecraft"; + + texture = ingotIconName.substring(ingotIconName.lastIndexOf(":") + 1) + ".png"; + ResourceLocation ingot = null; + TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); + + if (texturemanager.getResourceLocation(JewelryNBT.ingot(stack).getItemSpriteNumber()).toString().contains("items")) ingot = new ResourceLocation(domain.toLowerCase(), "textures/items/" + texture); + else ingot = new ResourceLocation(domain.toLowerCase(), "textures/blocks/" + texture); + + icon = ImageIO.read(rm.getResource(ingot).getInputStream()); + int height = icon.getHeight(); + int width = icon.getWidth(); + Map m = new HashMap(); + for (int i = 0; i < width; i++) + for (int j = 0; j < height; j++) + { + int rgb = icon.getRGB(i, j); + int red = (rgb >> 16) & 0xff; + int green = (rgb >> 8) & 0xff; + int blue = (rgb) & 0xff; + int[] rgbArr = {red, green, blue}; + int Cmax = Math.max(red, Math.max(green, blue)); + int Cmin = Math.min(red, Math.min(green, blue)); + if (!isGray(rgbArr)) m.put(rgb, (Cmax + Cmin)/2); + } + int color = getMostCommonColour(m); + if (JewelryNBT.ingot(stack) != null && JewelryNBT.ingot(stack).getItem().getColorFromItemStack(JewelryNBT.ingot(stack), 1) != 16777215) JewelryNBT.addIngotColor(stack, JewelryNBT.ingot(stack).getItem().getColorFromItemStack(JewelryNBT.ingot(stack), 1)); + else JewelryNBT.addIngotColor(stack, color); + } + else if (pass == 1 && stack != null && JewelryNBT.gem(stack) != null && JewelryNBT.gem(stack).getIconIndex() != null && JewelryNBT.gem(stack) != null) + { + IIcon itemIcon = JewelryNBT.gem(stack).getItem().getIconFromDamage(JewelryNBT.gem(stack).getItemDamage()); + String jewelIconName = itemIcon.getIconName(); + + if (jewelIconName.substring(0, jewelIconName.indexOf(":") + 1) != "") domain = jewelIconName.substring(0, jewelIconName.indexOf(":") + 1).replace(":", " ").trim(); + else domain = "minecraft"; + + texture = jewelIconName.substring(jewelIconName.lastIndexOf(":") + 1) + ".png"; + ResourceLocation jewelLoc = null; + + if (JewelryNBT.gem(stack).getUnlocalizedName().contains("item")) jewelLoc = new ResourceLocation(domain, "textures/items/" + texture); + else jewelLoc = new ResourceLocation(domain, "textures/blocks/" + texture); + + icon = ImageIO.read(rm.getResource(jewelLoc).getInputStream()); + int height = icon.getHeight(); + int width = icon.getWidth(); + Map m = new HashMap(); + for (int i = 0; i < width; i++) + for (int j = 0; j < height; j++) + { + int rgb = icon.getRGB(i, j); + int red = (rgb >> 16) & 0xff; + int green = (rgb >> 8) & 0xff; + int blue = (rgb) & 0xff; + int[] rgbArr = {red, green, blue}; + int Cmax = Math.max(red, Math.max(green, blue)); + int Cmin = Math.min(red, Math.min(green, blue)); + if (!isGray(rgbArr)) m.put(rgb, (Cmax + Cmin)/2); + } + int color = getMostCommonColour(m); + if (JewelryNBT.gem(stack).getItem().getColorFromItemStack(JewelryNBT.gem(stack), 1) == 16777215) JewelryNBT.addGemColor(stack, color); + else JewelryNBT.addGemColor(stack, JewelryNBT.gem(stack).getItem().getColorFromItemStack(JewelryNBT.gem(stack), 1)); + } + if (pass == 0 && JewelryNBT.ingot(stack) != null) return JewelryNBT.ingotColor(stack); + if (pass == 1 && JewelryNBT.gem(stack) != null) return JewelryNBT.gemColor(stack); + else if (JewelryNBT.ingot(stack) != null) return JewelryNBT.ingotColor(stack); + return 16777215; + } + + 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; + } + + public static boolean isGray(int[] rgbArr) + { + int rgbSum = rgbArr[0] + rgbArr[1] + rgbArr[2]; + if (rgbSum > 0 && rgbSum < 256 * 3) { return false; } + return true; + } + + 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(this.getUnlocalizedNameInefficiently(stack) + ".name")).trim(); + return ("" + StatCollector.translateToLocal(this.getUnlocalizedNameInefficiently(stack) + ".name")).trim(); + } + + /** + * allows items to add custom lines of information to the mouseover description + */ + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) + { + if (stack.hasTagCompound() && par4) + { + ItemStack ingot = JewelryNBT.ingot(stack); + if (ingot != null && Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()) > 0) list.add("Ingot: " + EnumChatFormatting.YELLOW + ingot.getDisplayName()); + + ItemStack gem = JewelryNBT.gem(stack); + if (gem != null) list.add("Gem: " + EnumChatFormatting.BLUE + gem.getDisplayName()); + + ArrayList<ItemStack> modifier = JewelryNBT.modifier(stack); + if (!modifier.isEmpty()) list.add("Modifiers: "); + for (int i = 0; i < modifier.size(); i++) + list.add(EnumChatFormatting.DARK_PURPLE + modifier.get(i).getDisplayName() + " x" + modifier.get(i).stackSize); + } + } +} diff --git a/java/darkknight/jewelrycraft/item/ItemBracelet.java b/java/darkknight/jewelrycraft/item/ItemBracelet.java new file mode 100644 index 0000000..8b034c7 --- /dev/null +++ b/java/darkknight/jewelrycraft/item/ItemBracelet.java @@ -0,0 +1,27 @@ +package darkknight.jewelrycraft.item; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import darkknight.jewelrycraft.util.JewelryNBT; + +public class ItemBracelet extends ItemBaseJewelry +{ + public IIcon gem; + public ItemBracelet() + { + } + + public void registerIcons(IIconRegister iconRegister) + { + itemIcon = iconRegister.registerIcon("jewelrycraft:bracelet"); + gem = iconRegister.registerIcon("jewelrycraft:jewelBracelet"); + } + + public IIcon getIcon(ItemStack stack, int pass) + { + if (pass == 0) return itemIcon; + if (pass == 1 && JewelryNBT.gem(stack) != null) return gem; + return itemIcon; + } +} diff --git a/java/darkknight/jewelrycraft/item/ItemClayMolds.java b/java/darkknight/jewelrycraft/item/ItemClayMolds.java index 8c2eafa..29a2526 100644 --- a/java/darkknight/jewelrycraft/item/ItemClayMolds.java +++ b/java/darkknight/jewelrycraft/item/ItemClayMolds.java @@ -15,7 +15,7 @@ public class ItemClayMolds extends Item { /** List of molds color names */ public static final String[] moldsItemNames = new String[] - { "clayIngot", "clayRing", "clayNecklace" }; + { "clayIngot", "clayRing", "clayNecklace", "clayBracelet", "clayEarrings"}; @SideOnly(Side.CLIENT) private IIcon[] moldsIcons; @@ -42,7 +42,7 @@ public class ItemClayMolds extends Item * ItemStack so different stacks can have different names based on their * damage or NBT. */ - public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) + public String getUnlocalizedName(ItemStack par1ItemStack) { int i = MathHelper.clamp_int(par1ItemStack.getItemDamage(), 0, moldsItemNames.length - 1); return super.getUnlocalizedName() + "." + moldsItemNames[i]; diff --git a/java/darkknight/jewelrycraft/item/ItemCrystal.java b/java/darkknight/jewelrycraft/item/ItemCrystal.java index e044385..c9a234b 100644 --- a/java/darkknight/jewelrycraft/item/ItemCrystal.java +++ b/java/darkknight/jewelrycraft/item/ItemCrystal.java @@ -59,10 +59,14 @@ public class ItemCrystal extends Item public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int i, int j, int k, int side, float par8, float par9, float par10) { - //System.out.println(world.getBlockMetadata(i, j, k)); return true; } + public String getUnlocalizedName(ItemStack stack) + { + return super.getUnlocalizedName() + "." + stack.getItemDamage(); + } + @SuppressWarnings( { "unchecked", "rawtypes" }) public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) diff --git a/java/darkknight/jewelrycraft/item/ItemEarrings.java b/java/darkknight/jewelrycraft/item/ItemEarrings.java new file mode 100644 index 0000000..abff9cc --- /dev/null +++ b/java/darkknight/jewelrycraft/item/ItemEarrings.java @@ -0,0 +1,27 @@ +package darkknight.jewelrycraft.item; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import darkknight.jewelrycraft.util.JewelryNBT; + +public class ItemEarrings extends ItemBaseJewelry +{ + public IIcon gem; + public ItemEarrings() + { + } + + public void registerIcons(IIconRegister iconRegister) + { + itemIcon = iconRegister.registerIcon("jewelrycraft:earrings"); + gem = iconRegister.registerIcon("jewelrycraft:jewelEarrings"); + } + + public IIcon getIcon(ItemStack stack, int pass) + { + if (pass == 0) return itemIcon; + if (pass == 1 && JewelryNBT.gem(stack) != null) return gem; + return itemIcon; + } +} diff --git a/java/darkknight/jewelrycraft/item/ItemList.java b/java/darkknight/jewelrycraft/item/ItemList.java index fa718df..1d060ec 100644 --- a/java/darkknight/jewelrycraft/item/ItemList.java +++ b/java/darkknight/jewelrycraft/item/ItemList.java @@ -20,6 +20,8 @@ public class ItemList public static Item crystal; public static ItemRing ring; public static ItemNecklace necklace; + public static ItemBracelet bracelet; + public static ItemEarrings earrings; public static Item guide; public static ItemMoltenMetalBucket bucket; public static ItemMoltenMetal metal; @@ -35,8 +37,10 @@ public class ItemList molds = new ItemMolds().setUnlocalizedName("Jewelrycraft.mold").setTextureName("Mold").setCreativeTab(JewelrycraftMod.jewelrycraft); clayMolds = new ItemClayMolds().setUnlocalizedName("Jewelrycraft.mold").setTextureName("Mold").setCreativeTab(JewelrycraftMod.jewelrycraft); ring = (ItemRing) new ItemRing().setUnlocalizedName("Jewelrycraft.ring").setTextureName("jewelrycraft:ring"); - crystal = new ItemCrystal().setUnlocalizedName("Jewelrycraft.crystal").setTextureName("jewelrycraft:crystal").setCreativeTab(JewelrycraftMod.jewelrycraft); necklace = (ItemNecklace) new ItemNecklace().setUnlocalizedName("Jewelrycraft.necklace").setTextureName("jewelrycraft:necklace"); + bracelet = (ItemBracelet) new ItemBracelet().setUnlocalizedName("Jewelrycraft.bracelet").setTextureName("jewelrycraft:bracelet"); + earrings = (ItemEarrings) new ItemEarrings().setUnlocalizedName("Jewelrycraft.earrings").setTextureName("jewelrycraft:earrings"); + crystal = new ItemCrystal().setUnlocalizedName("Jewelrycraft.crystal").setTextureName("jewelrycraft:crystal").setCreativeTab(JewelrycraftMod.jewelrycraft); guide = new ItemGuide().setUnlocalizedName("Jewelrycraft.guide").setTextureName("jewelrycraft:guide").setCreativeTab(JewelrycraftMod.jewelrycraft); bucket = (ItemMoltenMetalBucket) new ItemMoltenMetalBucket().setUnlocalizedName("Jewelrycraft.bucket"); metal = (ItemMoltenMetal) new ItemMoltenMetal().setUnlocalizedName("Jewelrycraft.bucket"); @@ -47,6 +51,8 @@ public class ItemList GameRegistry.registerItem(clayMolds, "clayMolds"); GameRegistry.registerItem(ring, "ring"); GameRegistry.registerItem(necklace, "necklace"); + GameRegistry.registerItem(bracelet, "bracelet"); + GameRegistry.registerItem(earrings, "earrings"); GameRegistry.registerItem(crystal, "crystal"); GameRegistry.registerItem(guide, "guide"); GameRegistry.registerItem(bucket, "moltenMetalBucket"); diff --git a/java/darkknight/jewelrycraft/item/ItemMolds.java b/java/darkknight/jewelrycraft/item/ItemMolds.java index a335df8..0703997 100644 --- a/java/darkknight/jewelrycraft/item/ItemMolds.java +++ b/java/darkknight/jewelrycraft/item/ItemMolds.java @@ -15,7 +15,7 @@ public class ItemMolds extends Item { /** List of molds color names */ public static final String[] moldsItemNames = new String[] - { "ingot", "ring", "necklace" }; + { "ingot", "ring", "necklace", "bracelet", "earrings" }; @SideOnly(Side.CLIENT) private IIcon[] moldsIcons; diff --git a/java/darkknight/jewelrycraft/item/ItemMoltenMetal.java b/java/darkknight/jewelrycraft/item/ItemMoltenMetal.java index 53f1926..ef098f5 100644 --- a/java/darkknight/jewelrycraft/item/ItemMoltenMetal.java +++ b/java/darkknight/jewelrycraft/item/ItemMoltenMetal.java @@ -1,8 +1,13 @@ package darkknight.jewelrycraft.item; import java.awt.image.BufferedImage; -import java.io.File; import java.io.IOException; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; import javax.imageio.ImageIO; @@ -53,7 +58,6 @@ public class ItemMoltenMetal extends Item String domain = "", texture; IResourceManager rm = Minecraft.getMinecraft().getResourceManager(); BufferedImage icon; - int x = 0, y = 0, ok = 0, red, green, blue; if (stack != null && JewelryNBT.ingot(stack) != null && Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()) > 0 && JewelryNBT.ingot(stack).getIconIndex() != null && JewelryNBT.ingotColor(stack) == 16777215) { IIcon itemIcon = JewelryNBT.ingot(stack).getItem().getIcon(JewelryNBT.ingot(stack), 0); @@ -70,32 +74,61 @@ public class ItemMoltenMetal extends Item else ingot = new ResourceLocation(domain.toLowerCase(), "textures/blocks/" + texture); icon = ImageIO.read(rm.getResource(ingot).getInputStream()); - while (ok == 0) - { - red = (icon.getRGB(x, y) >> 16) & 0xFF; - green = (icon.getRGB(x, y) >> 8) & 0xFF; - blue = icon.getRGB(x, y) & 0xFF; - if (!isColorPretty(red, green, blue)) + int height = icon.getHeight(); + int width = icon.getWidth(); + + Map m = new HashMap(); + for (int i = 0; i < width; i++) + for (int j = 0; j < height; j++) { - if (x < icon.getTileWidth() - 1) x++; - if (x >= icon.getTileWidth() - 1 && y < icon.getTileWidth() - 1) - { - x = 0; - y++; - } - if (x == icon.getTileWidth() - 1 && y == icon.getTileWidth() - 1) ok = 1; + int rgb = icon.getRGB(i, j); + int red = (rgb >> 16) & 0xff; + int green = (rgb >> 8) & 0xff; + int blue = (rgb) & 0xff; + int[] rgbArr = {red, green, blue}; + int Cmax = Math.max(red, Math.max(green, blue)); + int Cmin = Math.min(red, Math.min(green, blue)); + if (!isGray(rgbArr)) m.put(rgb, (Cmax + Cmin)/2); } - else ok = 1; + try + { + int color = getMostCommonColour(m); + if (JewelryNBT.ingot(stack) != null && JewelryNBT.ingot(stack).getItem().getColorFromItemStack(JewelryNBT.ingot(stack), 1) != 16777215) JewelryNBT.addIngotColor(stack, JewelryNBT.ingot(stack).getItem().getColorFromItemStack(JewelryNBT.ingot(stack), 1)); + else JewelryNBT.addIngotColor(stack, color); + } + catch (Exception e) + { + JewelryNBT.addIngotColor(stack, 16777215); } - JewelryNBT.addIngotColor(stack, icon.getRGB(x, y)); } if (JewelryNBT.ingot(stack) != null) return JewelryNBT.ingotColor(stack); - return 16777215; + return 0; + } + + 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; } - public static boolean isColorPretty(int r, int g, int b) + public static boolean isGray(int[] rgbArr) { - if ((r >= 100 && g >= 100 && b >= 100 && r < 230 && b < 230 && g < 230) || ((r >= 100 && (g < 100 || b < 100)) || (g >= 100 && (r < 100 || b < 100)) || (b >= 100 && (g < 100 || r < 100)))) return true; - else return false; + int rgbSum = rgbArr[0] + rgbArr[1] + rgbArr[2]; + if (rgbSum > 0 && rgbSum < 256 * 3) { return false; } + return true; } } diff --git a/java/darkknight/jewelrycraft/item/ItemMoltenMetalBucket.java b/java/darkknight/jewelrycraft/item/ItemMoltenMetalBucket.java index c4c0a2f..5c61398 100644 --- a/java/darkknight/jewelrycraft/item/ItemMoltenMetalBucket.java +++ b/java/darkknight/jewelrycraft/item/ItemMoltenMetalBucket.java @@ -2,6 +2,12 @@ package darkknight.jewelrycraft.item; import java.awt.image.BufferedImage; import java.io.IOException; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; import javax.imageio.ImageIO; @@ -41,8 +47,7 @@ public class ItemMoltenMetalBucket extends Item } /** - * Called whenever this item is equipped and the right mouse button is - * pressed. Args: itemStack, world, entityPlayer + * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ public ItemStack onItemRightClick(ItemStack stack, World par2World, EntityPlayer par3EntityPlayer) { @@ -180,9 +185,9 @@ public class ItemMoltenMetalBucket extends Item else if (stack != null && JewelryNBT.ingot(stack) != null) { if (!world.isRemote && flag && !material.isLiquid()) world.func_147480_a(x, y, z, true); - - JewelrycraftMod.saveData.setString(x + " " + y + " " + z + " " + world.provider.dimensionId, Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()) + ":" + JewelryNBT.ingot(stack).getItemDamage()); - JewelrycraftMod.netWrapper.sendToAll(new PacketSendLiquidData(world.provider.dimensionId, x, y, z, Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()), JewelryNBT.ingot(stack).getItemDamage())); + int color = color(stack, 1); + JewelrycraftMod.saveData.setString(x + " " + y + " " + z + " " + world.provider.dimensionId, Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()) + ":" + JewelryNBT.ingot(stack).getItemDamage() + ":" + color); + JewelrycraftMod.netWrapper.sendToAll(new PacketSendLiquidData(world.provider.dimensionId, x, y, z, Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()), JewelryNBT.ingot(stack).getItemDamage(), color)); world.setBlock(x, y, z, BlockList.moltenMetal, 0, 3); return true; @@ -229,7 +234,6 @@ public class ItemMoltenMetalBucket extends Item String domain = "", texture; IResourceManager rm = Minecraft.getMinecraft().getResourceManager(); BufferedImage icon; - int x = 0, y = 0, ok = 0, red, green, blue; if (pass == 1 && stack != null && JewelryNBT.ingot(stack) != null && Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()) > 0 && JewelryNBT.ingot(stack).getIconIndex() != null && JewelryNBT.ingotColor(stack) == 16777215) { IIcon itemIcon = JewelryNBT.ingot(stack).getItem().getIcon(JewelryNBT.ingot(stack), 0); @@ -246,33 +250,54 @@ public class ItemMoltenMetalBucket extends Item else ingot = new ResourceLocation(domain.toLowerCase(), "textures/blocks/" + texture); icon = ImageIO.read(rm.getResource(ingot).getInputStream()); - while (ok == 0) - { - red = (icon.getRGB(x, y) >> 16) & 0xFF; - green = (icon.getRGB(x, y) >> 8) & 0xFF; - blue = icon.getRGB(x, y) & 0xFF; - if (!isColorPretty(red, green, blue)) + int height = icon.getHeight(); + int width = icon.getWidth(); + Map m = new HashMap(); + for (int i = 0; i < width; i++) + for (int j = 0; j < height; j++) { - if (x < icon.getTileWidth() - 1) x++; - if (x >= icon.getTileWidth() - 1 && y < icon.getTileWidth() - 1) - { - x = 0; - y++; - } - if (x == icon.getTileWidth() - 1 && y == icon.getTileWidth() - 1) ok = 1; + int rgb = icon.getRGB(i, j); + int red = (rgb >> 16) & 0xff; + int green = (rgb >> 8) & 0xff; + int blue = (rgb) & 0xff; + int[] rgbArr = {red, green, blue}; + int Cmax = Math.max(red, Math.max(green, blue)); + int Cmin = Math.min(red, Math.min(green, blue)); + if (!isGray(rgbArr)) m.put(rgb, (Cmax + Cmin)/2); } - else ok = 1; - } - JewelryNBT.addIngotColor(stack, icon.getRGB(x, y)); + int color = getMostCommonColour(m); + if (JewelryNBT.ingot(stack) != null && JewelryNBT.ingot(stack).getItem().getColorFromItemStack(JewelryNBT.ingot(stack), 1) != 16777215) JewelryNBT.addIngotColor(stack, JewelryNBT.ingot(stack).getItem().getColorFromItemStack(JewelryNBT.ingot(stack), 1)); + else JewelryNBT.addIngotColor(stack, color); } if (JewelryNBT.ingot(stack) != null && pass == 1) return JewelryNBT.ingotColor(stack); return 16777215; } - public static boolean isColorPretty(int r, int g, int b) + public static int getMostCommonColour(Map map) { - if ((r >= 100 && g >= 100 && b >= 100 && r < 230 && b < 230 && g < 230) || ((r >= 100 && (g < 100 || b < 100)) || (g >= 100 && (r < 100 || b < 100)) || (b >= 100 && (g < 100 || r < 100)))) return true; - else return false; + 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; + } + + public static boolean isGray(int[] rgbArr) + { + int rgbSum = rgbArr[0] + rgbArr[1] + rgbArr[2]; + if (rgbSum > 0 && rgbSum < 256 * 3) { return false; } + return true; } public ItemStack getModifiedItemStack(ItemStack ingot) @@ -284,14 +309,10 @@ public class ItemMoltenMetalBucket extends Item public String getItemStackDisplayName(ItemStack stack) { - if (JewelryNBT.ingot(stack) != null){ + if (JewelryNBT.ingot(stack) != null) + { ItemStack ingot = JewelryNBT.ingot(stack); - if(Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_glass) - || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_glass_pane) - || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_hardened_clay) - || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.wool) - || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.carpet)) - ingot.setItemDamage(15 - ingot.getItemDamage()); + if (Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_glass) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_hardened_clay) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.wool) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.carpet)) ingot.setItemDamage(15 - ingot.getItemDamage()); return (StatCollector.translateToLocal(this.getUnlocalizedNameInefficiently(stack) + ".name")).trim() + " " + ingot.getDisplayName().replace("Ingot", " ").trim(); } return ("" + StatCollector.translateToLocal(this.getUnlocalizedNameInefficiently(stack) + ".name")).trim() + " Metal"; diff --git a/java/darkknight/jewelrycraft/item/ItemMultiIngot.java b/java/darkknight/jewelrycraft/item/ItemMultiIngot.java deleted file mode 100644 index 8e29690..0000000 --- a/java/darkknight/jewelrycraft/item/ItemMultiIngot.java +++ /dev/null @@ -1,46 +0,0 @@ -package darkknight.jewelrycraft.item; - -import java.util.List; - -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; - -public class ItemMultiIngot extends Item -{ - public IIcon[] icons = new IIcon[2]; - - public ItemMultiIngot() - { - super(); - setHasSubtypes(true); - } - - @Override - public void getSubItems(Item item, CreativeTabs tab, List items) - { - items.add(new ItemStack(item, 1, 0)); - items.add(new ItemStack(item, 1, 1)); - } - - @Override - public String getUnlocalizedName(ItemStack stack) - { - return super.getUnlocalizedName() + "." + stack.getItemDamage(); - } - - @Override - public void registerIcons(IIconRegister register) - { - icons[0] = register.registerIcon("jewelrycraft:test/ingot2"); - icons[1] = register.registerIcon("jewelrycraft:ingot3"); - } - - @Override - public IIcon getIconFromDamage(int dmg) - { - return dmg == 1 ? icons[1] : icons[0]; - } -} diff --git a/java/darkknight/jewelrycraft/item/ItemNecklace.java b/java/darkknight/jewelrycraft/item/ItemNecklace.java index c6bfbbc..e5905b5 100644 --- a/java/darkknight/jewelrycraft/item/ItemNecklace.java +++ b/java/darkknight/jewelrycraft/item/ItemNecklace.java @@ -1,43 +1,16 @@ package darkknight.jewelrycraft.item; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.entity.Entity; -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; -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionEffect; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IIcon; -import net.minecraft.util.StatCollector; -import net.minecraft.world.World; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import darkknight.jewelrycraft.util.JewelryNBT; -import darkknight.jewelrycraft.util.JewelrycraftUtil; -public class ItemNecklace extends Item +public class ItemNecklace extends ItemBaseJewelry { - public IIcon gem; - private double amplifier; - int index = 0; - + public IIcon gem; public ItemNecklace() { - super(); - this.setMaxStackSize(1); - } + } public void registerIcons(IIconRegister iconRegister) { @@ -45,238 +18,10 @@ public class ItemNecklace extends Item gem = iconRegister.registerIcon("jewelrycraft:jewelNecklace"); } - @Override - public boolean requiresMultipleRenderPasses() - { - return true; - } - - @SideOnly(Side.CLIENT) - public int getColorFromItemStack(ItemStack stack, int pass) - { - try - { - return ItemRing.color(stack, pass); - } - catch (IOException e) - { - e.printStackTrace(); - } - return 16777215; - } - public IIcon getIcon(ItemStack stack, int pass) { if (pass == 0) return itemIcon; if (pass == 1 && JewelryNBT.gem(stack) != null) return gem; return itemIcon; } - - 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(this.getUnlocalizedNameInefficiently(stack) + ".name")).trim(); - return ("" + StatCollector.translateToLocal(this.getUnlocalizedNameInefficiently(stack) + ".name")).trim(); - } - - @SuppressWarnings( - { "rawtypes" }) - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) - { - if (!world.isRemote) - { - List entities = world.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(player.posX - 1.5D, player.posY, player.posZ - 1.5D, player.posX + 1.5D, player.posY + 2D, player.posZ + 1.5D)); - if (JewelryNBT.playerPosX(stack) != -1 && JewelryNBT.playerPosY(stack) != -1 && JewelryNBT.playerPosZ(stack) != -1) - { - double posX = JewelryNBT.playerPosX(stack), posY = JewelryNBT.playerPosY(stack), posZ = JewelryNBT.playerPosZ(stack); - if (JewelryNBT.isGemX(stack, new ItemStack(Items.ender_pearl)) && JewelryNBT.isModifierX(stack, new ItemStack(Items.bed)) && JewelryNBT.dimension(stack) != -2 && JewelryNBT.dimName(stack) != null) - { - int dimension = JewelryNBT.dimension(stack); - for (int i = 1; i <= 20; i++) - world.spawnParticle("largesmoke", player.posX - 0.5D + Math.random(), player.posY - 1.5D + Math.random(), player.posZ - 0.5D + Math.random(), 0.0D, 0.0D, 0.0D); - if (!JewelryNBT.isDimensionX(stack, player.dimension)) player.travelToDimension(dimension); - for (int i = 0; i < entities.size(); i++) - ((EntityLivingBase) entities.get(i)).setPositionAndUpdate(posX, posY, posZ); - for (int i = 1; i <= 300; i++) - world.spawnParticle("portal", posX - 0.5D + Math.random(), posY + Math.random(), posZ - 0.5D + Math.random(), 0.0D, 0.0D, 0.0D); - } - else if (JewelryNBT.isDimensionX(stack, player.dimension)) - { - for (int i = 1; i <= 20; i++) - world.spawnParticle("largesmoke", player.posX - 0.5D + Math.random(), player.posY - 1.5D + Math.random(), player.posZ - 0.5D + Math.random(), 0.0D, 0.0D, 0.0D); - for (int i = 0; i < entities.size(); i++) - ((EntityLivingBase) entities.get(i)).setPositionAndUpdate(posX, posY, posZ); - for (int i = 1; i <= 300; i++) - world.spawnParticle("portal", posX - 0.5D + Math.random(), posY + Math.random(), posZ - 0.5D + Math.random(), 0.0D, 0.0D, 0.0D); - } - else player.addChatMessage(new ChatComponentText("You can't teleport to these coordonates! You need to be in the same dimension they were set!")); - } - else if (JewelryNBT.isGemX(stack, new ItemStack(Items.ender_pearl)) && JewelryNBT.isModifierX(stack, new ItemStack(Items.bed)) && JewelryNBT.dimension(stack) == -2 && JewelryNBT.playerPosX(stack) == -1 && JewelryNBT.playerPosY(stack) == -1 && JewelryNBT.playerPosZ(stack) == -1) - { - JewelryNBT.addCoordonatesAndDimension(stack, player.posX, player.posY, player.posZ, world.provider.dimensionId, world.provider.getDimensionName()); - JewelryNBT.addFakeEnchantment(stack); - } - else if (JewelryNBT.isGemX(stack, new ItemStack(Items.ender_pearl)) && !JewelryNBT.hasTag(stack, "modifier") && JewelryNBT.playerPosX(stack) == -1 && JewelryNBT.playerPosY(stack) == -1 && JewelryNBT.playerPosZ(stack) == -1) - { - JewelryNBT.addCoordonatesAndDimension(stack, player.posX, player.posY, player.posZ, world.provider.dimensionId, world.provider.getDimensionName()); - JewelryNBT.addFakeEnchantment(stack); - } - - if (JewelryNBT.hasTag(stack, "mode")) - { - String mode = ""; - if (JewelryNBT.isModeX(stack, "Activated")) mode = "Deactivated"; - else if (JewelryNBT.isModeX(stack, "Deactivated")) mode = "Activated"; - if (mode != "") - { - player.addChatMessage(new ChatComponentText("The Necklace has been " + mode)); - JewelryNBT.addMode(stack, mode); - } - } - } - return stack; - } - - // @Override - // public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer - // player, EntityLivingBase entity) - // { - // if (!player.worldObj.isRemote && entity instanceof EntityLivingBase && - // JewelryNBT.isGemX(stack, new ItemStack(Item.netherStar)) && - // JewelryNBT.isModifierX(stack, new ItemStack(Block.chest)) && - // JewelryNBT.entity(stack, player) == null){ - // JewelryNBT.addEntity(stack, entity); - // JewelryNBT.addEntityID(stack, entity); - // entity.setDead(); - // JewelryNBT.addFakeEnchantment(stack); - // } - // return true; - // } - - /** - * allows items to add custom lines of information to the mouseover - * description - */ - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) - { - if (stack.hasTagCompound() && par4) - { - ItemStack ingot = JewelryNBT.ingot(stack); - if (ingot != null && Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()) > 0) list.add("Ingot: " + EnumChatFormatting.YELLOW + ingot.getDisplayName()); - - ItemStack gem = JewelryNBT.gem(stack); - if (gem != null) list.add("Gem: " + EnumChatFormatting.BLUE + gem.getDisplayName()); - - ArrayList<ItemStack> modifier = JewelryNBT.modifier(stack); - if(!modifier.isEmpty()) list.add("Modifiers: "); - for(int i = 0; i < modifier.size(); i++) list.add(EnumChatFormatting.DARK_PURPLE + modifier.get(i).getDisplayName() + " x" + modifier.get(i).stackSize); - - double playerPosX = JewelryNBT.playerPosX(stack), playerPosY = JewelryNBT.playerPosY(stack), playerPosZ = JewelryNBT.playerPosZ(stack); - if (playerPosX != -1 && playerPosY != -1 && playerPosZ != -1) list.add(EnumChatFormatting.YELLOW + "X: " + EnumChatFormatting.GRAY + (int) playerPosX + EnumChatFormatting.YELLOW + " Y: " + EnumChatFormatting.GRAY + (int) playerPosY + EnumChatFormatting.YELLOW + " Z: " + EnumChatFormatting.GRAY + (int) playerPosZ); - - int posX = JewelryNBT.blockCoordX(stack), posY = JewelryNBT.blockCoordY(stack), posZ = JewelryNBT.blockCoordZ(stack); - if (posX != -1 && posY != -1 && posZ != -1) list.add(EnumChatFormatting.YELLOW + "X: " + EnumChatFormatting.GRAY + (int) posX + EnumChatFormatting.YELLOW + " Y: " + EnumChatFormatting.GRAY + (int) posY + EnumChatFormatting.YELLOW + " Z: " + EnumChatFormatting.GRAY + (int) posZ); - - String name = JewelryNBT.dimName(stack); - if (name != null) list.add("Dimension: " + EnumChatFormatting.DARK_GREEN + name); - - EntityLivingBase entity = JewelryNBT.entity(stack, player); - if (entity != null) list.add("Entity: " + EnumChatFormatting.GOLD + entity.getCommandSenderName()); - - String modeN = JewelryNBT.modeName(stack); - if (modeN != null) list.add("Mode: " + modeN); - - int block = JewelryNBT.blockID(stack); - if (block != -1) list.add("Block: " + StatCollector.translateToLocalFormatted(Block.getBlockById(block).getUnlocalizedName())); - - int blockmeta = JewelryNBT.blockMetadata(stack); - if (blockmeta != -1) list.add("Block Metadata: " + blockmeta); - - TileEntity tile = JewelryNBT.tileEntity(stack); - if (tile != null) list.add(EnumChatFormatting.RED + "Contains a tile entity"); - - int blockX = JewelryNBT.blockCoordX(stack); - if (blockX != -1) list.add("Block Coords X: " + blockX); - - int blockY = JewelryNBT.blockCoordY(stack); - if (blockY != -1) list.add("Block Coords Y: " + blockY); - - int blockZ = JewelryNBT.blockCoordZ(stack); - if (blockZ != -1) list.add("Block Coords Z: " + blockZ); - - // int colorI = JewelryNBT.ingotColor(stack); - // if(colorI != -1) list.add("Ingot Color: " + colorI); - // - // int colorJ = JewelryNBT.gemColor(stack); - // if(colorJ != -1) list.add("gem Color: " + colorJ); - } - } - - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int i, int j, int k, int side, float par8, float par9, float par10) - { - amplifier = 0; - if (JewelryNBT.isGemX(stack, new ItemStack(Items.diamond))) amplifier = 1D; - else if (JewelryNBT.isGemX(stack, new ItemStack(Items.emerald))) amplifier = 2D; - else if (JewelryNBT.isGemX(stack, new ItemStack(Items.nether_star))) amplifier = 5D; - - if (!world.isRemote) - { - onItemRightClick(stack, world, player); - if (JewelryNBT.isModifierX(stack, new ItemStack(Items.dye, 1, 15))) for (int x = (int) -amplifier; x <= amplifier; x++) - for (int z = (int) -amplifier; z <= amplifier; z++) - world.scheduleBlockUpdate(i + x, j, k + z, world.getBlock(i + x, j, k + z), 7 - (int) amplifier); - - for (int x = (int) -1; x <= 1; x++) - for (int z = (int) -1; z <= 1; z++) - if (JewelryNBT.isModifierX(stack, new ItemStack(Items.diamond_pickaxe)) && JewelryNBT.isGemX(stack, new ItemStack(Items.nether_star)) && JewelryNBT.isIngotX(stack, new ItemStack(ItemList.shadowIngot))) if ((side == 0 || side == 1) && j > 0 && world.getBlock(i, j + x, k + z) != Blocks.air && world.getBlock(i + x, j, k + z).getBlockHardness(world, i + x, j, k + z) > 0F) world.func_147480_a(i + x, j, k + z, true); - else if ((side == 2 || side == 3) && j + x > 0 && world.getBlock(i, j + x, k + z) != Blocks.air && world.getBlock(i + z, j + x, k).getBlockHardness(world, i + z, j + x, k) > 0F) world.func_147480_a(i + z, j + x, k, true); - else if ((side == 4 || side == 5) && j + x > 0 && world.getBlock(i, j + x, k + z) != Blocks.air && world.getBlock(i, j + x, k + z).getBlockHardness(world, i, j + x, k + z) > 0F) world.func_147480_a(i, j + x, k + z, true); - } - return true; - } - - public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) - { - amplifier = 0D; - if (!world.isRemote) - { - EntityPlayer entityplayer = (EntityPlayer) entity; - int posX = (int) Math.floor(entityplayer.posX), posY = (int) Math.floor(entityplayer.posY), posZ = (int) Math.floor(entityplayer.posZ); - - if (JewelryNBT.isGemX(stack, new ItemStack(Items.diamond))) amplifier = 1D; - else if (JewelryNBT.isGemX(stack, new ItemStack(Items.emerald))) amplifier = 2D; - else if (JewelryNBT.isGemX(stack, new ItemStack(Items.nether_star))) amplifier = 5D; - - if (JewelryNBT.isModifierX(stack, new ItemStack(Items.dye, 1, 15)) && world.getBlock(posX, posY - 1, posZ) == Blocks.farmland) for (int i = (int) -amplifier; i <= amplifier; i++) - for (int j = (int) -amplifier; j <= amplifier; j++) - world.setBlockMetadataWithNotify(posX + i, posY - 1, posZ + j, 1, 7); - - List entities = world.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(entityplayer.posX - amplifier, entityplayer.posY - amplifier, entityplayer.posZ - amplifier, entityplayer.posX + amplifier, entityplayer.posY + 2 * amplifier, entityplayer.posZ + amplifier)); - if (JewelryNBT.isModeX(stack, "Activated")) - { - for (int i = 0; i < entities.size(); i++) - { - if (JewelryNBT.isModifierX(stack, new ItemStack(Items.blaze_powder))) ((EntityLivingBase) entities.get(i)).addPotionEffect(new PotionEffect(Potion.fireResistance.id, 4, 0, true)); - else if (JewelryNBT.isModifierX(stack, new ItemStack(Items.sugar))) ((EntityLivingBase) entities.get(i)).addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 4, 0, true)); - else if (JewelryNBT.isModifierX(stack, new ItemStack(Items.iron_pickaxe)) && !JewelryNBT.isGemX(stack, new ItemStack(Items.ender_pearl))) ((EntityLivingBase) entities.get(i)).addPotionEffect(new PotionEffect(Potion.digSpeed.id, 4, 0, true)); - else if (JewelryNBT.isModifierX(stack, new ItemStack(Items.feather))) - { - ((EntityLivingBase) entities.get(i)).addPotionEffect(new PotionEffect(Potion.jump.id, 4, 0, true)); - entityplayer.fallDistance = 0; - } - else if (JewelryNBT.isModifierX(stack, new ItemStack(Items.potionitem, 1, 8270))) ((EntityLivingBase) entities.get(i)).addPotionEffect(new PotionEffect(Potion.invisibility.id, 4, 0, true)); - } - } - } - } - - public ItemStack getModifiedItemStack(ItemStack ingot, ItemStack modifier, ItemStack gem) - { - ItemStack itemstack = new ItemStack(this); - JewelryNBT.addMetal(itemstack, ingot); - JewelryNBT.addModifiers(itemstack, JewelrycraftUtil.addRandomModifiers()); - JewelryNBT.addGem(itemstack, gem); -// if (JewelryNBT.isModifierEffectType(itemstack) && !(JewelryNBT.isGemX(itemstack, new ItemStack(Items.ender_pearl)) && JewelryNBT.isModifierX(itemstack, new ItemStack(Items.iron_pickaxe)))) JewelryNBT.addMode(itemstack, "Activated"); - if (JewelryNBT.isGemX(itemstack, new ItemStack(Items.nether_star)) && JewelryNBT.isModifierX(itemstack, new ItemStack(Items.book))) JewelryNBT.addMode(itemstack, "Disenchant"); - return itemstack; - } } diff --git a/java/darkknight/jewelrycraft/item/ItemRing.java b/java/darkknight/jewelrycraft/item/ItemRing.java index ac05e73..af546fe 100644 --- a/java/darkknight/jewelrycraft/item/ItemRing.java +++ b/java/darkknight/jewelrycraft/item/ItemRing.java @@ -1,64 +1,16 @@ package darkknight.jewelrycraft.item; -import java.awt.image.BufferedImage; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Random; - -import javax.imageio.ImageIO; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockChest; -import net.minecraft.block.BlockSkull; -import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.client.renderer.texture.TextureManager; -import net.minecraft.client.resources.IResourceManager; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.monster.EntityIronGolem; -import net.minecraft.entity.monster.EntitySnowman; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.inventory.InventoryEnderChest; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionEffect; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityChest; -import net.minecraft.tileentity.TileEntitySkull; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IIcon; -import net.minecraft.util.MathHelper; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.StatCollector; -import net.minecraft.world.World; -import cpw.mods.fml.common.network.internal.FMLNetworkHandler; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import darkknight.jewelrycraft.JewelrycraftMod; -import darkknight.jewelrycraft.block.BlockList; import darkknight.jewelrycraft.util.JewelryNBT; -import darkknight.jewelrycraft.util.JewelrycraftUtil; -public class ItemRing extends Item +public class ItemRing extends ItemBaseJewelry { - public IIcon gem; - private int amplifier, cooldown = 0; - int index = 0; - + public IIcon gem; public ItemRing() { super(); - this.setMaxStackSize(1); } public void registerIcons(IIconRegister iconRegister) @@ -67,559 +19,10 @@ public class ItemRing extends Item gem = iconRegister.registerIcon("jewelrycraft:jewelRing"); } - @Override - public boolean requiresMultipleRenderPasses() - { - return true; - } - - @SideOnly(Side.CLIENT) - public int getColorFromItemStack(ItemStack stack, int pass) - { - try - { - return color(stack, pass); - } - catch (IOException e) - { - e.printStackTrace(); - } - return 16777215; - } - public IIcon getIcon(ItemStack stack, int pass) { if (pass == 0) return itemIcon; if (pass == 1 && JewelryNBT.gem(stack) != null) return gem; return itemIcon; } - - public static int color(ItemStack stack, int pass) throws IOException - { - String domain = "", texture; - IResourceManager rm = Minecraft.getMinecraft().getResourceManager(); - BufferedImage icon; - int x = 0, y = 0, ok = 0, red, green, blue; - if (pass == 0 && stack != null && JewelryNBT.ingot(stack) != null && Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()) > 0 && JewelryNBT.ingot(stack).getIconIndex() != null && JewelryNBT.ingotColor(stack) == 16777215) - { - IIcon itemIcon = JewelryNBT.ingot(stack).getItem().getIcon(JewelryNBT.ingot(stack), 0); - String ingotIconName = itemIcon.getIconName(); - - if (ingotIconName.substring(0, ingotIconName.indexOf(":") + 1) != "") domain = ingotIconName.substring(0, ingotIconName.indexOf(":") + 1).replace(":", " ").trim(); - else domain = "minecraft"; - - texture = ingotIconName.substring(ingotIconName.lastIndexOf(":") + 1) + ".png"; - ResourceLocation ingot = null; - TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); - - if (texturemanager.getResourceLocation(JewelryNBT.ingot(stack).getItemSpriteNumber()).toString().contains("items")) ingot = new ResourceLocation(domain.toLowerCase(), "textures/items/" + texture); - else ingot = new ResourceLocation(domain.toLowerCase(), "textures/blocks/" + texture); - - icon = ImageIO.read(rm.getResource(ingot).getInputStream()); - while (ok == 0) - { - red = (icon.getRGB(x, y) >> 16) & 0xFF; - green = (icon.getRGB(x, y) >> 8) & 0xFF; - blue = icon.getRGB(x, y) & 0xFF; - if (!isColorPretty(red, green, blue)) - { - if (x < icon.getTileWidth() - 1) x++; - if (x >= icon.getTileWidth() - 1 && y < icon.getTileWidth() - 1) - { - x = 0; - y++; - } - if (x == icon.getTileWidth() - 1 && y == icon.getTileWidth() - 1) ok = 1; - } - else ok = 1; - } - JewelryNBT.addIngotColor(stack, icon.getRGB(x, y)); - } - else if (pass == 1 && stack != null && JewelryNBT.gem(stack) != null && JewelryNBT.gem(stack).getIconIndex() != null && JewelryNBT.gem(stack) != null) - { - IIcon itemIcon = JewelryNBT.gem(stack).getItem().getIconFromDamage(JewelryNBT.gem(stack).getItemDamage()); - String jewelIconName = itemIcon.getIconName(); - x = 0; - y = 0; - ok = 0; - - if (jewelIconName.substring(0, jewelIconName.indexOf(":") + 1) != "") domain = jewelIconName.substring(0, jewelIconName.indexOf(":") + 1).replace(":", " ").trim(); - else domain = "minecraft"; - - texture = jewelIconName.substring(jewelIconName.lastIndexOf(":") + 1) + ".png"; - ResourceLocation jewelLoc = null; - - if (JewelryNBT.gem(stack).getUnlocalizedName().contains("item")) jewelLoc = new ResourceLocation(domain, "textures/items/" + texture); - else jewelLoc = new ResourceLocation(domain, "textures/blocks/" + texture); - - icon = ImageIO.read(rm.getResource(jewelLoc).getInputStream()); - while (ok == 0) - { - red = (icon.getRGB(x, y) >> 16) & 0xFF; - green = (icon.getRGB(x, y) >> 8) & 0xFF; - blue = icon.getRGB(x, y) & 0xFF; - if (!isColorPretty(red, green, blue)) - { - if (x < icon.getTileWidth() - 1) x++; - if (x >= icon.getTileWidth() - 1 && y < icon.getTileWidth() - 1) - { - x = 0; - y++; - } - if (x == icon.getTileWidth() - 1 && y == icon.getTileWidth() - 1) ok = 1; - } - else ok = 1; - } - if (JewelryNBT.gem(stack).getItem().getColorFromItemStack(JewelryNBT.gem(stack), 1) == 16777215) JewelryNBT.addGemColor(stack, icon.getRGB(x, y)); - else JewelryNBT.addGemColor(stack, JewelryNBT.gem(stack).getItem().getColorFromItemStack(JewelryNBT.gem(stack), 1)); - } - if (pass == 0 && JewelryNBT.ingot(stack) != null) return JewelryNBT.ingotColor(stack); - if (pass == 1 && JewelryNBT.gem(stack) != null) return JewelryNBT.gemColor(stack); - else if (JewelryNBT.ingot(stack) != null) return JewelryNBT.ingotColor(stack); - return 16777215; - } - - public static boolean isColorPretty(int r, int g, int b) - { - if ((r >= 100 && g >= 100 && b >= 100 && r < 230 && b < 230 && g < 230) || ((r >= 100 && (g < 100 || b < 100)) || (g >= 100 && (r < 100 || b < 100)) || (b >= 100 && (g < 100 || r < 100)))) return true; - else return false; - } - - public String getItemStackDisplayName(ItemStack stack) - { - if (JewelryNBT.ingot(stack) != null && JewelryNBT.gem(stack) != null && JewelryNBT.modifier(stack) == null && JewelryNBT.isGemX(stack, new ItemStack(Items.diamond)) && JewelryNBT.isIngotX(stack, new ItemStack(Items.gold_ingot))) return "Wedding Ring"; - else if (JewelryNBT.ingot(stack) != null && Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()) > 0) return JewelryNBT.ingot(stack).getDisplayName().replace("Ingot", " ").trim() + " " + ("" + StatCollector.translateToLocal(this.getUnlocalizedNameInefficiently(stack) + ".name")).trim(); - return ("" + StatCollector.translateToLocal(this.getUnlocalizedNameInefficiently(stack) + ".name")).trim(); - } - - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) - { - if (!world.isRemote) - { - if (JewelryNBT.playerPosX(stack) != -1 && JewelryNBT.playerPosY(stack) != -1 && JewelryNBT.playerPosZ(stack) != -1) - { - double posX = JewelryNBT.playerPosX(stack), posY = JewelryNBT.playerPosY(stack), posZ = JewelryNBT.playerPosZ(stack); - if (JewelryNBT.isGemX(stack, new ItemStack(Items.ender_pearl)) && JewelryNBT.isModifierX(stack, new ItemStack(Items.bed)) && JewelryNBT.dimension(stack) != -2 && JewelryNBT.dimName(stack) != null) - { - int dimension = JewelryNBT.dimension(stack); - for (int i = 1; i <= 20; i++) - world.spawnParticle("largesmoke", player.posX - 0.5D + Math.random(), player.posY - 1.5D + Math.random(), player.posZ - 0.5D + Math.random(), 0.0D, 0.0D, 0.0D); - if (!JewelryNBT.isDimensionX(stack, player.dimension)) player.travelToDimension(dimension); - player.setPositionAndUpdate(posX, posY, posZ); - for (int i = 1; i <= 300; i++) - world.spawnParticle("portal", posX - 0.5D + Math.random(), posY + Math.random(), posZ - 0.5D + Math.random(), 0.0D, 0.0D, 0.0D); - } - else if (JewelryNBT.isDimensionX(stack, player.dimension)) - { - for (int i = 1; i <= 20; i++) - world.spawnParticle("largesmoke", player.posX - 0.5D + Math.random(), player.posY - 1.5D + Math.random(), player.posZ - 0.5D + Math.random(), 0.0D, 0.0D, 0.0D); - player.setPositionAndUpdate(posX, posY, posZ); - for (int i = 1; i <= 300; i++) - world.spawnParticle("portal", posX - 0.5D + Math.random(), posY + Math.random(), posZ - 0.5D + Math.random(), 0.0D, 0.0D, 0.0D); - } - else player.addChatMessage(new ChatComponentText("You can't teleport to these coordonates! You need to be in the same dimension they were set!")); - } - else if (JewelryNBT.isGemX(stack, new ItemStack(Items.ender_pearl)) && JewelryNBT.isModifierX(stack, new ItemStack(Items.bed)) && JewelryNBT.dimension(stack) == -2 && JewelryNBT.playerPosX(stack) == -1 && JewelryNBT.playerPosY(stack) == -1 && JewelryNBT.playerPosZ(stack) == -1) - { - JewelryNBT.addCoordonatesAndDimension(stack, player.posX, player.posY, player.posZ, world.provider.dimensionId, world.provider.getDimensionName()); - JewelryNBT.addFakeEnchantment(stack); - } - else if (JewelryNBT.isGemX(stack, new ItemStack(Blocks.obsidian)) && JewelryNBT.isModifierX(stack, new ItemStack(Items.ender_eye))) - { - InventoryEnderChest inventoryenderchest = player.getInventoryEnderChest(); - player.displayGUIChest(inventoryenderchest); - } - else if (JewelryNBT.isGemX(stack, new ItemStack(Items.ender_pearl)) && JewelryNBT.isModifierX(stack, new ItemStack(Blocks.chest))) - { - int i = JewelryNBT.blockCoordX(stack), j = JewelryNBT.blockCoordY(stack), k = JewelryNBT.blockCoordZ(stack); - if (player.getDistance(i + 0.5F, j + 0.5F, k + 0.5F) <= 128 && i != -1 && j != -1 && k != -1) - { - Block block = world.getBlock(i, j, k); - if (!block.isAir(world, i, j, k) && block instanceof BlockChest) - { - TileEntity tile = world.getTileEntity(i, j, k); - if (tile != null && tile instanceof TileEntityChest) FMLNetworkHandler.openGui(player, JewelrycraftMod.instance, 0, world, i, j, k); - } - } - else if (i != -1 && j != -1 && k != -1) player.addChatMessage(new ChatComponentText("Chest out of range! You need to be " + ((int) player.getDistance(i + 0.5F, j + 0.5F, k + 0.5F) - 127) + " blocks closer.")); - else player.addChatMessage(new ChatComponentText("You need to link the ring with a chest first, before using it!")); - } - else if (JewelryNBT.isGemX(stack, new ItemStack(Items.ender_pearl)) && !JewelryNBT.hasTag(stack, "modifier") && JewelryNBT.playerPosX(stack) == -1 && JewelryNBT.playerPosY(stack) == -1 && JewelryNBT.playerPosZ(stack) == -1) - { - JewelryNBT.addCoordonatesAndDimension(stack, player.posX, player.posY, player.posZ, world.provider.dimensionId, world.provider.getDimensionName()); - JewelryNBT.addFakeEnchantment(stack); - } - - if (JewelryNBT.hasTag(stack, "mode")) - { - String mode = ""; - if (JewelryNBT.isModeX(stack, "Disenchant")) mode = "Transfer"; - else if (JewelryNBT.isModeX(stack, "Transfer")) mode = "Enchant"; - else if (JewelryNBT.isModeX(stack, "Enchant")) mode = "Disenchant"; - if (mode != "") - { - player.addChatMessage(new ChatComponentText("Switched to " + mode + " mode")); - JewelryNBT.addMode(stack, mode); - } - if (JewelryNBT.isModeX(stack, "Activated")) mode = "Deactivated"; - else if (JewelryNBT.isModeX(stack, "Deactivated")) mode = "Activated"; - if (mode != "" && mode != "Transfer" && mode != "Enchant" && mode != "Disenchant") - { - player.addChatMessage(new ChatComponentText("The Ring has been " + mode)); - JewelryNBT.addMode(stack, mode); - } - } - } - return stack; - } - - @Override - public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase entity) - { - if (!player.worldObj.isRemote && entity instanceof EntityLivingBase && JewelryNBT.isGemX(stack, new ItemStack(Items.nether_star)) && JewelryNBT.isModifierX(stack, new ItemStack(Blocks.chest)) && JewelryNBT.entity(stack, player) == null) - { - JewelryNBT.addEntity(stack, entity); - JewelryNBT.addEntityID(stack, entity); - entity.setDead(); - JewelryNBT.addFakeEnchantment(stack); - } - return true; - } - - /** - * allows items to add custom lines of information to the mouseover - * description - */ - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) - { - if (stack.hasTagCompound() && par4 && stack.getDisplayName() != "Wedding Ring") - { - ItemStack ingot = JewelryNBT.ingot(stack); - if (ingot != null && Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()) > 0) list.add("Ingot: " + EnumChatFormatting.YELLOW + ingot.getDisplayName()); - - ItemStack gem = JewelryNBT.gem(stack); - if (gem != null) list.add("Gem: " + EnumChatFormatting.BLUE + gem.getDisplayName()); - - ArrayList<ItemStack> modifier = JewelryNBT.modifier(stack); - if(!modifier.isEmpty()) list.add("Modifiers: "); - for(int i = 0; i < modifier.size(); i++) list.add(EnumChatFormatting.DARK_PURPLE + modifier.get(i).getDisplayName() + " x" + modifier.get(i).stackSize); - - double playerPosX = JewelryNBT.playerPosX(stack), playerPosY = JewelryNBT.playerPosY(stack), playerPosZ = JewelryNBT.playerPosZ(stack); - if (playerPosX != -1 && playerPosY != -1 && playerPosZ != -1) list.add(EnumChatFormatting.YELLOW + "X: " + EnumChatFormatting.GRAY + (int) playerPosX + EnumChatFormatting.YELLOW + " Y: " + EnumChatFormatting.GRAY + (int) playerPosY + EnumChatFormatting.YELLOW + " Z: " + EnumChatFormatting.GRAY + (int) playerPosZ); - - int posX = JewelryNBT.blockCoordX(stack), posY = JewelryNBT.blockCoordY(stack), posZ = JewelryNBT.blockCoordZ(stack); - if (posX != -1 && posY != -1 && posZ != -1) list.add(EnumChatFormatting.YELLOW + "X: " + EnumChatFormatting.GRAY + (int) posX + EnumChatFormatting.YELLOW + " Y: " + EnumChatFormatting.GRAY + (int) posY + EnumChatFormatting.YELLOW + " Z: " + EnumChatFormatting.GRAY + (int) posZ); - - String name = JewelryNBT.dimName(stack); - if (name != null) list.add("Dimension: " + EnumChatFormatting.DARK_GREEN + name); - - EntityLivingBase entity = JewelryNBT.entity(stack, player); - if (entity != null) list.add("Entity: " + EnumChatFormatting.GOLD + entity.getCommandSenderName()); - - String modeN = JewelryNBT.modeName(stack); - if (modeN != null) list.add("Mode: " + modeN); - - int block = JewelryNBT.blockID(stack); - if (block != -1) list.add("Block: " + StatCollector.translateToLocalFormatted(Block.getBlockById(block).getUnlocalizedName())); - - int blockmeta = JewelryNBT.blockMetadata(stack); - if (blockmeta != -1) list.add("Block Metadata: " + blockmeta); - - TileEntity tile = JewelryNBT.tileEntity(stack); - if (tile != null) list.add(EnumChatFormatting.RED + "Contains a tile entity"); - - int blockX = JewelryNBT.blockCoordX(stack); - if (blockX != -1) list.add("Block Coords X: " + blockX); - - int blockY = JewelryNBT.blockCoordY(stack); - if (blockY != -1) list.add("Block Coords Y: " + blockY); - - int blockZ = JewelryNBT.blockCoordZ(stack); - if (blockZ != -1) list.add("Block Coords Z: " + blockZ); - - // int colorI = JewelryNBT.ingotColor(stack); - // if(colorI != -1) list.add("Ingot Color: " + colorI); - // - // int colorJ = JewelryNBT.gemColor(stack); - // if(colorJ != -1) list.add("Jewel Color: " + colorJ); - } - } - - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int i, int j, int k, int side, float par8, float par9, float par10) - { - amplifier = 0; - if (JewelryNBT.isGemX(stack, new ItemStack(Items.diamond))) amplifier = 1; - else if (JewelryNBT.isGemX(stack, new ItemStack(Items.emerald))) amplifier = 2; - else if (JewelryNBT.isGemX(stack, new ItemStack(Items.nether_star))) amplifier = 7; - - if (!world.isRemote) - { - EntityLivingBase entity = JewelryNBT.entity(stack, player); - boolean used = false; - if (entity != null && entity instanceof EntityLivingBase) - { - entity.setLocationAndAngles(i + 0.5D, j + 1D, k + 0.5D, MathHelper.wrapAngleTo180_float(world.rand.nextFloat() * 360.0F), 0.0F); - world.spawnEntityInWorld(entity); - JewelryNBT.removeEntity(stack); - } - if (JewelryNBT.isGemX(stack, new ItemStack(Items.ender_pearl)) && JewelryNBT.isModifierX(stack, new ItemStack(Blocks.chest)) && world.getBlock(i, j, k) == Blocks.chest) JewelryNBT.addBlockCoordonates(stack, i, j, k); - onItemRightClick(stack, world, player); - if (JewelryNBT.isModifierX(stack, new ItemStack(Items.dye, 1, 15))) world.scheduleBlockUpdate(i, j, k, world.getBlock(i, j, k), 7 - amplifier); - if (JewelryNBT.isModifierX(stack, new ItemStack(Items.diamond_pickaxe)) && JewelryNBT.isGemX(stack, new ItemStack(Items.ender_pearl))) - { - if (JewelryNBT.hasTag(stack, "blockID") && !used) - { - int shiftX = 0, shiftY = 0, shiftZ = 0; - if (side == 0) shiftY = -1; - else if (side == 1) shiftY = 1; - else if (side == 2) shiftZ = -1; - else if (side == 3) shiftZ = 1; - else if (side == 4) shiftX = -1; - else if (side == 5) shiftX = 1; - world.setBlock(i + shiftX, j + shiftY, k + shiftZ, Block.getBlockById(JewelryNBT.blockID(stack))); - world.setBlockMetadataWithNotify(i + shiftX, j + shiftY, k + shiftZ, JewelryNBT.blockMetadata(stack), 2); - if (JewelryNBT.hasTag(stack, "tile")) world.setTileEntity(i + shiftX, j + shiftY, k + shiftZ, JewelryNBT.tileEntity(stack)); - if (JewelryNBT.tileEntity(stack) instanceof TileEntitySkull) ((BlockSkull) Blocks.skull).func_149965_a(world, i + shiftX, j + shiftY, k + shiftZ, (TileEntitySkull) JewelryNBT.tileEntity(stack)); - if (Block.getBlockById(JewelryNBT.blockID(stack)) == Blocks.pumpkin || Block.getBlockById(JewelryNBT.blockID(stack)) == Blocks.lit_pumpkin) createGolems(world, i + shiftX, j + shiftY, k + shiftZ); - JewelryNBT.removeBlock(stack); - used = true; - } - - if (!JewelryNBT.hasTag(stack, "tile") && world.getTileEntity(i, j, k) != null && !used && world.getBlock(i, j, k).getBlockHardness(world, i, j, k) > 0F) - { - JewelryNBT.addTileEntityBlock(stack, world, i, j, k); - world.removeTileEntity(i, j, k); - world.setBlock(i, j, k, Block.getBlockById(0)); - } - else if (!JewelryNBT.hasTag(stack, "blockID") && !used && world.getBlock(i, j, k).getBlockHardness(world, i, j, k) > 0F) - { - JewelryNBT.addBlock(stack, Block.getIdFromBlock(world.getBlock(i, j, k)), world.getBlockMetadata(i, j, k)); - JewelryNBT.addBlockCoordonates(stack, i, j, k); - world.setBlock(i, j, k, Block.getBlockById(0)); - } - } - if (JewelryNBT.isModifierX(stack, new ItemStack(Items.diamond_pickaxe)) && JewelryNBT.isGemX(stack, new ItemStack(Items.nether_star)) && JewelryNBT.isIngotX(stack, new ItemStack(ItemList.shadowIngot)) && j > 0 && world.getBlock(i, j, k).getBlockHardness(world, i, j, k) > 0F) world.func_147480_a(i, j, k, true); - } - return true; - } - - public boolean canDisenchant(EntityPlayer player) - { - if (player.capabilities.isCreativeMode) return true; - else if (player.experienceLevel >= 2) return true; - return false; - } - - public void dynamicLight(World world, EntityPlayer player) - { - world.setBlock((int) player.prevPosX, (int) player.prevPosY, (int) player.prevPosZ, Block.getBlockById(0)); - world.setBlock((int) player.posX, (int) player.posY, (int) player.posZ, BlockList.glow); - } - - @SuppressWarnings( - { "unchecked", "rawtypes" }) - @Override - public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) - { - amplifier = 0; - if (cooldown > 0) cooldown--; - if (!world.isRemote) - { - EntityPlayer entityplayer = (EntityPlayer) entity; - int posX = (int) Math.floor(entityplayer.posX), posY = (int) Math.floor(entityplayer.posY), posZ = (int) Math.floor(entityplayer.posZ); - - if (JewelryNBT.isGemX(stack, new ItemStack(Items.diamond))) amplifier = 1; - else if (JewelryNBT.isGemX(stack, new ItemStack(Items.emerald))) amplifier = 2; - else if (JewelryNBT.isGemX(stack, new ItemStack(Items.nether_star))) amplifier = 7; - - if (JewelryNBT.isModifierX(stack, new ItemStack(Items.dye, 1, 15)) && world.getBlock(posX, posY - 1, posZ) == Blocks.farmland) world.setBlockMetadataWithNotify(posX, posY - 1, posZ, 1, 7); - - if (JewelryNBT.isModeX(stack, "Activated")) - { - if (JewelryNBT.isModifierX(stack, new ItemStack(Items.blaze_powder)) && entityplayer != null) entityplayer.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 4, amplifier, true)); - else if (JewelryNBT.isModifierX(stack, new ItemStack(Items.sugar)) && entityplayer != null) - { - entityplayer.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 4, amplifier, true)); - entityplayer.addExhaustion(0.05f * amplifier); - } - else if (JewelryNBT.isModifierX(stack, new ItemStack(Items.iron_pickaxe)) && entityplayer != null && !JewelryNBT.isGemX(stack, new ItemStack(Items.ender_pearl))) entityplayer.addPotionEffect(new PotionEffect(Potion.digSpeed.id, 4, amplifier, true)); - else if (JewelryNBT.isModifierX(stack, new ItemStack(Items.feather)) && entityplayer != null) - { - entityplayer.addPotionEffect(new PotionEffect(Potion.jump.id, 4, amplifier, true)); - if (entityplayer.inventory.armorInventory[0] != null) - { - int damage = entityplayer.inventory.armorInventory[0].getMaxDamage() - entityplayer.inventory.armorInventory[0].getItemDamage(); - if (damage - entityplayer.fallDistance > 0) - { - entityplayer.inventory.armorInventory[0].damageItem((int) entityplayer.fallDistance, entityplayer); - entityplayer.fallDistance = 0; - } - else - { - --entityplayer.inventory.armorInventory[0].stackSize; - entityplayer.fallDistance -= damage; - } - } - } - else if (JewelryNBT.isModifierX(stack, new ItemStack(Items.potionitem, 1, 8270)) && entityplayer != null) entityplayer.addPotionEffect(new PotionEffect(Potion.invisibility.id, 4, amplifier, true)); - } - if (entityplayer.inventory.getCurrentItem() != null && JewelryNBT.isGemX(stack, new ItemStack(Items.nether_star)) && JewelryNBT.isModifierX(stack, new ItemStack(Items.book)) && entityplayer.inventory.getCurrentItem().getItem() == stack.getItem()) - { - ItemStack item = null; - if (entityplayer.inventory.currentItem + 1 <= 8 && entityplayer.inventory.getStackInSlot(entityplayer.inventory.currentItem + 1) != null && entityplayer.inventory.getStackInSlot(entityplayer.inventory.currentItem + 1).isItemEnchanted()) item = entityplayer.inventory.getStackInSlot(entityplayer.inventory.currentItem + 1); - if (entityplayer.inventory.currentItem - 1 >= 0 && entityplayer.inventory.getStackInSlot(entityplayer.inventory.currentItem - 1) != null && entityplayer.inventory.getStackInSlot(entityplayer.inventory.currentItem - 1).isItemEnchanted()) item = entityplayer.inventory.getStackInSlot(entityplayer.inventory.currentItem - 1); - if (item != null && JewelryNBT.isModeX(stack, "Disenchant")) - { - ItemStack enchBook = new ItemStack(Items.enchanted_book); - Map enchItem = EnchantmentHelper.getEnchantments(item); - Map book = EnchantmentHelper.getEnchantments(enchBook); - Iterator iterator = enchItem.keySet().iterator(); - int e; - - if (iterator.hasNext() && canDisenchant(entityplayer)) - { - e = ((Integer) iterator.next()).intValue(); - book.put(Integer.valueOf(e), Integer.valueOf(((Integer) enchItem.get(Integer.valueOf(e))).intValue())); - EnchantmentHelper.setEnchantments(book, enchBook); - if (entityplayer.inventory.addItemStackToInventory(enchBook)) - { - if (!entityplayer.capabilities.isCreativeMode) - { - entityplayer.addExperienceLevel(-2); - entityplayer.heal(-1f); - } - enchItem.remove(Integer.valueOf(e)); - if (item.isItemStackDamageable() && (item.getMaxDamage() - item.getItemDamage()) / 3 > 0) item.damageItem((item.getMaxDamage() - item.getItemDamage()) / 3, entityplayer); - EnchantmentHelper.setEnchantments(enchItem, item); - } - } - } - if (entityplayer.inventory.currentItem + 1 <= 8 && entityplayer.inventory.getStackInSlot(entityplayer.inventory.currentItem + 1) != null && entityplayer.inventory.currentItem - 1 >= 0 && entityplayer.inventory.getStackInSlot(entityplayer.inventory.currentItem - 1) != null && JewelryNBT.isModeX(stack, "Transfer")) - { - if (cooldown > 0) entityplayer.addChatMessage(new ChatComponentText("Ring is currently cooling down!")); - ItemStack enchantedItem = null, enchantableItem = null; - if (entityplayer.inventory.getStackInSlot(entityplayer.inventory.currentItem - 1).isItemEnchanted() && entityplayer.inventory.getStackInSlot(entityplayer.inventory.currentItem + 1) != null) - { - enchantedItem = entityplayer.inventory.getStackInSlot(entityplayer.inventory.currentItem - 1); - enchantableItem = entityplayer.inventory.getStackInSlot(entityplayer.inventory.currentItem + 1); - - } - if (enchantedItem != null && enchantableItem != null) - { - Map enchItem = EnchantmentHelper.getEnchantments(enchantedItem); - Map resultItem = EnchantmentHelper.getEnchantments(enchantableItem); - Iterator iterator = enchItem.keySet().iterator(); - int e; - - if (iterator.hasNext() && cooldown == 0) - { - e = ((Integer) iterator.next()).intValue(); - if (!EnchantmentHelper.getEnchantments(enchantableItem).containsKey(Integer.valueOf(e))) - { - resultItem.put(Integer.valueOf(e), Integer.valueOf(((Integer) enchItem.get(Integer.valueOf(e))).intValue())); - EnchantmentHelper.setEnchantments(resultItem, enchantableItem); - enchItem.remove(Integer.valueOf(e)); - EnchantmentHelper.setEnchantments(enchItem, enchantedItem); - cooldown = 50000; - } - } - } - } - if (entityplayer.inventory.currentItem + 1 <= 8 && entityplayer.inventory.getStackInSlot(entityplayer.inventory.currentItem + 1) != null) item = entityplayer.inventory.getStackInSlot(entityplayer.inventory.currentItem + 1); - else if (entityplayer.inventory.currentItem - 1 >= 0 && entityplayer.inventory.getStackInSlot(entityplayer.inventory.currentItem - 1) != null) item = entityplayer.inventory.getStackInSlot(entityplayer.inventory.currentItem - 1); - if (item != null && !item.isItemEnchanted() && item.isItemEnchantable() && entityplayer.experienceLevel > 0 && JewelryNBT.isModeX(stack, "Enchant")) - { - Map enchItem = EnchantmentHelper.getEnchantments(item); - int level = entityplayer.experienceLevel; - if (entityplayer.experienceLevel > 6) level = 6; - if (!entityplayer.capabilities.isCreativeMode) entityplayer.addExperienceLevel(-level); - enchItem.put(Enchantment.enchantmentsBookList[new Random().nextInt(Enchantment.enchantmentsBookList.length)].effectId, level); - EnchantmentHelper.setEnchantments(enchItem, item); - } - } - } - } - - public ItemStack getModifiedItemStack(ItemStack ingot, ItemStack modifier, ItemStack gem) - { - ItemStack itemstack = new ItemStack(this); - JewelryNBT.addMetal(itemstack, ingot); - JewelryNBT.addModifiers(itemstack, JewelrycraftUtil.addRandomModifiers()); - JewelryNBT.addGem(itemstack, gem); -// if (JewelryNBT.isModifierEffectType(itemstack) && !(JewelryNBT.isGemX(itemstack, new ItemStack(Items.ender_pearl)) && JewelryNBT.isModifierX(itemstack, new ItemStack(Items.iron_pickaxe)))) JewelryNBT.addMode(itemstack, "Activated"); - if (JewelryNBT.isGemX(itemstack, new ItemStack(Items.nether_star)) && JewelryNBT.isModifierX(itemstack, new ItemStack(Items.book))) JewelryNBT.addMode(itemstack, "Disenchant"); - return itemstack; - } - - public void createGolems(World world, int i, int j, int k) - { - if (world.getBlock(i, j - 1, k) == Blocks.snow && world.getBlock(i, j - 2, k) == Blocks.snow) - { - if (!world.isRemote) - { - world.setBlock(i, j, k, Block.getBlockById(0), 0, 2); - world.setBlock(i, j - 1, k, Block.getBlockById(0), 0, 2); - world.setBlock(i, j - 2, k, Block.getBlockById(0), 0, 2); - EntitySnowman entitysnowman = new EntitySnowman(world); - entitysnowman.setLocationAndAngles((double) i + 0.5D, (double) j - 1.95D, (double) k + 0.5D, 0.0F, 0.0F); - world.spawnEntityInWorld(entitysnowman); - world.notifyBlockChange(i, j, k, Block.getBlockById(0)); - world.notifyBlockChange(i, j - 1, k, Block.getBlockById(0)); - world.notifyBlockChange(i, j - 2, k, Block.getBlockById(0)); - } - - for (int l = 0; l < 120; ++l) - { - world.spawnParticle("snowshovel", (double) i + world.rand.nextDouble(), (double) (j - 2) + world.rand.nextDouble() * 2.5D, (double) k + world.rand.nextDouble(), 0.0D, 0.0D, 0.0D); - } - } - else if (world.getBlock(i, j - 1, k) == Blocks.iron_block && world.getBlock(i, j - 2, k) == Blocks.iron_block) - { - boolean flag = world.getBlock(i - 1, j - 1, k) == Blocks.iron_block && world.getBlock(i + 1, j - 1, k) == Blocks.iron_block; - boolean flag1 = world.getBlock(i, j - 1, k - 1) == Blocks.iron_block && world.getBlock(i, j - 1, k + 1) == Blocks.iron_block; - - if (flag || flag1) - { - world.setBlock(i, j, k, Block.getBlockById(0), 0, 2); - world.setBlock(i, j - 1, k, Block.getBlockById(0), 0, 2); - world.setBlock(i, j - 2, k, Block.getBlockById(0), 0, 2); - - if (flag) - { - world.setBlock(i - 1, j - 1, k, Block.getBlockById(0), 0, 2); - world.setBlock(i + 1, j - 1, k, Block.getBlockById(0), 0, 2); - } - else - { - world.setBlock(i, j - 1, k - 1, Block.getBlockById(0), 0, 2); - world.setBlock(i, j - 1, k + 1, Block.getBlockById(0), 0, 2); - } - - EntityIronGolem entityirongolem = new EntityIronGolem(world); - entityirongolem.setPlayerCreated(true); - entityirongolem.setLocationAndAngles((double) i + 0.5D, (double) j - 1.95D, (double) k + 0.5D, 0.0F, 0.0F); - world.spawnEntityInWorld(entityirongolem); - - for (int i1 = 0; i1 < 120; ++i1) - { - world.spawnParticle("snowballpoof", (double) i + world.rand.nextDouble(), (double) (j - 2) + world.rand.nextDouble() * 3.9D, (double) k + world.rand.nextDouble(), 0.0D, 0.0D, 0.0D); - } - - world.notifyBlockChange(i, j, k, Block.getBlockById(0)); - world.notifyBlockChange(i, j - 1, k, Block.getBlockById(0)); - world.notifyBlockChange(i, j - 2, k, Block.getBlockById(0)); - - if (flag) - { - world.notifyBlockChange(i - 1, j - 1, k, Block.getBlockById(0)); - world.notifyBlockChange(i + 1, j - 1, k, Block.getBlockById(0)); - } - else - { - world.notifyBlockChange(i, j - 1, k - 1, Block.getBlockById(0)); - world.notifyBlockChange(i, j - 1, k + 1, Block.getBlockById(0)); - } - } - } - } } diff --git a/java/darkknight/jewelrycraft/item/ItemThiefGloves.java b/java/darkknight/jewelrycraft/item/ItemThiefGloves.java index 344f9a6..658e9cc 100644 --- a/java/darkknight/jewelrycraft/item/ItemThiefGloves.java +++ b/java/darkknight/jewelrycraft/item/ItemThiefGloves.java @@ -11,6 +11,9 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.Potion; +import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; import net.minecraft.village.MerchantRecipe; @@ -21,10 +24,11 @@ import org.lwjgl.input.Keyboard; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.relauncher.ReflectionHelper; import cpw.mods.fml.relauncher.Side; +import darkknight.jewelrycraft.util.PlayerUtils; public class ItemThiefGloves extends Item { - public Random rand; + public Random rand = new Random(); public ItemThiefGloves() { @@ -35,43 +39,91 @@ public class ItemThiefGloves extends Item } @Override - public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer par2EntityPlayer, EntityLivingBase par3EntityLivingBase) + public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase entity) { - if (par3EntityLivingBase instanceof EntityVillager) + if (entity instanceof EntityVillager) { - EntityVillager villager = (EntityVillager) par3EntityLivingBase; + EntityVillager villager = (EntityVillager) entity; int wealth = (Integer) ReflectionHelper.getPrivateValue(EntityVillager.class, villager, "wealth", "field_70956_bz"); MerchantRecipeList buyingList = (MerchantRecipeList) ReflectionHelper.getPrivateValue(EntityVillager.class, villager, "buyingList", "field_70963_i"); + int chance = 5; + boolean areOtherVillagersAround = false, canTheySeeYou = false; + AxisAlignedBB axisalignedbb = villager.boundingBox.expand(4.0D, 4.0D, 4.0D); + List entities = villager.worldObj.getEntitiesWithinAABBExcludingEntity(villager, axisalignedbb); + for (Object s : entities) + if (s instanceof EntityVillager) + { + areOtherVillagersAround = true; + chance += rand.nextInt(2); + if (((EntityVillager) s).canEntityBeSeen(player)) + { + chance += 2; + canTheySeeYou = true; + } + } + if (villager.canEntityBeSeen(player)) chance += 5; + if (player.isPotionActive(Potion.invisibility)) chance -= (0.8 * chance); + if (player.capabilities.isCreativeMode) chance = 1; + int steal = rand.nextInt(chance); + NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, "Jewelrycraft"); if (buyingList != null) { Iterator<?> iterator = buyingList.iterator(); - while (iterator.hasNext()) + if (steal == 0) + { + while (iterator.hasNext()) + { + MerchantRecipe recipe = (MerchantRecipe) iterator.next(); + int toolUses = (Integer) ReflectionHelper.getPrivateValue(MerchantRecipe.class, recipe, "toolUses", "field_77400_d"); + int quantity; + if (recipe.getItemToSell().isStackable()) quantity = recipe.getItemToSell().stackSize * (7 - toolUses); + else quantity = recipe.getItemToSell().stackSize; + ItemStack s = new ItemStack(recipe.getItemToSell().getItem(), quantity, recipe.getItemToSell().getItemDamage()); + s.setTagCompound(recipe.getItemToSell().getTagCompound()); + if (player.inventory.addItemStackToInventory(s)) + ; + else villager.entityDropItem(s, 0); + if (playerInfo.hasKey("cursePoints")) playerInfo.setInteger("cursePoints", playerInfo.getInteger("cursePoints") + 5); + else playerInfo.setInteger("cursePoints", 5); + player.addChatMessage(new ChatComponentText("Villager #" + villager.getProfession() + ": Hmmm... I seem to have lost my " + s.getDisplayName() + "!")); + stack.damageItem(1, player); + } + buyingList.clear(); + ReflectionHelper.setPrivateValue(EntityVillager.class, villager, 300, "timeUntilReset", "field_70961_j"); + ReflectionHelper.setPrivateValue(EntityVillager.class, villager, true, "needsInitilization", "field_70959_by"); + player.addChatMessage(new ChatComponentText("You hear a faint whisper in your ear: ")); + player.addChatMessage(new ChatComponentText(EnumChatFormatting.DARK_PURPLE + "Those who steal but don't get caught get rewarded and do not.")); + player.addChatMessage(new ChatComponentText(EnumChatFormatting.DARK_PURPLE + "Embrace the path you have gone, for the darkness will not")); + player.addChatMessage(new ChatComponentText(EnumChatFormatting.DARK_PURPLE + "dwell on.")); + } + else { - MerchantRecipe recipe = (MerchantRecipe) iterator.next(); - int toolUses = (Integer) ReflectionHelper.getPrivateValue(MerchantRecipe.class, recipe, "toolUses", "field_77400_d"); - int quantity; - if (recipe.getItemToSell().isStackable()) quantity = recipe.getItemToSell().stackSize * (7 - toolUses); - else quantity = 1; - ItemStack s = new ItemStack(recipe.getItemToSell().getItem(), quantity, recipe.getItemToSell().getItemDamage()); - s.setTagCompound(recipe.getItemToSell().getTagCompound()); - if (par2EntityPlayer.inventory.addItemStackToInventory(s)) - ; - else villager.entityDropItem(s, 0); - par2EntityPlayer.addChatMessage(new ChatComponentText("Villager #" + villager.getProfession() + ": Hmmm... I seem to have lost my " + s.getDisplayName() + "!")); - stack.damageItem(1, par2EntityPlayer); + if (player.isPotionActive(Potion.invisibility)) player.addChatMessage(new ChatComponentText("Villager #" + villager.getProfession() + " sensed a strange presence around him, making him cling on to his items. You didn't get anything.")); + else + { + if (areOtherVillagersAround) + { + if (!canTheySeeYou) player.addChatMessage(new ChatComponentText("As he was passing by, a random villager caught you trying to steal from Villager #" + villager.getProfession() + ".")); + else player.addChatMessage(new ChatComponentText("A villager nearby saw you trying to steal from Villager #" + villager.getProfession() + ".")); + } + else player.addChatMessage(new ChatComponentText("Villager #" + villager.getProfession() + " caught you trying to steal from him.")); + player.addChatMessage(new ChatComponentText("Villager #" + villager.getProfession() + " curses you for the attempt.")); + } + stack.damageItem(1, player); + if (playerInfo.hasKey("cursePoints")) playerInfo.setInteger("cursePoints", playerInfo.getInteger("cursePoints") + 25); + else playerInfo.setInteger("cursePoints", 25); } - buyingList.clear(); - ReflectionHelper.setPrivateValue(EntityVillager.class, villager, 300, "timeUntilReset", "field_70961_j"); - ReflectionHelper.setPrivateValue(EntityVillager.class, villager, true, "needsInitilization", "field_70959_by"); } - - villager.dropItem(Items.emerald, wealth); - ReflectionHelper.setPrivateValue(EntityVillager.class, villager, 0, "wealth", "field_70956_bz"); + if (steal == 0) + { + villager.dropItem(Items.emerald, wealth); + ReflectionHelper.setPrivateValue(EntityVillager.class, villager, 0, "wealth", "field_70956_bz"); + } return true; } else { - return super.itemInteractionForEntity(stack, par2EntityPlayer, par3EntityLivingBase); + return super.itemInteractionForEntity(stack, player, entity); } } diff --git a/java/darkknight/jewelrycraft/lib/Reference.java b/java/darkknight/jewelrycraft/lib/Reference.java index 24e8751..03dac51 100644 --- a/java/darkknight/jewelrycraft/lib/Reference.java +++ b/java/darkknight/jewelrycraft/lib/Reference.java @@ -4,6 +4,6 @@ public class Reference { public static final String MODID = "Jewelrycraft"; public static final String MODNAME = "Jewelrycraft"; - public static final String VERSION = "1.5"; + public static final String VERSION = "2.0"; public static final String PACKET_CHANNEL = "Jewelrycraft"; } diff --git a/java/darkknight/jewelrycraft/network/PacketRequestLiquidData.java b/java/darkknight/jewelrycraft/network/PacketRequestLiquidData.java index 5e394ed..6fd3274 100644 --- a/java/darkknight/jewelrycraft/network/PacketRequestLiquidData.java +++ b/java/darkknight/jewelrycraft/network/PacketRequestLiquidData.java @@ -34,15 +34,16 @@ public class PacketRequestLiquidData implements IMessage, IMessageHandler<Packet IMessage replyPacket = null; - if (splitData.length == 2) + if (splitData.length == 3) { - int itemID, itemDamage; + int itemID, itemDamage, color; try { itemID = Integer.parseInt(splitData[0]); itemDamage = Integer.parseInt(splitData[1]); + color = Integer.parseInt(splitData[2]); - replyPacket = (IMessage) new PacketSendLiquidData(message, itemID, itemDamage); + replyPacket = (IMessage) new PacketSendLiquidData(message, itemID, itemDamage, color); } catch (Exception e) { diff --git a/java/darkknight/jewelrycraft/network/PacketSendLiquidData.java b/java/darkknight/jewelrycraft/network/PacketSendLiquidData.java index 258b6cb..436daba 100644 --- a/java/darkknight/jewelrycraft/network/PacketSendLiquidData.java +++ b/java/darkknight/jewelrycraft/network/PacketSendLiquidData.java @@ -11,13 +11,13 @@ import io.netty.buffer.ByteBuf; public class PacketSendLiquidData implements IMessage, IMessageHandler<PacketSendLiquidData, IMessage> { - int dimID, x, y, z, itemID, itemMeta; + int dimID, x, y, z, itemID, itemMeta, color; public PacketSendLiquidData() { } - public PacketSendLiquidData(PacketRequestLiquidData packet, int itemID, int itemMeta) + public PacketSendLiquidData(PacketRequestLiquidData packet, int itemID, int itemMeta, int color) { dimID = packet.dimID; x = packet.x; @@ -25,9 +25,10 @@ public class PacketSendLiquidData implements IMessage, IMessageHandler<PacketSen z = packet.z; this.itemID = itemID; this.itemMeta = itemMeta; + this.color = color; } - public PacketSendLiquidData(int dimID, int x, int y, int z, int itemID, int itemMeta) + public PacketSendLiquidData(int dimID, int x, int y, int z, int itemID, int itemMeta, int color) { this.dimID = dimID; this.x = x; @@ -35,6 +36,7 @@ public class PacketSendLiquidData implements IMessage, IMessageHandler<PacketSen this.z = z; this.itemID = itemID; this.itemMeta = itemMeta; + this.color = color; } @Override @@ -46,6 +48,7 @@ public class PacketSendLiquidData implements IMessage, IMessageHandler<PacketSen z = buf.readInt(); itemID = buf.readInt(); itemMeta = buf.readInt(); + color = buf.readInt(); } @Override @@ -57,12 +60,13 @@ public class PacketSendLiquidData implements IMessage, IMessageHandler<PacketSen buf.writeInt(z); buf.writeInt(itemID); buf.writeInt(itemMeta); + buf.writeInt(color); } @Override public IMessage onMessage(PacketSendLiquidData message, MessageContext ctx) { - JewelrycraftMod.clientData.setString(message.x + " " + message.y + " " + message.z + " " + message.dimID, message.itemID + ":" + message.itemMeta); + JewelrycraftMod.clientData.setString(message.x + " " + message.y + " " + message.z + " " + message.dimID, message.itemID + ":" + message.itemMeta + ":" + message.color); Block block = Minecraft.getMinecraft().theWorld.getBlock(message.x, message.y, message.z); Minecraft.getMinecraft().theWorld.markBlockForUpdate(message.x, message.y, message.z); diff --git a/java/darkknight/jewelrycraft/recipes/CraftingRecipes.java b/java/darkknight/jewelrycraft/recipes/CraftingRecipes.java index 6e01d4b..10246ef 100644 --- a/java/darkknight/jewelrycraft/recipes/CraftingRecipes.java +++ b/java/darkknight/jewelrycraft/recipes/CraftingRecipes.java @@ -23,6 +23,8 @@ public class CraftingRecipes 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); + GameRegistry.addRecipe(new ItemStack(ItemList.clayMolds, 1, 4), "x x", 'x', Items.clay_ball); GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ItemList.crystal, 1, 15), " x ", "x x", " x ", 'x', Blocks.glass)); for (int i = 0; i < 15; i++) { @@ -39,6 +41,10 @@ public class CraftingRecipes { new ItemStack(Items.book), new ItemStack(ItemList.molds, 1, 1) }); GameRegistry.addShapelessRecipe(new ItemStack(ItemList.guide), new Object[] { new ItemStack(Items.book), new ItemStack(ItemList.molds, 1, 2) }); + GameRegistry.addShapelessRecipe(new ItemStack(ItemList.guide), 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)); @@ -53,6 +59,8 @@ public class CraftingRecipes GameRegistry.addSmelting(new ItemStack(ItemList.clayMolds, 1, 0), new ItemStack(ItemList.molds, 1, 0), 0.2F); GameRegistry.addSmelting(new ItemStack(ItemList.clayMolds, 1, 1), new ItemStack(ItemList.molds, 1, 1), 0.2F); GameRegistry.addSmelting(new ItemStack(ItemList.clayMolds, 1, 2), new ItemStack(ItemList.molds, 1, 2), 0.2F); + GameRegistry.addSmelting(new ItemStack(ItemList.clayMolds, 1, 3), new ItemStack(ItemList.molds, 1, 3), 0.2F); + GameRegistry.addSmelting(new ItemStack(ItemList.clayMolds, 1, 4), new ItemStack(ItemList.molds, 1, 4), 0.2F); isInitialized = true; } diff --git a/java/darkknight/jewelrycraft/renders/TileEntityMolderRender.java b/java/darkknight/jewelrycraft/renders/TileEntityMolderRender.java index ce11078..29598c4 100644 --- a/java/darkknight/jewelrycraft/renders/TileEntityMolderRender.java +++ b/java/darkknight/jewelrycraft/renders/TileEntityMolderRender.java @@ -2,11 +2,11 @@ package darkknight.jewelrycraft.renders; import org.lwjgl.opengl.GL11; +import darkknight.jewelrycraft.JewelrycraftMod; import darkknight.jewelrycraft.item.ItemList; import darkknight.jewelrycraft.model.ModelMolder; import darkknight.jewelrycraft.tileentity.TileEntityMolder; import darkknight.jewelrycraft.util.JewelryNBT; - import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.OpenGlHelper; @@ -16,6 +16,7 @@ import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; +import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; @@ -93,8 +94,15 @@ public class TileEntityMolderRender extends TileEntitySpecialRenderer { GL11.glPushMatrix(); GL11.glDisable(GL11.GL_LIGHTING); + if (JewelrycraftMod.fancyRender) + { + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(1, 1, 0, 0); + } ItemStack metal = new ItemStack(ItemList.metal); - JewelryNBT.addMetal(metal, me.moltenMetal); + ItemStack ingot = me.moltenMetal.copy(); + if (Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_glass) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_hardened_clay) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.wool) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.carpet)) ingot.setItemDamage(15 - ingot.getItemDamage()); + JewelryNBT.addMetal(metal, ingot); EntityItem moltenMetal = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, metal); moltenMetal.getEntityItem().stackSize = 1; moltenMetal.hoverStart = 0.0F; @@ -105,6 +113,7 @@ public class TileEntityMolderRender extends TileEntitySpecialRenderer RenderItem.renderInFrame = true; RenderManager.instance.renderEntityWithPosYaw(moltenMetal, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); RenderItem.renderInFrame = false; + if (JewelrycraftMod.fancyRender) GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_LIGHTING); GL11.glPopMatrix(); } diff --git a/java/darkknight/jewelrycraft/renders/TileEntitySmelterRender.java b/java/darkknight/jewelrycraft/renders/TileEntitySmelterRender.java index 0ce030e..0e51e7f 100644 --- a/java/darkknight/jewelrycraft/renders/TileEntitySmelterRender.java +++ b/java/darkknight/jewelrycraft/renders/TileEntitySmelterRender.java @@ -122,9 +122,9 @@ public class TileEntitySmelterRender extends TileEntitySpecialRenderer OpenGlHelper.glBlendFunc(1, 1, 0, 0); } ItemStack metal = new ItemStack(ItemList.metal); - ItemStack stack = new ItemStack(st.moltenMetal.getItem(), 1, st.moltenMetal.getItemDamage()); - if (Item.getIdFromItem(stack.getItem()) == Block.getIdFromBlock(Blocks.stained_glass) || Item.getIdFromItem(stack.getItem()) == Block.getIdFromBlock(Blocks.stained_glass_pane) || Item.getIdFromItem(stack.getItem()) == Block.getIdFromBlock(Blocks.stained_hardened_clay) || Item.getIdFromItem(stack.getItem()) == Block.getIdFromBlock(Blocks.wool) || Item.getIdFromItem(stack.getItem()) == Block.getIdFromBlock(Blocks.carpet)) stack.setItemDamage(15 - stack.getItemDamage()); - JewelryNBT.addMetal(metal, stack); + ItemStack ingot = st.moltenMetal.copy(); + if (Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_glass) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_hardened_clay) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.wool) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.carpet)) ingot.setItemDamage(15 - ingot.getItemDamage()); + JewelryNBT.addMetal(metal, ingot); EntityItem moltenMetal = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, metal); moltenMetal.getEntityItem().stackSize = 1; moltenMetal.hoverStart = 0.0F; diff --git a/java/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java b/java/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java index 5e91624..8fcf62f 100644 --- a/java/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java +++ b/java/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java @@ -17,6 +17,7 @@ import net.minecraft.util.MathHelper; import darkknight.jewelrycraft.config.ConfigHandler; import darkknight.jewelrycraft.particles.EntityShadowsFX; import darkknight.jewelrycraft.util.JewelryNBT; +import darkknight.jewelrycraft.util.JewelrycraftUtil; public class TileEntityJewelrsCraftingTable extends TileEntity { @@ -96,7 +97,6 @@ public class TileEntityJewelrsCraftingTable extends TileEntity if (angle < 360F) angle += 3F; else angle = 0F; - if (carving > 0) System.out.println(carving); if (this.hasJewelry && this.hasGem && !this.hasEndItem && crafting) { if (carving > 0) carving--; @@ -104,6 +104,7 @@ public class TileEntityJewelrsCraftingTable extends TileEntity { for (int l = 0; l < ConfigHandler.jewelryCraftingTime / (carving + 2); ++l) { + if (worldObj.rand.nextInt(10) == 0) this.worldObj.playSoundEffect(xCoord, yCoord + 0.5F, zCoord, "random.orb", 0.05F, 1F); if (this.getBlockMetadata() == 0) this.worldObj.spawnParticle("instantSpell", xCoord + 0.5F, (double) yCoord + 0.8F, zCoord + 0.2F, 0.0D, 0.0D, 0.0D); if (this.getBlockMetadata() == 1) this.worldObj.spawnParticle("instantSpell", xCoord + 0.8F, (double) yCoord + 0.8F, zCoord + 0.5F, 0.0D, 0.0D, 0.0D); if (this.getBlockMetadata() == 2) this.worldObj.spawnParticle("instantSpell", xCoord + 0.5F, (double) yCoord + 0.8F, zCoord + 0.8F, 0.0D, 0.0D, 0.0D); @@ -127,7 +128,12 @@ public class TileEntityJewelrsCraftingTable extends TileEntity { ItemStack aux = JewelryNBT.gem(jewelry); JewelryNBT.addGem(endItem, gem); - gem = aux.copy(); + if(JewelrycraftUtil.rand.nextBoolean()) gem = aux.copy(); + else + { + this.hasGem = false; + this.gem = new ItemStack(Item.getItemById(0), 0, 0); + } } } this.hasJewelry = false; diff --git a/java/darkknight/jewelrycraft/tileentity/TileEntityMolder.java b/java/darkknight/jewelrycraft/tileentity/TileEntityMolder.java index 6006dea..62ec130 100644 --- a/java/darkknight/jewelrycraft/tileentity/TileEntityMolder.java +++ b/java/darkknight/jewelrycraft/tileentity/TileEntityMolder.java @@ -1,5 +1,7 @@ package darkknight.jewelrycraft.tileentity; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -90,13 +92,15 @@ public class TileEntityMolder extends TileEntity } if (this.hasMoltenMetal && !this.hasJewelBase && quantity >= 0.1f) { - ringMetal = moltenMetal; + ringMetal = moltenMetal.copy(); if (cooling > 0) this.cooling--; if (cooling <= 0f) { if (mold.getItemDamage() == 0) this.jewelBase = moltenMetal; else if (mold.getItemDamage() == 1) this.jewelBase = new ItemStack(ItemList.ring); - else this.jewelBase = new ItemStack(ItemList.necklace); + else if (mold.getItemDamage() == 2) this.jewelBase = new ItemStack(ItemList.necklace); + else if (mold.getItemDamage() == 3) this.jewelBase = new ItemStack(ItemList.bracelet); + else if (mold.getItemDamage() == 4) this.jewelBase = new ItemStack(ItemList.earrings); ringMetal.stackSize = 1; jewelBase.stackSize = 1; if (mold.getItemDamage() != 0 && jewelBase != new ItemStack(Item.getItemById(0), 0, 0)) JewelryNBT.addMetal(jewelBase, ringMetal); diff --git a/java/darkknight/jewelrycraft/tileentity/TileEntityShadowEye.java b/java/darkknight/jewelrycraft/tileentity/TileEntityShadowEye.java index 0aff8df..7a7a7c3 100644 --- a/java/darkknight/jewelrycraft/tileentity/TileEntityShadowEye.java +++ b/java/darkknight/jewelrycraft/tileentity/TileEntityShadowEye.java @@ -1,11 +1,12 @@ package darkknight.jewelrycraft.tileentity; import java.util.ArrayList; -import java.util.Iterator; +import java.util.List; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; @@ -13,6 +14,7 @@ import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; +import cpw.mods.fml.common.registry.GameData; import darkknight.jewelrycraft.block.BlockHandPedestal; import darkknight.jewelrycraft.block.BlockList; import darkknight.jewelrycraft.particles.EntityShadowsFX; @@ -118,14 +120,6 @@ public class TileEntityShadowEye extends TileEntity persistTag.setBoolean("nearStartedRitual", true); } } - try - { - // System.out.println(pedestalItems); - } - catch (Exception e) - { - // System.out.println(e); - } } public boolean isValidStructure(World world, int x, int y, int z, int metadata) @@ -213,8 +207,6 @@ public class TileEntityShadowEye extends TileEntity public void addData(World world, int x, int y, int z) { pedestalItems.clear(); - // addPedestalInfo((TileEntityHandPedestal) world.getTileEntity(x, y - - // 3, z)); addPedestalInfo((TileEntityHandPedestal) world.getTileEntity(x + 2, y - 3, z - 4)); addPedestalInfo((TileEntityHandPedestal) world.getTileEntity(x - 4, y - 3, z + 2)); addPedestalInfo((TileEntityHandPedestal) world.getTileEntity(x, y - 3, z - 5)); @@ -231,7 +223,6 @@ public class TileEntityShadowEye extends TileEntity public void addPedestalInfo(TileEntityHandPedestal pedestal) { - System.out.println(pedestalItems); if (pedestal != null && pedestal.object != null && pedestal.object.getItem() != null) { if (pedestalItems.isEmpty()) pedestalItems.add(pedestal.object.copy()); 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()) { diff --git a/java/darkknight/jewelrycraft/worldGen/village/ComponentJewelry.java b/java/darkknight/jewelrycraft/worldGen/village/ComponentJewelry.java index aadc084..f07a4a6 100644 --- a/java/darkknight/jewelrycraft/worldGen/village/ComponentJewelry.java +++ b/java/darkknight/jewelrycraft/worldGen/village/ComponentJewelry.java @@ -235,8 +235,7 @@ public class ComponentJewelry extends StructureVillagePieces.House1 { ItemStack jewels = JewelrycraftUtil.gem.get(random.nextInt(JewelrycraftUtil.gem.size())); chest.func_145976_a("Jeweler's Chest"); - if (random.nextBoolean()) chest.setInventorySlotContents(random.nextInt(chest.getSizeInventory()), JewelrycraftUtil.modifiers.get(random.nextInt(JewelrycraftUtil.modifiers.size()))); - else if (jewels.getItem() == Items.nether_star && ConfigHandler.generateVillageNetherstar) chest.setInventorySlotContents(random.nextInt(chest.getSizeInventory()), jewels); + if (jewels.getItem() == Items.nether_star && ConfigHandler.generateVillageNetherstar) chest.setInventorySlotContents(random.nextInt(chest.getSizeInventory()), jewels); else if (random.nextBoolean() && jewels.getItem() != Items.nether_star) chest.setInventorySlotContents(random.nextInt(chest.getSizeInventory()), jewels); t--; } @@ -289,13 +288,12 @@ public class ComponentJewelry extends StructureVillagePieces.House1 TileEntityDisplayer displayer = (TileEntityDisplayer) world.getTileEntity(i1, j1, k1); if (displayer != null) { - ItemStack ring = new ItemStack(ItemList.ring); - JewelryNBT.addMetal(ring, JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size()))); - JewelryNBT.addModifiers(ring, JewelrycraftUtil.addRandomModifiers()); - JewelryNBT.addGem(ring, JewelrycraftUtil.gem.get(random.nextInt(JewelrycraftUtil.gem.size()))); -// if (JewelryNBT.isModifierEffectType(ring)) JewelryNBT.addMode(ring, "Activated"); - if (JewelryNBT.isGemX(ring, new ItemStack(Items.nether_star)) && JewelryNBT.isModifierX(ring, new ItemStack(Items.book))) JewelryNBT.addMode(ring, "Disenchant"); - displayer.object = ring; + Item[] jewels = {ItemList.ring, ItemList.necklace}; + ItemStack jewel = new ItemStack(jewels[random.nextInt(jewels.length)]); + JewelryNBT.addMetal(jewel, JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size()))); + JewelryNBT.addModifiers(jewel, JewelrycraftUtil.addRandomModifiers(random.nextInt(4))); + JewelryNBT.addGem(jewel, JewelrycraftUtil.gem.get(random.nextInt(JewelrycraftUtil.gem.size()))); + displayer.object = jewel; displayer.quantity = 1; displayer.hasObject = true; } diff --git a/java/darkknight/jewelrycraft/worldGen/village/JCTrades.java b/java/darkknight/jewelrycraft/worldGen/village/JCTrades.java index bddf7b3..1d474b0 100644 --- a/java/darkknight/jewelrycraft/worldGen/village/JCTrades.java +++ b/java/darkknight/jewelrycraft/worldGen/village/JCTrades.java @@ -11,6 +11,7 @@ import net.minecraft.village.MerchantRecipeList; import cpw.mods.fml.common.registry.VillagerRegistry.IVillageTradeHandler; import darkknight.jewelrycraft.block.BlockList; import darkknight.jewelrycraft.item.ItemList; +import darkknight.jewelrycraft.item.ItemMolds; import darkknight.jewelrycraft.util.JewelryNBT; import darkknight.jewelrycraft.util.JewelrycraftUtil; @@ -37,82 +38,55 @@ public class JCTrades implements IVillageTradeHandler case 0: { result = JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size())); - result.stackSize = 5 + random.nextInt(8); - ingredient = new ItemStack(Items.emerald, 2 + random.nextInt(2)); + result.stackSize = 5 + random.nextInt(5); + ingredient = new ItemStack(Items.emerald, 2 + random.nextInt(7)); if (random.nextBoolean()) ingredient2 = new ItemStack(Items.emerald, 2 + random.nextInt(2)); break; } case 1: { - result = new ItemStack(ItemList.molds, 5 + random.nextInt(7), random.nextInt(2)); - ingredient = new ItemStack(Items.emerald, 1 + random.nextInt(1)); + result = new ItemStack(ItemList.molds, 5 + random.nextInt(7), random.nextInt(ItemMolds.moldsItemNames.length)); + ingredient = new ItemStack(Items.emerald, 1); if (random.nextBoolean()) ingredient2 = new ItemStack(Items.emerald, 1 + random.nextInt(2)); break; } case 2: { - result = new ItemStack(ItemList.thiefGloves); - ingredient = new ItemStack(Items.emerald, 16 + random.nextInt(8)); - if (random.nextBoolean()) ingredient2 = new ItemStack(Items.emerald, 8 + random.nextInt(4)); + int number = random.nextInt(3); + result = new ItemStack(BlockList.displayer, 1 + number); + ingredient = new ItemStack(Blocks.emerald_block, 2 + number*3 + random.nextInt(2)); + ingredient2 = new ItemStack(Items.emerald, 3 + number + random.nextInt(8)); break; } case 3: { - result = new ItemStack(BlockList.displayer, 1 + random.nextInt(6)); - ingredient = new ItemStack(Items.emerald, 3 + random.nextInt(8)); - if (random.nextBoolean()) ingredient2 = new ItemStack(Items.emerald, 3 + random.nextInt(8)); - break; - } - case 4: - { result = new ItemStack(BlockList.jewelCraftingTable); ingredient = new ItemStack(Items.emerald, 1 + random.nextInt(2)); if (random.nextBoolean()) ingredient2 = new ItemStack(Items.emerald, 1 + random.nextInt(2)); break; } - case 5: + case 4: { - result = new ItemStack(BlockList.shadowOre, 1 + random.nextInt(16)); + result = new ItemStack(BlockList.shadowOre, 1 + random.nextInt(6)); ingredient = new ItemStack(Items.emerald, 3 + random.nextInt(4)); if (random.nextBoolean()) ingredient2 = new ItemStack(Items.emerald, 3 + random.nextInt(4)); break; } - case 6: + case 5: { result = new ItemStack(BlockList.molder, 5 + random.nextInt(5)); - ingredient = new ItemStack(Items.emerald, 1 + random.nextInt(1)); - if (random.nextBoolean()) ingredient2 = new ItemStack(Items.emerald, 1 + random.nextInt(1)); + ingredient = new ItemStack(Items.emerald, 1); + if (random.nextBoolean()) ingredient2 = new ItemStack(Items.emerald, 1); break; } - case 7: + case 6: { result = new ItemStack(BlockList.smelter); ingredient = new ItemStack(Items.emerald, 1 + random.nextInt(2)); if (random.nextBoolean()) ingredient2 = new ItemStack(Items.emerald, 1 + random.nextInt(2)); break; } - case 8: - { - int end = random.nextInt(JewelrycraftUtil.modifiers.size()); - result = JewelrycraftUtil.modifiers.get(end); - if (JewelrycraftUtil.modifiers.size() - 1 - end >= 3) - { - result.stackSize = 1 + random.nextInt(JewelrycraftUtil.modifiers.size() - end); - int value = end; - if (value > 64) value = 64; - ingredient = new ItemStack(Items.emerald, 3 + random.nextInt(value)); - if (random.nextBoolean()) ingredient2 = new ItemStack(Items.emerald, 4 + random.nextInt(value)); - } - else - { - result.stackSize = 1 + random.nextInt(7); - ingredient = new ItemStack(Items.emerald, result.stackSize / 2 + 1 + random.nextInt(7)); - ingredient2 = new ItemStack(Items.emerald, result.stackSize / 2 + 1 + random.nextInt(4)); - } - if (result.getMaxStackSize() <= 1) result.stackSize = 1; - break; - } - case 9: + case 7: { int end = random.nextInt(JewelrycraftUtil.gem.size()); result = JewelrycraftUtil.gem.get(end); @@ -131,24 +105,29 @@ public class JCTrades implements IVillageTradeHandler } break; } - case 10: + case 8: { result = JewelrycraftUtil.ores.get(random.nextInt(JewelrycraftUtil.ores.size())); - result.stackSize = 3 + random.nextInt(8); - ingredient = new ItemStack(Items.emerald, 2 + random.nextInt(2)); - if (random.nextBoolean()) ingredient2 = new ItemStack(Items.emerald, 2 + random.nextInt(2)); + result.stackSize = 3 + random.nextInt(3); + ingredient = new ItemStack(Items.emerald, 2 + random.nextInt(5)); + if (random.nextBoolean()) ingredient2 = new ItemStack(Items.emerald, 2 + random.nextInt(6)); + break; + } + case 9: + { + result = new ItemStack(ItemList.guide, 1); + ingredient = new ItemStack(Items.emerald, 1); break; } default: { result = new ItemStack(ItemList.ring, 1, 0); + int randValue = random.nextInt(4); JewelryNBT.addMetal(result, JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size()))); - JewelryNBT.addModifiers(result, JewelrycraftUtil.addRandomModifiers()); + JewelryNBT.addModifiers(result, JewelrycraftUtil.addRandomModifiers(randValue)); JewelryNBT.addGem(result, JewelrycraftUtil.gem.get(random.nextInt(JewelrycraftUtil.gem.size()))); -// if (JewelryNBT.isModifierEffectType(result)) JewelryNBT.addMode(result, "Activated"); - if (JewelryNBT.isGemX(result, new ItemStack(Items.nether_star)) && JewelryNBT.isModifierX(result, new ItemStack(Items.book))) JewelryNBT.addMode(result, "Disenchant"); ingredient = new ItemStack(Items.emerald, 16 + random.nextInt(20)); - ingredient2 = new ItemStack(Blocks.emerald_block, 5 + random.nextInt(5)); + ingredient2 = new ItemStack(Blocks.emerald_block, 2 + randValue); } } |
