minecraft - Bukkit: Change EXP_Bottle item material to consume instead of throwable -


i'm trying build bukkit plugin store xp levels in exp_bottle. exp_bottle throwable , releases exp orbs.

i wanted make consumable instead of throwable.

also, wanted right event on crafting remove exp after player grabs new flask instead of when places stuff in crafting table.

can me out?

i not believe possible change exp bottle consumable minecraft client still think exp bottle. however, listening playerinteractevent , achieve similar functionality. example:

@eventhandler public void interact(playerinteractevent e) {     itemstack itemstack = e.getitem();     // check see if item exp bottle     if (itemstack != null && e.getitem().gettype().equals(material.exp_bottle)) {         // cancel event not thrown         e.setcancelled(true);          player player = e.getplayer();          // add exp player         player.giveexp(1);          // remove bottle players hand         int newamount = e.getitem().getamount() - 1;         if (newamount > 0)             player.getiteminhand().setamount(newamount);         else             player.setiteminhand(null);     } } 

also, if want listen when item crafted can use craftitemevent.

cheers!


Comments