How would i detect if a player left or right clicks with a bow in there hand and then shoot an arrow. Also if the arrow hit someone it kills them and gets who killed them. It will be great for your help.
kalicat For left and right clicking, use PlayerInteractEvent. For shooting with a bow, use EntityShootBowEvent. For arrow hitting a block, use ProjectileHitEvent. For arrow damaging an entity, use EntityDamageByEntityEvent. For arrow killing a player, use EntityDeathEvent. Did you even try to search?
What Assist said like this: (eg) this will make an explosion if you click with a stick. publicvoidonPlayerInteract(PlayerInteractEventevent){ Player player = event.getPlayer(); @SuppressWarnings("deprecation") int blockId = player.getItemInHand().getType().getId(); if(blockId == 280){ @SuppressWarnings("deprecation") Block block = player.getTargetBlock(null, 50); Location location = block.getLocation(); World world = player.getWorld(); world.createExplosion(location, 5);
jkjames6 You should put your code inside the code tags [ code ]code here[ / code ] it looks much better. The text above would look like this without the spaces Code: code here
Code:java onEntityDamage(EntityDamageEvent event){ if(event instanceof EntityDamageByEntityEvent){ if(event.getDamager instanceof Arrow) { Arrow a = (Arrow) test.getDamager(); if(a.getShooter() instanceof Player) { Player player = (Player) a.getShooter(); player.sendMessage("You hit something with an arrow!"); } } } } https://forums.bukkit.org/threads/getting-the-shooter-of-an-arrow.53450/