當前位置: 首頁>>代碼示例>>Java>>正文


Java Zombie類代碼示例

本文整理匯總了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());
        }
    }
}
 
開發者ID:cadox8,項目名稱:WC,代碼行數:27,代碼來源:WorldInteract.java

示例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);
}
 
開發者ID:zachbr,項目名稱:Debuggery,代碼行數:22,代碼來源:InputFormatterTest.java

示例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.
}
 
開發者ID:Kneesnap,項目名稱:Kineticraft,代碼行數:22,代碼來源:Pinata.java

示例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()));
}
 
開發者ID:Kneesnap,項目名稱:Kineticraft,代碼行數:27,代碼來源:Pinata.java

示例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);
    }
}
 
開發者ID:Project-Coalesce,項目名稱:UHC,代碼行數:19,代碼來源:JoinQuitHandlers.java

示例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);
}
 
開發者ID:savior67,項目名稱:BendingExp,代碼行數:21,代碼來源:DeathByBendingListener.java

示例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);
			}
		}
	}
}
 
開發者ID:TheLimeGlass,項目名稱:Skellett,代碼行數:19,代碼來源:EffBabyAdult.java

示例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;
}
 
開發者ID:TheLimeGlass,項目名稱:Skellett,代碼行數:17,代碼來源:CondIsAdult.java

示例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);
}
 
開發者ID:stefvanschie,項目名稱:buildinggame,代碼行數:27,代碼來源:BabyMenu.java

示例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());
					}
				}
			}
		}
	}
}
 
開發者ID:odarriba,項目名稱:defend-the-village,代碼行數:23,代碼來源:Main.java

示例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); 		
	}
	
}
 
開發者ID:Wintergrasped,項目名稱:NSHC,代碼行數:20,代碼來源:RandomEvents.java

示例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
}
 
開發者ID:nheir,項目名稱:killBaby,代碼行數:20,代碼來源:KillBaby.java

示例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();
   }
 
開發者ID:AlexMl,項目名稱:ZvP,代碼行數:25,代碼來源:DeathMatch.java

示例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);
		}
	    }
	}
    }
}
   }
 
開發者ID:AlexMl,項目名稱:ZvP,代碼行數:24,代碼來源:DeathMatch.java

示例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))
    };
}
 
開發者ID:EntityAPIDev,項目名稱:EntityAPI,代碼行數:21,代碼來源:ControllableVillagerBase.java


注:本文中的org.bukkit.entity.Zombie類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。