ItemStack's Vanish.

Discussion in 'Plugin Development' started by iPhysX, Jan 18, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    iPhysX

    I did a quick search and couldn't find anthing already posted about ItemStacks Vanishing.

    So I have made a plugin.
    To make me Stupidly OverPowered.

    STUPIDLY OVERPOWERED (open)

    Code:java
    1. player.getInventory().clear();
    2. ItemStack boots = new ItemStack(313);
    3. boots.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4);
    4. boots.addEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 4);
    5. boots.addEnchantment(Enchantment.PROTECTION_FALL, 4);
    6. boots.addEnchantment(Enchantment.PROTECTION_FIRE, 4);
    7. boots.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 4);
    8. player.getInventory().setBoots(boots);
    9. player.getInventory().getBoots().setDurability((short) 0);
    10. System.out.println("boots dur: " + boots.getDurability());
    11. ItemStack pants = new ItemStack(312);
    12. pants.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4);
    13. pants.addEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 4);
    14. pants.addEnchantment(Enchantment.PROTECTION_FIRE, 4);
    15. pants.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 4);
    16. player.getInventory().setLeggings(pants);
    17. player.getInventory().getLeggings().setDurability((short) 0);
    18. System.out.println("pants dur: " + pants.getDurability());
    19. ItemStack chest = new ItemStack(311);
    20. chest.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4);
    21. chest.addEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 4);
    22. chest.addEnchantment(Enchantment.PROTECTION_FIRE, 4);
    23. chest.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 4);
    24. player.getInventory().setChestplate(chest);
    25. player.getInventory().getChestplate().setDurability((short) 0);
    26. System.out.println("chest dur: " + chest.getDurability());
    27. ItemStack helm = new ItemStack(310);
    28. helm.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4);
    29. helm.addEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 4);
    30. helm.addEnchantment(Enchantment.PROTECTION_FIRE, 4);
    31. helm.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 4);
    32. helm.addEnchantment(Enchantment.WATER_WORKER, 1);
    33. helm.addEnchantment(Enchantment.OXYGEN, 1);
    34. player.getInventory().setHelmet(helm);
    35. player.getInventory().getHelmet().setDurability((short) 0);
    36. System.out.println("helmet dur: " + helm.getDurability());
    37. ItemStack sword = new ItemStack(276);
    38. sword.addEnchantment(Enchantment.FIRE_ASPECT, 2);
    39. sword.addEnchantment(Enchantment.DAMAGE_ALL, 4);
    40. sword.addEnchantment(Enchantment.DAMAGE_ARTHROPODS, 4);
    41. sword.addEnchantment(Enchantment.DAMAGE_UNDEAD, 4);
    42. sword.addEnchantment(Enchantment.KNOCKBACK, 2);
    43. sword.addEnchantment(Enchantment.LOOT_BONUS_MOBS, 3);
    44. System.out.println("sword dur: " + sword.getDurability());
    45. player.getInventory().addItem(sword);
    46. ItemStack shovel = new ItemStack(277);
    47. shovel.addEnchantment(Enchantment.DURABILITY, 3);
    48. shovel.addEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 3);
    49. shovel.addEnchantment(Enchantment.SILK_TOUCH, 1);
    50. player.getInventory().addItem(shovel);
    51. System.out.println("shovel dur: " + shovel.getDurability());
    52. ItemStack pick = new ItemStack(278);
    53. pick.addEnchantment(Enchantment.DURABILITY, 3);
    54. pick.addEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 3);
    55. pick.addEnchantment(Enchantment.SILK_TOUCH, 1);
    56. player.getInventory().addItem(pick);
    57. System.out.println("pick dur: " + pick.getDurability());
    58. ItemStack axe = new ItemStack(279);
    59. axe.addEnchantment(Enchantment.DURABILITY, 3);
    60. axe.addEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 3);
    61. axe.addEnchantment(Enchantment.SILK_TOUCH, 1);
    62. player.getInventory().addItem(axe);
    63. System.out.println("axe dur: " + axe.getDurability());
    64. player.updateInventory();
    65. player.sendMessage(ChatColor.GRAY+"Enjoy your OverPoweredNess.");



    But as soon as i do anything with the item... Drop it, use it, interact with it...
    It will just vanish.
    I checked out the JavaDocs and I still couldn't find out why.

    I noticed updateInventory() was depricated though.

    Thanks for any help,
    ~Phys.
     
  2. Offline

    nisovin

    You need to specify a quantity when making an ItemStack.
     
    iPhysX likes this.
  3. Offline

    iPhysX

    Thanks, I had no idea, i was under the impression it was not needed.
    Helps alot :p
     
    Adamki11s likes this.
Thread Status:
Not open for further replies.

Share This Page