Peter200lx / ToolBelt

Play Minecraft with a wide assortment of tools at your side.
9 stars 5 forks source link

Use named items for tools #33

Open Peter200lx opened 10 years ago

Peter200lx commented 10 years ago

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

Peter200lx commented 10 years ago

Also worth investigating, this might mean that the paint tool can now listen to a specific paint name instead of an action bar slot.

Jadedwolf commented 10 years ago

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);
        }
    }