@EventHandler public void onInteract(PlayerInteractEvent e) { if(e.getAction() == Action.RIGHT_CLICK_BLOCK) { if(e.getClickedBlock().getType() == Material.WOOD_STAIRS || e.getClickedBlock().getType() == Material.COBBLESTONE_STAIRS || e.getClickedBlock().getType() == Material.SMOOTH_STAIRS || e.getClickedBlock().getType() == Material.BRICK_STAIRS) { if(isChair(e.getClickedBlock())) { if(e.getPlayer().getItemInHand() != null) { return; } Chicken chicken = (Chicken)e.getClickedBlock().getWorld().spawnEntity(e.getClickedBlock().getLocation().add(0.5, 0, 0.5), EntityType.CHICKEN); chicken.setMetadata("chair", new FixedMetadataValue(pl, e.getPlayer().getName())); chicken.setPassenger(e.getPlayer()); chicken.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 10)); chicken.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, Integer.MAX_VALUE, 100)); sendMessage(e.getPlayer(), ChatColor.GREEN + "you are now sitting on a chair."); pl.getManagers().getChairManager().addChicken(e.getPlayer(), chicken); Bukkit.getScheduler().runTaskTimer(pl, this, 0L, 1L); XPlayer xp = pl.getManagers().getPlayerManager().getPlayer(e.getPlayer().getName()); xp.setInChair(true); } } } }
public TrackTask(Entity arrow, LivingEntity target, Plugin plugin) { this.arrow = arrow; this.target = target; runTaskTimer(plugin, 1L, 1L); if(arrow instanceof Chicken) { c = true; } m = c ? EquestrianDash.plugin.getConfig().getDouble("Powerups.Chicken.Multiplier") : 0; }
@EventHandler public void onDamage(EntityDamageEvent e) { if(e.getEntity() instanceof Chicken) { Chicken chicken = (Chicken) e.getEntity(); if(chicken.hasMetadata("chair")) { e.setCancelled(true); } } }
@SuppressWarnings("deprecation") @Override public void run() { Iterator<Entry<String, Entity>> it = pl.getManagers().getChairManager().getIterator(); while(it.hasNext()) { Entry<String, Entity> entry = it.next(); if(entry.getValue().getPassenger() == null) { Bukkit.getPluginManager().callEvent(new ChairExitEvent(Bukkit.getPlayer(entry.getKey()), (Chicken)entry.getValue())); } } }
@Override public void display() { this.chickens.add(InfiniteChickenFamilyDisplayer.this.baseLocation.getWorld().spawn(InfiniteChickenFamilyDisplayer.this.baseLocation, Chicken.class)); new BukkitRunnable() { @Override public void run() { if (InfiniteChickenFamilyDisplayer.this.chickens.size() == 10) { for (Chicken chicken : InfiniteChickenFamilyDisplayer.this.chickens) { chicken.getLocation().getWorld().createExplosion(chicken.getLocation().getX(), chicken.getLocation().getY(), chicken.getLocation().getZ(), 1.5F, false, false); chicken.remove(); } InfiniteChickenFamilyDisplayer.this.restore(); InfiniteChickenFamilyDisplayer.this.end(); this.cancel(); } else { if (InfiniteChickenFamilyDisplayer.this.lastEgg == null) { InfiniteChickenFamilyDisplayer.this.lastEgg = InfiniteChickenFamilyDisplayer.this.baseLocation.getWorld().dropItemNaturally( InfiniteChickenFamilyDisplayer.this.chickens.get(InfiniteChickenFamilyDisplayer.this.chickens.size() - 1).getLocation(), new ItemStack(Material.EGG, 1)); InfiniteChickenFamilyDisplayer.this.lastEgg.setVelocity(InfiniteChickenFamilyDisplayer.this.lastEgg.getVelocity().multiply(2)); } else { InfiniteChickenFamilyDisplayer.this.chickens.add(InfiniteChickenFamilyDisplayer.this.lastEgg.getWorld().spawn(InfiniteChickenFamilyDisplayer.this.lastEgg.getLocation(), Chicken.class)); InfiniteChickenFamilyDisplayer.this.lastEgg.remove(); InfiniteChickenFamilyDisplayer.this.lastEgg = null; } } } }.runTaskTimer(this.hub, 20L, 20L); }
public CanaryChicken(net.canarymod.api.entity.living.animal.Chicken entity) { super(entity); }
@EventHandler(ignoreCancelled = true) public void onAnimalClick(PlayerInteractEntityEvent e) { // THIS EVENT FIRES TOO FAST WE NEED A TIMER World eworld = e.getPlayer().getLocation().getWorld(); // If plugin is not enabled in this world, return if (!PwnBreeding.isEnabledIn(eworld.getName())) return; Player player = e.getPlayer(); String thisItem = player.getItemInHand().getType().toString(); if(e.getRightClicked() instanceof Chicken) { e.setCancelled(true); player.sendMessage(ChatColor.GOLD + "Player has " + thisItem + " for a " + e.getRightClicked().getType().toString()); if (player.getItemInHand().getType() == Material.SEEDS) { if(player.getItemInHand().getAmount() > 1) { player.getItemInHand().setAmount(player.getItemInHand().getAmount() - 1); } else { player.getItemInHand().setAmount(0); } } } else if(e.getRightClicked() instanceof Cow) { player.sendMessage(ChatColor.GOLD + "Player has " + thisItem + " for a " + e.getRightClicked().getType().toString()); } else if(e.getRightClicked() instanceof Sheep) { player.sendMessage(ChatColor.GOLD + "Player has " + thisItem + " for a " + e.getRightClicked().getType().toString()); } else if(e.getRightClicked() instanceof Pig) { player.sendMessage(ChatColor.GOLD + "Player has " + thisItem + " for a " + e.getRightClicked().getType().toString()); } else if(e.getRightClicked() instanceof Horse) { player.sendMessage(ChatColor.GOLD + "Player has " + thisItem + " for a " + e.getRightClicked().getType().toString()); } else if(e.getRightClicked() instanceof Wolf) { player.sendMessage(ChatColor.GOLD + "Player has " + thisItem + " for a " + e.getRightClicked().getType().toString()); } else if(e.getRightClicked() instanceof Ocelot) { player.sendMessage(ChatColor.GOLD + "Player has " + thisItem + " for a " + e.getRightClicked().getType().toString()); } else if(e.getRightClicked() instanceof Rabbit) { player.sendMessage(ChatColor.GOLD + "Player has " + thisItem + " for a " + e.getRightClicked().getType().toString()); } }
@Override public void run() { if(target == null) { if (!arrow.isDead()) { return; } } double speed = arrow.getVelocity().length(); if ((!c && arrow.isOnGround()) || arrow.isDead() || target.isDead()) { cancel(); return; } Vector toTarget = target.getLocation().clone() .add(new Vector(c ? m : 0.0D, 0.5D, c ? m : 0.0D)) .subtract(arrow.getLocation()).toVector(); Vector dirVelocity = arrow.getVelocity().clone().normalize(); Vector dirToTarget = toTarget.clone().normalize(); double angle = dirVelocity.angle(dirToTarget); double newSpeed = 0.90000000000000002D * speed + 0.13999999999999999D; if ((target instanceof Player) && arrow.getLocation().distance(target.getLocation()) < 8D) { Player player = (Player) target; if (player.isBlocking()) { newSpeed = speed * 0.59999999999999998D; } } Vector newVelocity; if (angle < 0.12D) { newVelocity = dirVelocity.clone().multiply(newSpeed); } else { Vector newDir = dirVelocity.clone() .multiply((angle - 0.12D) / angle) .add(dirToTarget.clone().multiply(0.12D / angle)); newDir.normalize(); newVelocity = newDir.clone().multiply(newSpeed); } arrow.setVelocity(newVelocity.add(new Vector(0.0D, 0.029999999999999999D, 0.0D))); if(c) { arrow.getWorld().playSound(arrow.getLocation(), Sound.CHICKEN_HURT, 0.5F, 1.5F); ((Chicken) arrow).damage(0); } }
public void addChicken(Player p, Chicken chicken) { hash.put(p.getName(), chicken); }
public boolean containsChicken(Chicken chicken) { return hash.containsValue(chicken); }
public ChairExitEvent(Player who, Chicken chicken) { super(who); this.chicken = chicken; }
public Chicken getChairPiece() { return chicken; }
@Override public BehaviourItem[] getDefaultMovementBehaviours() { return new BehaviourItem[]{ new BehaviourItem(1, new BehaviourRandomTargetNonTamed(this, Chicken.class, 750, false)) }; }