本文整理汇总了Java中org.bukkit.entity.Zombie类的典型用法代码示例。如果您正苦于以下问题:Java Zombie类的具体用法?Java Zombie怎么用?Java Zombie使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Zombie类属于org.bukkit.entity包,在下文中一共展示了Zombie类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onMobDie
import org.bukkit.entity.Zombie; //导入依赖的package包/类
@EventHandler
public void onMobDie(EntityDeathEvent e){
AllItems items = new AllItems();
Location l = e.getEntity().getLocation();
World w = l.getWorld();
e.getDrops().clear();
e.setDroppedExp(0);
if (e.getEntity() instanceof Zombie){
if (new Random().nextInt(5) >= 3){
w.dropItemNaturally(l, new ItemMaker(Material.EMERALD).setAmount(new Random().nextInt(4) + 1).build());
if (new Random().nextBoolean()){
w.dropItemNaturally(l, items.weapons.get(new Random().nextInt(items.weapons.size())));
} else {
w.dropItemNaturally(l, items.health.get(new Random().nextInt(items.health.size())));
}
}
}
if (e.getEntity() instanceof Giant){
if (new Random().nextInt(5) > 3){
w.dropItemNaturally(l, new ItemMaker(Material.NETHER_STAR).setAmount(new Random().nextInt(4) + 1).build());
}
}
}
示例2: testBukkitClasses
import org.bukkit.entity.Zombie; //导入依赖的package包/类
@Test
public void testBukkitClasses() throws InputException {
Class[] inputTypes = {Class[].class};
String[] input = {"Zombie,Creeper,Pig"};
Object[] output = InputFormatter.getTypesFromInput(inputTypes, Arrays.asList(input), null);
// First let's make sure we didn't lose anything, or get anything
assertEquals(inputTypes.length, output.length);
// Next let's make sure everything is the right type
for (Object object : output) {
assertTrue(object instanceof Class[]);
}
// Finally, let's make sure the values are correct
Class[] classes = (Class[]) output[0];
assertEquals(classes[0], Zombie.class);
assertEquals(classes[1], Creeper.class);
assertEquals(classes[2], Pig.class);
}
示例3: spawnZombie
import org.bukkit.entity.Zombie; //导入依赖的package包/类
private void spawnZombie() {
Location center = new Location(Parties.getPartyWorld(), -74.5, 76, 30);
Zombie z = center.getWorld().spawn(Utils.scatter(center, 4, 0, 4), Zombie.class);
z.setCustomNameVisible(true);
z.setCustomName(ChatColor.RED + "Piñata");
z.getEquipment().setHelmet(ItemManager.createSkull("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZn"
+ "QubmV0L3RleHR1cmUvM2IyNTI2NmQ0MGNlY2Q5M2QwNTMxNTZlNGE0YTc4NDE0MGQwMzQyNTVjNzIxY2MzNzVkMWMzNjQ4MzQyYjZmZCJ9fX0",
"Pinata Skull", "He doesn't want to party anymore."));
z.getEquipment().setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE));
z.getEquipment().setLeggings(new ItemStack(Material.LEATHER_LEGGINGS));
z.getEquipment().setBoots(new ItemStack(Material.LEATHER_BOOTS));
z.getEquipment().setItemInMainHand(ItemManager.createItem(Material.STICK, ChatColor.RED + "Pinata Bat", ChatColor.DARK_PURPLE + "Stop hitting me!"));
z.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(40);
z.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(.4F);
z.getAttribute(Attribute.GENERIC_ATTACK_DAMAGE).setBaseValue(6);
z.getAttribute(Attribute.GENERIC_KNOCKBACK_RESISTANCE).setBaseValue(1);
z.setSilent(true);
z.setGlowing(true);
getScheduler().runTaskLater(z::remove, 1200L); // Remove zombie in 1 minute.
}
示例4: onEntityDeath
import org.bukkit.entity.Zombie; //导入依赖的package包/类
@EventHandler
public void onEntityDeath(EntityDeathEvent evt) { // If a pinata is killed, have a 12% chance of dropping something extra.
if (evt.getEntity() instanceof Zombie && getArena().contains(evt.getEntity().getLocation()) && Utils.randChance(8))
evt.getDrops().add(Utils.randElement(
ItemManager.createItem(Material.DIAMOND, ChatColor.AQUA + "Rock Candy", "So delicious, so rare."),
ItemManager.createItem(Material.CAKE, ChatColor.LIGHT_PURPLE + "Birthday Cake", "Happy 3rd Anniversary, Kineticraft!"),
ItemManager.createItem(Material.SEA_LANTERN, ChatColor.RED + "Jaw Breaker", "Suck it, Piñatas!"),
ItemManager.createItem(Material.IRON_BLOCK, ChatColor.RED + "Hershey's Kiss", "Mmmm, so chocolatey."),
ItemManager.createItem(Material.TNT, ChatColor.LIGHT_PURPLE + "Pop Rocks", "An explosion for your taste buds."),
ItemManager.createItem(Material.MAGMA_CREAM, ChatColor.RED + "Atomic Fireball", "It burns so good."),
ItemManager.createItem(Material.EXP_BOTTLE, ChatColor.AQUA + "Soda", "Refreshing and fizzy."),
ItemManager.createItem(Material.SLIME_BALL, ChatColor.AQUA + "Taffy", "Chewy...careful not to glue your teeth together!"),
ItemManager.createItem(Material.NETHER_STALK, ChatColor.RED + "Twizzlers", "Gimme some sugar."),
ItemManager.createItem(Material.MYCEL, ChatColor.RED + "Fudge", "What the fudge!?"),
ItemManager.createItem(Material.WEB, ChatColor.LIGHT_PURPLE + "Cotton Candy", "So fluffy!"),
ItemManager.createItem(Material.RAW_FISH, (byte) 1, ChatColor.LIGHT_PURPLE + "Swedish Fish", "A yummy, gummy candy."),
ItemManager.createItem(Material.RED_ROSE, (byte) 2, ChatColor.AQUA + "Lollipop", "I'm a sucker for puns."),
ItemManager.createItem(Material.COOKIE, ChatColor.YELLOW + "Birthday Cookie", "You're one smart cookie!"),
ItemManager.createItem(Material.BLAZE_ROD, ChatColor.RED + "Hot Tamale", "You're one hot Tamale!"),
ItemManager.createItem(Material.PUMPKIN_PIE, ChatColor.GOLD + "Seasonal Treat", "Pumpkin Spice flavor ALL THE THINGS!"),
ItemManager.createItem(Material.EMERALD, ChatColor.GREEN + "Gumball", "I chews you! <3"),
ItemManager.createItem(Material.GOLDEN_APPLE, ChatColor.GOLD + "Caramel Apple", "...and we lived apple-y ever after <3"),
ItemManager.createItem(Material.HUGE_MUSHROOM_2, ChatColor.RED + "Strawberry Bon Bon", "You're the berry best."),
evt.getEntity().getEquipment().getHelmet(),
evt.getEntity().getEquipment().getItemInMainHand()));
}
示例5: leave
import org.bukkit.entity.Zombie; //导入依赖的package包/类
@EventHandler
public void leave(final PlayerQuitEvent event) {
if(GameState.current() != GameState.LOBBY && event.getPlayer().getGameMode() != GameMode.SPECTATOR){
event.setQuitMessage(colour("&6" + event.getPlayer().getName() + " has quit! " +
"They have " + UHC.getInstance().getMainConfig().getDisconnectGracePeriodSeconds() + "s to reconnect."));
bukkitRunnable(() -> disqualified(event.getPlayer().getUniqueId(), event.getPlayer().getName(),
event.getPlayer().getLocation(), event.getPlayer().getInventory())).runTaskLater(UHC.getInstance(),
TimeUnit.MILLISECONDS.convert(UHC.getInstance().getMainConfig().getDisconnectGracePeriodSeconds(), TimeUnit.SECONDS));
//Zombie Spawning
Zombie zombie = (Zombie) event.getPlayer().getWorld().spawnEntity(event.getPlayer().getLocation(), EntityType.ZOMBIE);
zombie.setCustomName(event.getPlayer().getName());
zombie.setCustomNameVisible(true);
//TODO Make no AI and invulnerable cough cough Proxi cough cough
deadRepresentatives.put(event.getPlayer().getUniqueId(), zombie);
}
}
示例6: onEntityBendingDeath
import org.bukkit.entity.Zombie; //导入依赖的package包/类
@EventHandler
public void onEntityBendingDeath(EntityBendingDeathEvent event) {
Entity v = event.getVictim();
Element e = CoreAbility.getAbility(event.getAbility()).getElement();
int xp;
if(v == null || e == null)
return;
if(v instanceof Player) {
xp = 25 + (int)(Math.random() * ((35 - 25) + 1));
}
else if(v instanceof Zombie || v instanceof Creeper || v instanceof Witch || v instanceof Skeleton || v instanceof Guardian || v instanceof Spider) {
xp = 13 + (int)(Math.random() * ((22 - 13) + 1));
}
else {
xp = 3 + (int)(Math.random() * ((8 - 3) + 1));
}
BendingExp.addExp(event.getAttacker(), e, xp);
}
示例7: execute
import org.bukkit.entity.Zombie; //导入依赖的package包/类
@Override
protected void execute(Event e) {
if (entity != null) {
if (marker == 1) {
if (Ageable.class.isAssignableFrom(entity.getSingle(e).getClass())) {
((Ageable)entity.getSingle(e)).setBaby();
} else if (Zombie.class.isAssignableFrom(entity.getSingle(e).getClass())) {
((Zombie)entity.getSingle(e)).setBaby(true);
}
} else {
if (Ageable.class.isAssignableFrom(entity.getSingle(e).getClass())) {
((Ageable)entity.getSingle(e)).setAdult();
} else if (Zombie.class.isAssignableFrom(entity.getSingle(e).getClass())) {
((Zombie)entity.getSingle(e)).setBaby(false);
}
}
}
}
示例8: check
import org.bukkit.entity.Zombie; //导入依赖的package包/类
public boolean check(Event e) {
if (entity.getSingle(e) instanceof Ageable) {
if (((Ageable)entity.getSingle(e)).isAdult()) {
return isNegated();
} else {
return !isNegated();
}
} else if (entity.getSingle(e) instanceof Zombie) {
if (((Zombie)entity.getSingle(e)).isBaby()) {
return !isNegated();
} else {
return isNegated();
}
}
return false;
}
示例9: BabyMenu
import org.bukkit.entity.Zombie; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public BabyMenu(Plot plot, Entity entity) {
super(plot, entity);
ItemStack baby = new ItemStack(Material.EGG);
ItemMeta babyMeta = baby.getItemMeta();
babyMeta.setDisplayName(ChatColor.GREEN + "Change to baby/adult");
baby.setItemMeta(babyMeta);
insertItem(baby, event -> {
if (entity instanceof Ageable) {
Ageable ageable = (Ageable) entity;
if (ageable.isAdult())
ageable.setBaby();
else
ageable.setAdult();
} else if (entity instanceof Zombie) {
Zombie zombie = (Zombie) entity;
zombie.setBaby(!zombie.isBaby());
}
event.setCancelled(true);
}, 0);
}
示例10: onDeath
import org.bukkit.entity.Zombie; //导入依赖的package包/类
@EventHandler(priority=EventPriority.HIGHEST)
public void onDeath(PlayerDeathEvent ev) {
// Is the player in game?
if (this.am.isInGame((Player)ev.getEntity())) {
// Dont' drop anything
ev.getDrops().clear();
ev.setDeathMessage(null);
// Find the arena were the player is playing
for (Arena a : this.am.arenas) {
if (a.players.contains(ev.getEntity().getName())) {
for (Zombie z : a.zombies) {
// Send all the killer zombies to kill the villagers
if (z.getTarget().equals(ev.getEntity())) {
CraftZombie z2 = (CraftZombie) z;
z2.getHandle().setGoalTarget(((CraftLivingEntity) a.villagers.get(0)).getHandle());
}
}
}
}
}
}
示例11: ZombieApoc
import org.bukkit.entity.Zombie; //导入依赖的package包/类
public void ZombieApoc() {
for (Player pl : Bukkit.getOnlinePlayers()) {
Bukkit.broadcastMessage(ChatColor.BOLD+""+ChatColor.RED+"The Zombie Appocolypse Has Begun!");
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "time night");
Location loc = pl.getLocation();
Zombie zombie = (Zombie) pl.getWorld().spawnEntity((Location) Arrays.asList(circle(loc, 4, 1, true, true, 1)), EntityType.ZOMBIE);
Zombie zombie1 = (Zombie) pl.getWorld().spawnEntity((Location) Arrays.asList(circle(loc, 4, 1, true, true, 1)), EntityType.ZOMBIE);
Zombie zombie2 = (Zombie) pl.getWorld().spawnEntity((Location) Arrays.asList(circle(loc, 4, 1, true, true, 1)), EntityType.ZOMBIE);
Zombie zombie3 = (Zombie) pl.getWorld().spawnEntity((Location) Arrays.asList(circle(loc, 4, 1, true, true, 1)), EntityType.ZOMBIE);
Zombie zombie4 = (Zombie) pl.getWorld().spawnEntity((Location) Arrays.asList(circle(loc, 4, 1, true, true, 1)), EntityType.ZOMBIE);
Zombie zombie5 = (Zombie) pl.getWorld().spawnEntity((Location) Arrays.asList(circle(loc, 4, 1, true, true, 1)), EntityType.ZOMBIE);
Zombie zombie6 = (Zombie) pl.getWorld().spawnEntity((Location) Arrays.asList(circle(loc, 4, 1, true, true, 1)), EntityType.ZOMBIE);
Zombie zombie7 = (Zombie) pl.getWorld().spawnEntity((Location) Arrays.asList(circle(loc, 4, 1, true, true, 1)), EntityType.ZOMBIE);
Zombie zombie8 = (Zombie) pl.getWorld().spawnEntity((Location) Arrays.asList(circle(loc, 4, 1, true, true, 1)), EntityType.ZOMBIE);
Zombie zombie9 = (Zombie) pl.getWorld().spawnEntity((Location) Arrays.asList(circle(loc, 4, 1, true, true, 1)), EntityType.ZOMBIE);
Zombie zombie0 = (Zombie) pl.getWorld().spawnEntity((Location) Arrays.asList(circle(loc, 4, 1, true, true, 1)), EntityType.ZOMBIE);
}
}
示例12: onSpawn
import org.bukkit.entity.Zombie; //导入依赖的package包/类
@EventHandler
public void onSpawn(CreatureSpawnEvent event) {
if(event.isCancelled())
return;
LivingEntity c = event.getEntity();
if(c instanceof Zombie)
{
Zombie a = (Zombie) c;
if(a.isBaby())
{
a.setBaby(false);
//a.remove();
}
}
// Some code here
}
示例13: onDeath
import org.bukkit.entity.Zombie; //导入依赖的package包/类
@Override
public void onDeath(ZvPPlayer player, PlayerDeathEvent event) {
super.onDeath(player, event);
this.playerDrops.put(player, new ArrayList<ItemStack>(event.getDrops()));
event.getDrops().clear();
Entity entitiy = getArena().getWorld().spawnEntity(player.getLocation(), EntityType.ZOMBIE);
if (entitiy != null) {
getArena().getDifficultyTool().customizeEntity(entitiy);
}
ItemStack playerSkull = new ItemStack(Material.SKULL_ITEM);
playerSkull.setDurability((short) 3);
SkullMeta meta = (SkullMeta) playerSkull.getItemMeta();
meta.setOwner(player.getName());
playerSkull.setItemMeta(meta);
Zombie z = (Zombie) entitiy;
z.setBaby(false);
z.getEquipment().setHelmet(playerSkull);
z.setMaxHealth(2 * 20);
getArena().updatePlayerBoards();
}
示例14: onZombieKill
import org.bukkit.entity.Zombie; //导入依赖的package包/类
@Override
public void onZombieKill(ZvPPlayer attacker, Entity zombie, EntityDeathEvent event) {
super.onZombieKill(attacker, zombie, event);
Zombie z = (Zombie) zombie;
if (z.getEquipment().getHelmet().getType() == Material.SKULL_ITEM) {
if (z.getEquipment().getHelmet().hasItemMeta() && z.getEquipment().getHelmet().getItemMeta() instanceof SkullMeta) {
SkullMeta meta = (SkullMeta) z.getEquipment().getHelmet().getItemMeta();
if (meta.hasOwner()) {
ZvPPlayer player = GameManager.getManager().getPlayer(meta.getOwner());
if (player != null) {
if (this.playerDrops.containsKey(player)) {
event.getDrops().clear();
event.getDrops().addAll(this.playerDrops.get(player));
this.playerDrops.remove(player);
}
}
}
}
}
}
示例15: getDefaultMovementBehaviours
import org.bukkit.entity.Zombie; //导入依赖的package包/类
@Override
public BehaviourItem[] getDefaultMovementBehaviours() {
return new BehaviourItem[]{
new BehaviourItem(0, new BehaviourFloat(this)),
new BehaviourItem(1, new BehaviourAvoidEntity(this, Zombie.class, 8.0F, 0.6D, 0.6D)),
new BehaviourItem(1, new BehaviourTradeWithPlayer(this)),
new BehaviourItem(1, new BehaviourLookAtTradingPlayer(this)),
new BehaviourItem(2, new BehaviourMoveIndoors(this)),
new BehaviourItem(3, new BehaviourRestrictOpenDoor(this)),
new BehaviourItem(4, new BehaviourOpenDoor(this, true)),
new BehaviourItem(5, new BehaviourMoveTowardsRestriction(this, 0.6D)),
new BehaviourItem(6, new BehaviourMakeLove(this)),
new BehaviourItem(7, new BehaviourTakeFlower(this)),
new BehaviourItem(8, new BehaviourVillagerPlay(this, 0.32D)),
new BehaviourItem(9, new BehaviourInteract(this, HumanEntity.class, 3.0F, 1.0F)),
new BehaviourItem(9, new BehaviourInteract(this, Villager.class, 3.0F, 1.0F)),
new BehaviourItem(9, new BehaviourRandomStroll(this, 0.6D)),
new BehaviourItem(10, new BehaviourLookAtNearestEntity(this, InsentientEntity.class, 8.0F))
};
}