Use named items for tools
Peter200lx opened this issue ยท 2 comments
Minecraft has support for named items.
http://minecraft.gamepedia.com/Anvil#Renaming
This can be used to make ToolBelt only listen to specific items instead of all ____ (bone, golden shovel, etc)
Also the items can have descriptions, handy for giving usage instructions.
Originally suggested by Jadedwolf
Also worth investigating, this might mean that the paint tool can now listen to a specific paint name instead of an action bar slot.
Here is an example I use to use the lore data of an item for a specific event. So only if the item has that lore will the event fire.
@EventHandler
public void onShoot(EntityShootBowEvent e) {
ArrayList loreData = new ArrayList();
loreData.add("Feel the Wither Within as you pull!");
Player player = (Player) e.getEntity();
if (e.getEntity() == null) {
return;
}
if ((e.getBow().getItemMeta().hasLore())
&& (e.getBow().getItemMeta().getLore().equals(loreData))) {
Player p = (Player) e.getEntity();
e.setCancelled(true);
((WitherSkull) p.launchProjectile(WitherSkull.class)).setVelocity(e.getProjectile().getVelocity());
p.removePotionEffect(PotionEffectType.WITHER);
p.getWorld().playEffect(p.getLocation(), Effect.MOBSPAWNER_FLAMES, 5);
}
}