Referencing an Entity?

Discussion in 'Plugin Development' started by Shzylo, Jul 28, 2013.

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

    Shzylo

    I am writing code that I don't find efficient at all. I want to make a class in which I reference a couple things and just do it there, so I won't have to write it again and again for each entity.

    Code:
    @EventHandler
        public void onDamageEntity(PlayerInteractEntityEvent e) {
                if (e.getRightClicked() instanceof Cow) {
                    onDamageEntity();
                }
     
    // Deal with it here
    private void onDamageEntity(Entity e) {
        e.damage(int);
    }
    Is this possible?
     
  2. Offline

    StevenMANGOS

    This should work:

    Code:
    @EventHandler
    public void onDamageEntity(PlayerInteractEntityEvent e) {
        if (e.getRightClicked() instanceof Cow) {
            Cow cow = (Cow) e.getRightClicked();
            onDamageEntity(cow);
        }
    }
     
    private void onDamageEntity(Entity e) {
        if (e instanceof LivingEntity) {
            ((LivingEntity) e).damage(double);
        }
    }
     
Thread Status:
Not open for further replies.

Share This Page