this should fix things the LivingEntityUseItemEvent.Start only works for items that can be used i.e. food i wrote the fixed code for you below.
EDIT: just realized you wanted sneak-right-click i fixed the code below
//used when rightclicking while looking at a block
@SubscribeEvent()
public void rightClickBlock(PlayerInteractEvent.RightClickBlock e){
//this checks if the entities world is the server we only run this on the server so it doesn't mess with things
if(!e.getEntity().getEntityWorld().isRemote){
EntityPlayer player = e.getEntityPlayer();//the player
//check if player is sneaking
if(player.isSneaking()){
ItemStack heldItem = player.getHeldItemMainhand();//the items in the players hand
//we compare the Item contained in the ItemStack not the ItemStack itself
//we use .equals here not == only use == for numbers or booleans
if(heldItem.getItem().equals(Items.GLASS_BOTTLE)){
onGlassBottleRightClick(player, heldItem);//this is the method where you put the code when the player right-clicks with an item
}
}
}
}
//used when rightclicking with an item while not looking at a block
@SubscribeEvent()
public void rightClickItem(PlayerInteractEvent.RightClickItem e){
//this checks if the entities world is the server we only run this on the server so it doesn't mess with things
if(!e.getEntity().getEntityWorld().isRemote){
EntityPlayer player = e.getEntityPlayer();//the player
//check if player is sneaking
if(player.isSneaking()){
ItemStack heldItem = player.getHeldItemMainhand();//the items in the players hand
//we compare the Item contained in the ItemStack not the ItemStack itself
//we use .equals here not == only use == for numbers or booleans
if(heldItem.getItem().equals(Items.GLASS_BOTTLE)){
onGlassBottleRightClick(player, heldItem);//this is the method where you put the code when the player right-clicks with an item
}
}
}
}
private void onGlassBottleRightClick(EntityPlayer player, ItemStack bottlestack){
player.attackEntityFrom(DamageSource.GENERIC, 3F);
//player.inventory.addItemStackToInventory(new ItemStack(ItemRegistry.bloodVial));
}