1

Coding help

_gdawg_ 6/3/16 4:32 pm
250
6/3/2016 6:53 pm
I'm trying to make a minecraft plugin where I'm making it so you can make craftable items. I have that part down, but how do you make properties for those items (Like for instance making an obsidian shovel with high durability)?
Posted by
_gdawg_
Level 30 : Artisan Miner
9

  Have something to say?

JoinSign in

1

SirBlobman
06/03/2016 6:53 pm
Level 24 : Expert Modder
You can't change the durability of Minecraft items, but you can add invisible unbreaking enchanments that will make it seem like it has more durability

Here's some example code


ItemStack op_sword = new ItemStack(Material.DIAMOND_SWORD);
ItemMeta meta = op_sword.getItemMeta();

meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
op_sword.setItemMeta(meta);

op_sword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 32767);
op_sword.addUnsafeEnchantment(Enchantment.DAMAGE_ARTHROPODS, 32767);
op_sword.addUnsafeEnchantment(Enchantment.DAMAGE_UNDEAD, 32767);
op_sword.addUnsafeEnchantment(Enchantment.DURABILITY, 32767);
1

Welcome