Certain Damageable Location on Entity

Discussion in 'Plugin Development' started by AndersonEpic, Jun 25, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    AndersonEpic

    I'm trying to make a Headshot plugin for every entity/mob in Minecraft with swords instead of arrows or any projectile. I'm new to Bukkit and at the same time I'm not. I'm trying to find the location with the sword hit the giant and then check if the location is equal to one of the y coordinates that I specified. Here's my code:

    Code:
    @SuppressWarnings("deprecation")
            @EventHandler
            public void on(EntityDamageEvent e) {
              Material s = Material.IRON_SWORD;
             
              if (e.getEntity() instanceof Giant){
                        Giant g = (Giant) e.getEntity();
                        EntityDamageEvent ede = new EntityDamageEvent(g, DamageCause.ENTITY_ATTACK, 0);
                        if(s.getLocation.getY() - g.getLocation().getY() <= 9.38 && g.getLocation().getY() > 9.26) {
                       
                        g.setHealth(0);
                        g.isDead();
                       
                        }
              }
            }
            }
    
    And please if you, comment the fix code :D
     
  2. Offline

    D4rkz

    You don't need g.isDead();
     
  3. Offline

    AndersonEpic

    Okay, but how will I get the location of where the sword hit?
     
  4. Offline

    Traks

    I don't think there's an 'easy' way of doing that... You could try to use the player's yaw and pitch and calculate where that vector intersects the body of another player, but I don't think you would want to go through the trouble of doing that...
     
  5. Offline

    AndersonEpic

    I honestly don't know how to do that. Can you comment the code?
     
Thread Status:
Not open for further replies.

Share This Page