From 6312636fd9a4d0f56dc7c9ff474a99d879bcb4e9 Mon Sep 17 00:00:00 2001 From: OnyxDarkKnight Date: Mon, 23 Mar 2015 14:51:06 +0000 Subject: Reworked the whole repo. --- .../jewelrycraft/item/ItemBaseJewelry.java | 261 --------------------- .../darkknight/jewelrycraft/item/ItemBracelet.java | 40 ---- .../jewelrycraft/item/ItemClayMolds.java | 87 ------- java/darkknight/jewelrycraft/item/ItemCrystal.java | 113 --------- .../darkknight/jewelrycraft/item/ItemEarrings.java | 40 ---- java/darkknight/jewelrycraft/item/ItemGuide.java | 32 --- java/darkknight/jewelrycraft/item/ItemList.java | 57 ----- java/darkknight/jewelrycraft/item/ItemMolds.java | 87 ------- .../jewelrycraft/item/ItemMoltenMetal.java | 133 ----------- .../jewelrycraft/item/ItemMoltenMetalBucket.java | 225 ------------------ .../darkknight/jewelrycraft/item/ItemNecklace.java | 40 ---- java/darkknight/jewelrycraft/item/ItemRing.java | 40 ---- .../jewelrycraft/item/ItemThiefGloves.java | 165 ------------- 13 files changed, 1320 deletions(-) delete mode 100644 java/darkknight/jewelrycraft/item/ItemBaseJewelry.java delete mode 100644 java/darkknight/jewelrycraft/item/ItemBracelet.java delete mode 100644 java/darkknight/jewelrycraft/item/ItemClayMolds.java delete mode 100644 java/darkknight/jewelrycraft/item/ItemCrystal.java delete mode 100644 java/darkknight/jewelrycraft/item/ItemEarrings.java delete mode 100644 java/darkknight/jewelrycraft/item/ItemGuide.java delete mode 100644 java/darkknight/jewelrycraft/item/ItemList.java delete mode 100644 java/darkknight/jewelrycraft/item/ItemMolds.java delete mode 100644 java/darkknight/jewelrycraft/item/ItemMoltenMetal.java delete mode 100644 java/darkknight/jewelrycraft/item/ItemMoltenMetalBucket.java delete mode 100644 java/darkknight/jewelrycraft/item/ItemNecklace.java delete mode 100644 java/darkknight/jewelrycraft/item/ItemRing.java delete mode 100644 java/darkknight/jewelrycraft/item/ItemThiefGloves.java (limited to 'java/darkknight/jewelrycraft/item') diff --git a/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java b/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java deleted file mode 100644 index cb38b76..0000000 --- a/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java +++ /dev/null @@ -1,261 +0,0 @@ -package darkknight.jewelrycraft.item; - -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.TextureManager; -import net.minecraft.client.resources.IResourceManager; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.DamageSource; -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.JewelrycraftMod; -import darkknight.jewelrycraft.effects.ModifierEffects; -import darkknight.jewelrycraft.util.JewelryNBT; - -public abstract class ItemBaseJewelry extends Item -{ - public ItemBaseJewelry() - { - super(); - setMaxStackSize(1); - setCreativeTab(JewelrycraftMod.jewelrycraft); - } - - 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; - } - - /** - * @param stack - * @param pass - * @return - * @throws IOException - */ - public static int color(ItemStack stack, int pass) throws IOException - { - 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 ingot = JewelryNBT.ingot(stack); - icon = ImageIO.read(rm.getResource(getLocation(ingot, stack, true)).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){ - ItemStack gem = JewelryNBT.gem(stack); - icon = ImageIO.read(rm.getResource(getLocation(gem, stack, true)).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; - } - - /** - * @param item - * @param stack - * @param changeMeta - * @return - */ - public static ResourceLocation getLocation(ItemStack item, ItemStack stack, boolean changeMeta) - { - String domain = ""; - String texture; - if (changeMeta && (Item.getIdFromItem(item.getItem()) == Block.getIdFromBlock(Blocks.stained_glass) || Item.getIdFromItem(item.getItem()) == Block.getIdFromBlock(Blocks.stained_hardened_clay) || Item.getIdFromItem(item.getItem()) == Block.getIdFromBlock(Blocks.wool) || Item.getIdFromItem(item.getItem()) == Block.getIdFromBlock(Blocks.carpet))) item.setItemDamage(15 - item.getItemDamage()); - IIcon itemIcon = item.getItem().getIcon(item, 0); - String iconName = itemIcon.getIconName(); - if (iconName.substring(0, iconName.indexOf(":") + 1) != "") domain = iconName.substring(0, iconName.indexOf(":") + 1).replace(":", " ").trim(); - else domain = "minecraft"; - texture = iconName.substring(iconName.lastIndexOf(":") + 1) + ".png"; - ResourceLocation textureLocation = null; - TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); - if (texturemanager.getResourceLocation(item.getItemSpriteNumber()).toString().contains("items")) textureLocation = new ResourceLocation(domain.toLowerCase(), "textures/items/" + texture); - else textureLocation = new ResourceLocation(domain.toLowerCase(), "textures/blocks/" + texture); - return textureLocation; - } - - /** - * @param map - * @return - */ - 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; - } - - /** - * @param rgbArr - * @return - */ - public static boolean isGray(int[] rgbArr) - { - int rgbSum = rgbArr[0] + rgbArr[1] + rgbArr[2]; - if (rgbSum > 0 && rgbSum < 256 * 3) return false; - return true; - } - - /** - * @param stack - * @return - */ - public String getItemStackDisplayName(ItemStack stack) - { - if (JewelryNBT.ingot(stack) != null && Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()) > 0) return JewelryNBT.ingot(stack).getDisplayName().replace("Ingot", " ").trim() + " " + ("" + StatCollector.translateToLocal(getUnlocalizedNameInefficiently(stack) + ".name")).trim(); - return ("" + StatCollector.translateToLocal(getUnlocalizedNameInefficiently(stack) + ".name")).trim(); - } - - /** - * allows items to add custom lines of information to the mouseover description. - * - * @param stack - * @param player - * @param list - * @param par4 - */ - 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 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); - } - } - - /** - * @param stack - * @param player - */ - public void action(ItemStack stack, EntityPlayer player) - { - for(ModifierEffects mod: ModifierEffects.getEffects()) - mod.action(stack, player, this); - } - - /** - * @param item - * @param player - * @param source - * @return - */ - public boolean onPlayerAttackedCacellable(ItemStack item, EntityPlayer player, DamageSource source, float amount) - { - for(ModifierEffects mod: ModifierEffects.getEffects()) - return mod.onPlayerAttackedCacellable(item, player, source, this, amount); - return false; - } - - /** - * @param item - * @param player - * @param target - * @return - */ - public boolean onEntityAttackedCacellable(ItemStack item, EntityPlayer player, Entity target, float amount) - { - for(ModifierEffects mod: ModifierEffects.getEffects()) - return mod.onEntityAttackedCacellable(item, player, target, this, amount); - return false; - } - - /** - * @param item - * @param player - * @param source - * @return - */ - public void onPlayerAttacked(ItemStack item, EntityPlayer player, DamageSource source, float amount) - { - for(ModifierEffects mod: ModifierEffects.getEffects()) mod.onPlayerAttacked(item, player, source, this, amount); - } - - /** - * @param item - * @param player - * @param target - * @return - */ - public void onEntityAttacked(ItemStack item, EntityPlayer player, Entity target, float amount) - { - for(ModifierEffects mod: ModifierEffects.getEffects()) mod.onEntityAttacked(item, player, target, this, amount); - } -} diff --git a/java/darkknight/jewelrycraft/item/ItemBracelet.java b/java/darkknight/jewelrycraft/item/ItemBracelet.java deleted file mode 100644 index b754186..0000000 --- a/java/darkknight/jewelrycraft/item/ItemBracelet.java +++ /dev/null @@ -1,40 +0,0 @@ -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() - {} - - /** - * @param iconRegister - */ - @Override - public void registerIcons(IIconRegister iconRegister) - { - itemIcon = iconRegister.registerIcon("jewelrycraft:bracelet"); - gem = iconRegister.registerIcon("jewelrycraft:jewelBracelet"); - } - - /** - * @param stack - * @param pass - * @return - */ - @Override - 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 deleted file mode 100644 index 9f99857..0000000 --- a/java/darkknight/jewelrycraft/item/ItemClayMolds.java +++ /dev/null @@ -1,87 +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; -import net.minecraft.util.MathHelper; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -public class ItemClayMolds extends Item -{ - /** List of molds color names */ - public static final String[] moldsItemNames = new String[]{"clayIngot", "clayRing", "clayNecklace", "clayBracelet", "clayEarrings"}; - @SideOnly (Side.CLIENT) - private IIcon[] moldsIcons; - - /** - * - */ - public ItemClayMolds() - { - super(); - setHasSubtypes(true); - setMaxDamage(0); - setMaxStackSize(1); - } - - /** - * @param par1 - * @return - */ - @Override - @SideOnly (Side.CLIENT) - /** - * Gets an icon index based on an item's damage value - */ - public IIcon getIconFromDamage(int par1) - { - int j = MathHelper.clamp_int(par1, 0, moldsItemNames.length - 1); - return moldsIcons[j]; - } - - /** - * Returns the unlocalized name of this item. This version accepts an ItemStack so different stacks can have different names based on their damage or NBT. - * - * @param par1ItemStack - * @return - */ - @Override - public String getUnlocalizedName(ItemStack par1ItemStack) - { - int i = MathHelper.clamp_int(par1ItemStack.getItemDamage(), 0, moldsItemNames.length - 1); - return super.getUnlocalizedName() + "." + moldsItemNames[i]; - } - - /** - * @param par1 - * @param par2CreativeTabs - * @param par3List - */ - @Override - @SuppressWarnings ({"unchecked", "rawtypes"}) - @SideOnly (Side.CLIENT) - /** - * returns a list of items with the same ID, but different meta (eg: molds returns 16 items) - */ - public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) - { - for(int j = 0; j < moldsItemNames.length; ++j) - par3List.add(new ItemStack(par1, 1, j)); - } - - /** - * @param par1IconRegister - */ - @Override - @SideOnly (Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) - { - moldsIcons = new IIcon[moldsItemNames.length]; - for(int i = 0; i < moldsItemNames.length; ++i) - moldsIcons[i] = par1IconRegister.registerIcon("jewelrycraft:" + moldsItemNames[i] + getIconString()); - } -} diff --git a/java/darkknight/jewelrycraft/item/ItemCrystal.java b/java/darkknight/jewelrycraft/item/ItemCrystal.java deleted file mode 100644 index ca6b58d..0000000 --- a/java/darkknight/jewelrycraft/item/ItemCrystal.java +++ /dev/null @@ -1,113 +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.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -import net.minecraft.world.World; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -public class ItemCrystal extends Item -{ - public IIcon overlay; - public static final int[] dyeColors = new int[]{1973019, 11743532, 3887386, 5320730, 2437522, 8073150, 2651799, 11250603, 4408131, 14188952, 4312372, 14602026, 6719955, 12801229, 15435844, 15790320}; - - /** - * - */ - public ItemCrystal() - { - super(); - setHasSubtypes(true); - setMaxDamage(0); - } - - /** - * @param iconRegister - */ - @Override - public void registerIcons(IIconRegister iconRegister) - { - itemIcon = iconRegister.registerIcon("jewelrycraft:crystal"); - overlay = iconRegister.registerIcon("jewelrycraft:crystalOverlay"); - } - - /** - * @return - */ - @Override - public boolean requiresMultipleRenderPasses() - { - return true; - } - - /** - * @param stack - * @param pass - * @return - */ - @Override - @SideOnly (Side.CLIENT) - public int getColorFromItemStack(ItemStack stack, int pass) - { - if (pass == 1 && getDamage(stack) != 16) return dyeColors[getDamage(stack)]; - return 16777215; - } - - /** - * @param stack - * @param pass - * @return - */ - @Override - public IIcon getIcon(ItemStack stack, int pass) - { - return pass == 0 ? itemIcon : overlay; - } - - /** - * @param stack - * @param player - * @param world - * @param i - * @param j - * @param k - * @param side - * @param par8 - * @param par9 - * @param par10 - * @return - */ - @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int i, int j, int k, int side, float par8, float par9, float par10) - { - return true; - } - - /** - * @param stack - * @return - */ - @Override - public String getUnlocalizedName(ItemStack stack) - { - return super.getUnlocalizedName() + "." + stack.getItemDamage(); - } - - /** - * @param par1 - * @param par2CreativeTabs - * @param par3List - */ - @Override - @SuppressWarnings ({"unchecked", "rawtypes"}) - public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) - { - for(int j = 0; j < 16; ++j) - par3List.add(new ItemStack(par1, 1, j)); - } -} diff --git a/java/darkknight/jewelrycraft/item/ItemEarrings.java b/java/darkknight/jewelrycraft/item/ItemEarrings.java deleted file mode 100644 index 2321df0..0000000 --- a/java/darkknight/jewelrycraft/item/ItemEarrings.java +++ /dev/null @@ -1,40 +0,0 @@ -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() - {} - - /** - * @param iconRegister - */ - @Override - public void registerIcons(IIconRegister iconRegister) - { - itemIcon = iconRegister.registerIcon("jewelrycraft:earrings"); - gem = iconRegister.registerIcon("jewelrycraft:jewelEarrings"); - } - - /** - * @param stack - * @param pass - * @return - */ - @Override - 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/ItemGuide.java b/java/darkknight/jewelrycraft/item/ItemGuide.java deleted file mode 100644 index ed85dc4..0000000 --- a/java/darkknight/jewelrycraft/item/ItemGuide.java +++ /dev/null @@ -1,32 +0,0 @@ -package darkknight.jewelrycraft.item; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; -import darkknight.jewelrycraft.JewelrycraftMod; - -public class ItemGuide extends Item -{ - - /** - * - */ - public ItemGuide() - { - super(); - } - - /** - * @param stack - * @param world - * @param player - * @return - */ - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) - { - if (world.isRemote) player.openGui(JewelrycraftMod.instance, 1, player.worldObj, 0, 0, 0); - return stack; - } -} \ No newline at end of file diff --git a/java/darkknight/jewelrycraft/item/ItemList.java b/java/darkknight/jewelrycraft/item/ItemList.java deleted file mode 100644 index b9acd96..0000000 --- a/java/darkknight/jewelrycraft/item/ItemList.java +++ /dev/null @@ -1,57 +0,0 @@ -package darkknight.jewelrycraft.item; - -import net.minecraft.item.Item; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.common.registry.GameRegistry; -import darkknight.jewelrycraft.JewelrycraftMod; - -public class ItemList -{ - public static Item thiefGloves; - public static Item shadowIngot; - public static Item molds; - public static Item clayMolds; - 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; - private static boolean isInitialized = false; - - /** - * @param e - */ - public static void preInit(FMLPreInitializationEvent e) - { - if (!isInitialized){ - thiefGloves = new ItemThiefGloves().setUnlocalizedName("Jewelrycraft.thiefGloves").setTextureName("jewelrycraft:thiefGloves").setCreativeTab(JewelrycraftMod.jewelrycraft); - shadowIngot = new Item().setUnlocalizedName("Jewelrycraft.ingotShadow").setTextureName("jewelrycraft:ingotShadow").setCreativeTab(JewelrycraftMod.jewelrycraft); - 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"); - 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"); - GameRegistry.registerItem(thiefGloves, "thiefGloves"); - GameRegistry.registerItem(shadowIngot, "shadowIngot"); - GameRegistry.registerItem(molds, "molds"); - 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"); - GameRegistry.registerItem(metal, "moltenMetal"); - isInitialized = true; - } - } -} diff --git a/java/darkknight/jewelrycraft/item/ItemMolds.java b/java/darkknight/jewelrycraft/item/ItemMolds.java deleted file mode 100644 index 106fcbe..0000000 --- a/java/darkknight/jewelrycraft/item/ItemMolds.java +++ /dev/null @@ -1,87 +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; -import net.minecraft.util.MathHelper; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -public class ItemMolds extends Item -{ - /** List of molds color names */ - public static final String[] moldsItemNames = new String[]{"ingot", "ring", "necklace", "bracelet", "earrings"}; - @SideOnly (Side.CLIENT) - private IIcon[] moldsIcons; - - /** - * - */ - public ItemMolds() - { - super(); - setHasSubtypes(true); - setMaxDamage(0); - setMaxStackSize(1); - } - - /** - * @param par1 - * @return - */ - @Override - @SideOnly (Side.CLIENT) - /** - * Gets an icon index based on an item's damage value - */ - public IIcon getIconFromDamage(int par1) - { - int j = MathHelper.clamp_int(par1, 0, moldsItemNames.length - 1); - return moldsIcons[j]; - } - - /** - * Returns the unlocalized name of this item. This version accepts an ItemStack so different stacks can have different names based on their damage or NBT. - * - * @param par1ItemStack - * @return - */ - @Override - public String getUnlocalizedName(ItemStack par1ItemStack) - { - int i = MathHelper.clamp_int(par1ItemStack.getItemDamage(), 0, moldsItemNames.length - 1); - return super.getUnlocalizedName() + "." + moldsItemNames[i]; - } - - /** - * @param par1 - * @param par2CreativeTabs - * @param par3List - */ - @Override - @SuppressWarnings ({"unchecked", "rawtypes"}) - @SideOnly (Side.CLIENT) - /** - * returns a list of items with the same ID, but different meta (eg: molds returns 16 items) - */ - public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) - { - for(int j = 0; j < moldsItemNames.length; ++j) - par3List.add(new ItemStack(par1, 1, j)); - } - - /** - * @param par1IconRegister - */ - @Override - @SideOnly (Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) - { - moldsIcons = new IIcon[moldsItemNames.length]; - for(int i = 0; i < moldsItemNames.length; ++i) - moldsIcons[i] = par1IconRegister.registerIcon("jewelrycraft:" + moldsItemNames[i] + getIconString()); - } -} diff --git a/java/darkknight/jewelrycraft/item/ItemMoltenMetal.java b/java/darkknight/jewelrycraft/item/ItemMoltenMetal.java deleted file mode 100644 index 0638da7..0000000 --- a/java/darkknight/jewelrycraft/item/ItemMoltenMetal.java +++ /dev/null @@ -1,133 +0,0 @@ -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; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.client.resources.IResourceManager; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import darkknight.jewelrycraft.util.JewelryNBT; - -public class ItemMoltenMetal extends Item -{ - - /** - * - */ - public ItemMoltenMetal() - { - super(); - setMaxStackSize(1); - } - - /** - * @param iconRegister - */ - @Override - public void registerIcons(IIconRegister iconRegister) - { - itemIcon = iconRegister.registerIcon("jewelrycraft:moltenMetalStill"); - } - - /** - * @param stack - * @param pass - * @return - */ - @Override - @SideOnly (Side.CLIENT) - public int getColorFromItemStack(ItemStack stack, int pass) - { - try{ - return color(stack, pass); - } - catch(IOException e){ - e.printStackTrace(); - } - return 16777215; - } - - /** - * @param stack - * @param pass - * @return - * @throws IOException - */ - public static int color(ItemStack stack, int pass) throws IOException - { - IResourceManager rm = Minecraft.getMinecraft().getResourceManager(); - BufferedImage icon; - if (stack != null && JewelryNBT.ingot(stack) != null && Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()) > 0 && JewelryNBT.ingot(stack).getIconIndex() != null && JewelryNBT.ingotColor(stack) == 16777215){ - ResourceLocation ingot = ItemBaseJewelry.getLocation(JewelryNBT.ingot(stack), stack, false); - 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); - } - 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); - } - } - if (JewelryNBT.ingot(stack) != null) return JewelryNBT.ingotColor(stack); - return 0; - } - - /** - * @param map - * @return - */ - 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; - } - - /** - * @param rgbArr - * @return - */ - public static boolean isGray(int[] rgbArr) - { - 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 deleted file mode 100644 index 9365224..0000000 --- a/java/darkknight/jewelrycraft/item/ItemMoltenMetalBucket.java +++ /dev/null @@ -1,225 +0,0 @@ -package darkknight.jewelrycraft.item; - -import java.io.IOException; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IIconRegister; -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.IIcon; -import net.minecraft.util.MovingObjectPosition; -import net.minecraft.util.StatCollector; -import net.minecraft.world.World; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.entity.player.FillBucketEvent; -import cpw.mods.fml.common.eventhandler.Event; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import darkknight.jewelrycraft.JewelrycraftMod; -import darkknight.jewelrycraft.block.BlockList; -import darkknight.jewelrycraft.network.PacketSendLiquidData; -import darkknight.jewelrycraft.util.JewelryNBT; - -public class ItemMoltenMetalBucket extends Item -{ - public IIcon liquid; - - /** - * - */ - public ItemMoltenMetalBucket() - { - maxStackSize = 1; - } - - /** - * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer - * - * @param stack - * @param par2World - * @param par3EntityPlayer - * @return - */ - @Override - public ItemStack onItemRightClick(ItemStack stack, World par2World, EntityPlayer par3EntityPlayer) - { - boolean flag = BlockList.moltenMetal == Blocks.air; - MovingObjectPosition movingobjectposition = getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, flag); - if (movingobjectposition == null) return stack; - else{ - FillBucketEvent event = new FillBucketEvent(par3EntityPlayer, stack, par2World, movingobjectposition); - if (MinecraftForge.EVENT_BUS.post(event)) return stack; - if (event.getResult() == Event.Result.ALLOW){ - if (par3EntityPlayer.capabilities.isCreativeMode) return stack; - if (--stack.stackSize <= 0) return event.result; - if (!par3EntityPlayer.inventory.addItemStackToInventory(event.result)) par3EntityPlayer.dropPlayerItemWithRandomChoice(event.result, false); - return stack; - } - if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK){ - int i = movingobjectposition.blockX; - int j = movingobjectposition.blockY; - int k = movingobjectposition.blockZ; - if (!par2World.canMineBlock(par3EntityPlayer, i, j, k)) return stack; - if (flag){ - if (!par3EntityPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, stack)) return stack; - par2World.getBlock(i, j, k).getMaterial(); - par2World.getBlockMetadata(i, j, k); - par2World.setBlockToAir(i, j, k); - return func_150910_a(stack, par3EntityPlayer, ItemList.bucket); - }else{ - if (BlockList.moltenMetal == Blocks.air) return new ItemStack(Items.bucket); - if (movingobjectposition.sideHit == 0) --j; - if (movingobjectposition.sideHit == 1) ++j; - if (movingobjectposition.sideHit == 2) --k; - if (movingobjectposition.sideHit == 3) ++k; - if (movingobjectposition.sideHit == 4) --i; - if (movingobjectposition.sideHit == 5) ++i; - if (!par3EntityPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, stack)) return stack; - try{ - if (tryPlaceContainedLiquid(par2World, i, j, k, stack) && !par3EntityPlayer.capabilities.isCreativeMode) return new ItemStack(Items.bucket); - } - catch(IOException e){ - e.printStackTrace(); - } - } - } - return stack; - } - } - - /** - * @param p_150910_1_ - * @param p_150910_2_ - * @param p_150910_3_ - * @return - */ - private ItemStack func_150910_a(ItemStack p_150910_1_, EntityPlayer p_150910_2_, Item p_150910_3_) - { - if (p_150910_2_.capabilities.isCreativeMode) return p_150910_1_; - else if (--p_150910_1_.stackSize <= 0) return new ItemStack(p_150910_3_); - else{ - if (!p_150910_2_.inventory.addItemStackToInventory(new ItemStack(p_150910_3_))) p_150910_2_.dropPlayerItemWithRandomChoice(new ItemStack(p_150910_3_, 1, 0), false); - return p_150910_1_; - } - } - - /** - * Attempts to place the liquid contained inside the bucket. - * - * @param world - * @param x - * @param y - * @param z - * @param stack - * @return - * @throws IOException - */ - public boolean tryPlaceContainedLiquid(World world, int x, int y, int z, ItemStack stack) throws IOException - { - if (BlockList.moltenMetal == Blocks.air) return false; - else{ - Material material = world.getBlock(x, y, z).getMaterial(); - boolean flag = !material.isSolid(); - if (!world.isAirBlock(x, y, z) && !flag) return false; - else if (stack != null && JewelryNBT.ingot(stack) != null){ - if (!world.isRemote && flag && !material.isLiquid()) world.func_147480_a(x, y, z, true); - 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; - }else return false; - } - } - - /** - * @param iconRegister - */ - @Override - public void registerIcons(IIconRegister iconRegister) - { - itemIcon = iconRegister.registerIcon("bucket_empty"); - liquid = iconRegister.registerIcon("jewelrycraft:bucketOverlay"); - } - - /** - * @param stack - * @param pass - * @return - */ - @Override - @SideOnly (Side.CLIENT) - public int getColorFromItemStack(ItemStack stack, int pass) - { - try{ - return color(stack, pass); - } - catch(IOException e){ - e.printStackTrace(); - } - return 16777215; - } - - /** - * @return - */ - @Override - public boolean requiresMultipleRenderPasses() - { - return true; - } - - /** - * @param stack - * @param pass - * @return - */ - @Override - public IIcon getIcon(ItemStack stack, int pass) - { - if (pass == 0) return itemIcon; - if (pass == 1) return liquid; - return itemIcon; - } - - /** - * @param stack - * @param pass - * @return - * @throws IOException - */ - public static int color(ItemStack stack, int pass) throws IOException - { - if (pass == 1) return ItemMoltenMetal.color(stack, pass); - return 16777215; - } - - /** - * @param ingot - * @return - */ - public ItemStack getModifiedItemStack(ItemStack ingot) - { - ItemStack itemstack = new ItemStack(this); - JewelryNBT.addMetal(itemstack, ingot); - return itemstack; - } - - /** - * @param stack - * @return - */ - @Override - public String getItemStackDisplayName(ItemStack stack) - { - 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_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(getUnlocalizedNameInefficiently(stack) + ".name").trim() + " " + ingot.getDisplayName().replace("Ingot", " ").trim(); - } - return ("" + StatCollector.translateToLocal(getUnlocalizedNameInefficiently(stack) + ".name")).trim() + " Metal"; - } -} diff --git a/java/darkknight/jewelrycraft/item/ItemNecklace.java b/java/darkknight/jewelrycraft/item/ItemNecklace.java deleted file mode 100644 index 9668589..0000000 --- a/java/darkknight/jewelrycraft/item/ItemNecklace.java +++ /dev/null @@ -1,40 +0,0 @@ -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 ItemNecklace extends ItemBaseJewelry -{ - public IIcon gem; - - /** - * - */ - public ItemNecklace() - {} - - /** - * @param iconRegister - */ - @Override - public void registerIcons(IIconRegister iconRegister) - { - itemIcon = iconRegister.registerIcon("jewelrycraft:necklace"); - gem = iconRegister.registerIcon("jewelrycraft:jewelNecklace"); - } - - /** - * @param stack - * @param pass - * @return - */ - @Override - 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/ItemRing.java b/java/darkknight/jewelrycraft/item/ItemRing.java deleted file mode 100644 index 4472324..0000000 --- a/java/darkknight/jewelrycraft/item/ItemRing.java +++ /dev/null @@ -1,40 +0,0 @@ -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 ItemRing extends ItemBaseJewelry -{ - public IIcon gem; - - /** - * - */ - public ItemRing() - {} - - /** - * @param iconRegister - */ - @Override - public void registerIcons(IIconRegister iconRegister) - { - itemIcon = iconRegister.registerIcon("jewelrycraft:ring"); - gem = iconRegister.registerIcon("jewelrycraft:jewelRing"); - } - - /** - * @param stack - * @param pass - * @return - */ - @Override - 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/ItemThiefGloves.java b/java/darkknight/jewelrycraft/item/ItemThiefGloves.java deleted file mode 100644 index e9cbeca..0000000 --- a/java/darkknight/jewelrycraft/item/ItemThiefGloves.java +++ /dev/null @@ -1,165 +0,0 @@ -package darkknight.jewelrycraft.item; - -import java.util.Iterator; -import java.util.List; -import java.util.Random; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.passive.EntityVillager; -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; -import net.minecraft.village.MerchantRecipeList; -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.JewelrycraftUtil; -import darkknight.jewelrycraft.util.PlayerUtils; - -public class ItemThiefGloves extends Item -{ - public Random rand = new Random(); - - /** - * - */ - public ItemThiefGloves() - { - super(); - setCreativeTab(CreativeTabs.tabTools); - setMaxStackSize(1); - setMaxDamage(10); - } - - /** - * @param stack - * @param player - * @param entity - * @return - */ - @Override - public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase entity) - { - if (entity instanceof EntityVillager){ - 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); - if (steal == 0){ - villager.dropItem(Items.emerald, wealth); - ReflectionHelper.setPrivateValue(EntityVillager.class, villager, 0, "wealth", "field_70956_bz"); - } - if (buyingList != null){ - Iterator iterator = buyingList.iterator(); - 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); - JewelrycraftUtil.addCursePoints(player, 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{ - stack.damageItem(1, player); - JewelrycraftUtil.addCursePoints(player, 25); - 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() + ".")); - player.addChatMessage(new ChatComponentText("Villager #" + villager.getProfession() + " curses you for the attempt.")); - return true; - } - else{ - player.addChatMessage(new ChatComponentText("A villager nearby saw you trying to steal from Villager #" + villager.getProfession() + ".")); - player.addChatMessage(new ChatComponentText("Villager #" + villager.getProfession() + " curses you for the attempt.")); - return true; - } - }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.")); - return true; - } - } - } - } - return true; - }else return super.itemInteractionForEntity(stack, player, entity); - } - - /** - * @param stack - * @param player - * @param list - * @param par4 - */ - @Override - @SuppressWarnings ("unchecked") - public void addInformation(ItemStack stack, EntityPlayer player, @SuppressWarnings ("rawtypes") List list, boolean par4) - { - if (!shouldAddAdditionalInfo()) list.add(EnumChatFormatting.GRAY + additionalInfoInstructions()); - else{ - list.add(EnumChatFormatting.GRAY + "Right click with the gloves,"); - list.add(EnumChatFormatting.GRAY + "while sneaking, on a villager"); - list.add(EnumChatFormatting.GRAY + "to steal his stuff."); - } - } - - /** - * @return - */ - public static boolean shouldAddAdditionalInfo() - { - if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) return true; - return false; - } - - /** - * @return - */ - public static String additionalInfoInstructions() - { - String message = "\247oPress \247b\2477\247o for more information."; - return message; - } -} -- cgit v1.2.3