smack that chicken!

Discussion in 'Plugin Development' started by lynnetelfer, Apr 20, 2014.

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

    lynnetelfer

    I would like to make a plugin where you can hit a chicken with a stick and it will act like a simple pong game. I cant find how I can launch the chicken after hitting. Is it using pathentity()? I take it projectile is only for the egg not the chicken :p

    any ideas awesome ones?
     
  2. Offline

    Heirteir

    you would change the velocity based on the pitch and yaw of the hitter.
     
  3. Offline

    itzrobotix

    Try setting the chickens velocity in the players eye direction and multiply it?
     
  4. Offline

    lynnetelfer

    That's definitely the way I will do it! I'm having trouble working out the syntax to determine the eye direction.
     
  5. Offline

    Zethariel

    Use the location yaw and pitch, and some fancy vector math.
     
  6. Offline

    lynnetelfer

    package me.telfer.lynnette.chickensquash;

    import org.bukkit.Bukkit;
    import org.bukkit.entity.Chicken;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.EntityDamageByEntityEvent;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.util.Vector;

    import java.util.HashMap;

    /**
    * Created by Lynne Telfer on 23/04/2014.
    */
    public class ChickenSquash extends JavaPlugin implements Listener {

    private HashMap<Player, Player> tag = new HashMap<Player, Player>();

    @Override

    public void onEnable() {
    Bukkit.getServer().getPluginManager().registerEvents(this,this);
    }

    @Override

    public void onDisable() {
    }

    boolean flag = true;

    @EventHandler
    public void onEntityDamage(EntityDamageByEntityEvent e){
    if (e.getEntity() instanceof Chicken && e.getDamager() instanceof Player) {
    Chicken en = (Chicken) e.getEntity();
    Player player = (Player) e.getDamager();
    Bukkit.broadcastMessage( en + " was hit by "+ player.getName() + ".");
    // en.setVelocity(player.getLocation().getDirection().multiply(3));
    en.setVelocity(new Vector(player.getLocation().getX(), 1.0D, player.getLocation().getZ()));
    flag = false;
    e.setCancelled(true);

    }
    }


    }
     
Thread Status:
Not open for further replies.

Share This Page