1

Help with plugin

Android73's Avatar Android732/8/14 4:10 pm
1 emeralds 221 7
2/8/2014 5:14 pm
Android73's Avatar Android73
I'm having trouble with a code. I'm trying to make it where if you r-click a snowball entity in the air, you get a snowball item in your inventory. For some reason this will work with all entities except arrows and snowballs. Does PlayerInteractEntityEvent not work with projectiles?
Posted by Android73's Avatar
Android73
Level 1 : New Explorer
0

Create an account or sign in to comment.

7

1
02/08/2014 5:14 pm
Level 1 : New Explorer
Android73
Android73's Avatar
Can anybody tell me why this code isn't working with arrows and snowballs? It works perfectly fine with other entities. I have tested it on cows, pigs, chickens, squids, and fireballs and it works. Why is it not on snowballs?
1
02/08/2014 5:01 pm
Level 19 : Journeyman Ninja
WordOut
WordOut's Avatar
If you want them to have an item in their hand you can use:
player.setItemInHand(new ItemStack(Material.SNOW_BALL));
but their hand would have to be empty i think to have the item you could try it and see if it works
1
02/08/2014 4:49 pm
Level 4 : Apprentice Architect
grootcamelbridgesun
grootcamelbridgesun's Avatar
Make sure that your method has a @EventHandler annotation, and that the event i s registered. Try to see if the entity is an instance of a projectile, and then check if the projectile is an instance of a snowball. You might haver to use PlayerInteractEvent, then get the player's line of sight and check for a snowball.
1
02/08/2014 4:48 pm
Level 1 : New Explorer
Android73
Android73's Avatar
I already had it deprecated, I'm sorry I forgot to put that in there. I tried it with Entity entity = e.getRightClicked();, but it still isn't working(though it does with other entities.)
1
02/08/2014 4:37 pm
Level 2 : Apprentice Explorer
eprimex
eprimex's Avatar
i have no idea what Entity entity = ((PlayerInteractEntityEvent) e).getRightClicked(); is supposed to do

-> Entity entity = e.getRightClicked();

no idea why it wouldn't work then

http://prntscr.com/2qqj66

p.updateInventory() is deprecated
1
02/08/2014 4:21 pm
Level 1 : New Explorer
Android73
Android73's Avatar
public void onSnowballCatch(PlayerInteractEntityEvent e){
Player p = e.getPlayer();
Entity entity = ((PlayerInteractEntityEvent) e).getRightClicked();
if(entity instanceof Snowball){
p.getInventory().addItem(new ItemStack(Material.SNOW_BALL));
p.updateInventory();
}
}

1
02/08/2014 4:16 pm
Level 2 : Apprentice Explorer
eprimex
eprimex's Avatar
could you paste your current code?. Yes PlayerInterractEntityEvent does work with snowball
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome