GenuineSounds

Auto gen'd item info.

Jul 26th, 2012
191
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.35 KB | None | 0 0
  1. public void generateInfo(ItemStack stack) {
  2.     if (stack == null)
  3.         return;
  4.     Item item = stack.getItem();
  5.     if (item != null && item.getItemName() != null) {
  6.         ItemWrap wrap = new ItemWrap(stack);
  7.         String[] tips = new String[] {};
  8.         if (item instanceof ItemBlock) {
  9.             tips = addToArray(tips, "Placeable Block");
  10.             Block block = Block.blocksList[((ItemBlock) item).getBlockID()];
  11.             if (block != null) {
  12.                 if (block.canProvidePower())
  13.                     tips = addToArray(tips, "Redstone Powered");
  14.             }
  15.         }
  16.         if (item.getItemEnchantability() > 0)
  17.             tips = addToArray(tips, "Enchantable");
  18.         boolean isArmor = false;
  19.         if (item.isItemTool(stack)) {
  20.             String type = "Tool";
  21.             if (item instanceof ItemArmor) {
  22.                 isArmor = true;
  23.                 switch (((ItemArmor) item).armorType) {
  24.                     case 0:
  25.                         type = "Helm";
  26.                         break;
  27.                     case 1:
  28.                         type = "Chest";
  29.                         break;
  30.                     case 2:
  31.                         type = "Pants";
  32.                         break;
  33.                     case 3:
  34.                         type = "Boots";
  35.                         break;
  36.                 }
  37.             }
  38.             tips = addToArray(tips, item.getRarity(stack).rarityName + " " + type);
  39.         }
  40.         if (isArmor)
  41.             tips = addToArray(tips, "Armor Strength: " + ((ItemArmor) item).damageReduceAmount);
  42.         if (item.getMaxDamage() > 0)
  43.             tips = addToArray(tips, "Max Use: " + item.getMaxDamage());
  44.         else if (!stack.getHasSubtypes())
  45.             wrap = new ItemWrap(wrap.getName(), 0x8000);
  46.         switch (item.getItemUseAction(stack)) {
  47.             case block:
  48.                 tips = addToArray(tips, "Use: Blocks damage");
  49.                 break;
  50.             case bow:
  51.                 tips = addToArray(tips, "Use: Pull Back");
  52.                 break;
  53.             case drink:
  54.                 tips = addToArray(tips, "Drinkable");
  55.                 break;
  56.             case eat:
  57.                 tips = addToArray(tips, "Edible");
  58.                 break;
  59.             default:
  60.                 break;
  61.         }
  62.         if (item instanceof ItemFood)
  63.             tips = addToArray(tips, "Feeds: " + ((ItemFood) item).getHealAmount() + " Half-bars");
  64.         if (item.isPotionIngredient())
  65.             tips = addToArray(tips, "Potion Ingredient");
  66. //      if (item.getPotionEffect() != null && !item.getPotionEffect().isEmpty()) {
  67. //          String[] effects = new String[] {};
  68. //          Matcher m = pattern.matcher(item.getPotionEffect());
  69. //          while (m.find())
  70. //              effects = addToArray(effects, m.group());
  71. //          for (String effect : effects)
  72. //              tips = addToArray(tips, effect);
  73. //      }
  74.         if (values.containsKey(wrap))
  75.             System.out.println("Contains same key... it never should...");
  76.         values.put(wrap, tips);
  77.     }
  78. }
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment