当前位置: 首页>>代码示例>>Java>>正文


Java Chicken类代码示例

本文整理汇总了Java中org.bukkit.entity.Chicken的典型用法代码示例。如果您正苦于以下问题:Java Chicken类的具体用法?Java Chicken怎么用?Java Chicken使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Chicken类属于org.bukkit.entity包,在下文中一共展示了Chicken类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onInteract

import org.bukkit.entity.Chicken; //导入依赖的package包/类
@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);
			}
		}
	}
}
 
开发者ID:xEssentials,项目名称:xEssentials-deprecated-bukkit,代码行数:23,代码来源:PlayerSitOnChairEvent_org.java

示例2: TrackTask

import org.bukkit.entity.Chicken; //导入依赖的package包/类
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;
}
 
开发者ID:ColonelHedgehog,项目名称:Equestrian-Dash,代码行数:12,代码来源:TrackTask.java

示例3: onDamage

import org.bukkit.entity.Chicken; //导入依赖的package包/类
@EventHandler
public void onDamage(EntityDamageEvent e) {
	if(e.getEntity() instanceof Chicken) {
		Chicken chicken = (Chicken) e.getEntity();
		if(chicken.hasMetadata("chair")) {
			e.setCancelled(true);
		}
	}
}
 
开发者ID:xEssentials,项目名称:xEssentials-deprecated-bukkit,代码行数:10,代码来源:PlayerSitOnChairEvent_org.java

示例4: run

import org.bukkit.entity.Chicken; //导入依赖的package包/类
@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()));	
		}
	}
}
 
开发者ID:xEssentials,项目名称:xEssentials-deprecated-bukkit,代码行数:12,代码来源:PlayerSitOnChairEvent_org.java

示例5: display

import org.bukkit.entity.Chicken; //导入依赖的package包/类
@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);
}
 
开发者ID:SamaGames,项目名称:Hub,代码行数:43,代码来源:InfiniteChickenFamilyDisplayer.java

示例6: CanaryChicken

import org.bukkit.entity.Chicken; //导入依赖的package包/类
public CanaryChicken(net.canarymod.api.entity.living.animal.Chicken entity) {
    super(entity);
}
 
开发者ID:CanaryBukkitTeam,项目名称:CanaryBukkit,代码行数:4,代码来源:CanaryChicken.java

示例7: onAnimalClick

import org.bukkit.entity.Chicken; //导入依赖的package包/类
@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());
      }        
  }
 
开发者ID:Pwn9,项目名称:PwnBreeding,代码行数:62,代码来源:FeedListener.java

示例8: run

import org.bukkit.entity.Chicken; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:ColonelHedgehog,项目名称:Equestrian-Dash,代码行数:55,代码来源:TrackTask.java

示例9: addChicken

import org.bukkit.entity.Chicken; //导入依赖的package包/类
public void addChicken(Player p, Chicken chicken) {
	hash.put(p.getName(), chicken);
}
 
开发者ID:xEssentials,项目名称:xEssentials-deprecated-bukkit,代码行数:4,代码来源:ChairManager.java

示例10: containsChicken

import org.bukkit.entity.Chicken; //导入依赖的package包/类
public boolean containsChicken(Chicken chicken) {
	return hash.containsValue(chicken);
}
 
开发者ID:xEssentials,项目名称:xEssentials-deprecated-bukkit,代码行数:4,代码来源:ChairManager.java

示例11: ChairExitEvent

import org.bukkit.entity.Chicken; //导入依赖的package包/类
public ChairExitEvent(Player who, Chicken chicken) {
	super(who);
	this.chicken = chicken;
}
 
开发者ID:xEssentials,项目名称:xEssentials-deprecated-bukkit,代码行数:5,代码来源:ChairExitEvent.java

示例12: getChairPiece

import org.bukkit.entity.Chicken; //导入依赖的package包/类
public Chicken getChairPiece() {
	return chicken;
}
 
开发者ID:xEssentials,项目名称:xEssentials-deprecated-bukkit,代码行数:4,代码来源:ChairExitEvent.java

示例13: getDefaultMovementBehaviours

import org.bukkit.entity.Chicken; //导入依赖的package包/类
@Override
public BehaviourItem[] getDefaultMovementBehaviours() {
    return new BehaviourItem[]{
            new BehaviourItem(1, new BehaviourRandomTargetNonTamed(this, Chicken.class, 750, false))
    };
}
 
开发者ID:EntityAPIDev,项目名称:EntityAPI,代码行数:7,代码来源:ControllableOcelotBase.java


注:本文中的org.bukkit.entity.Chicken类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。