org.bukkit.entity.Zombie Java Examples
The following examples show how to use
org.bukkit.entity.Zombie.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ControllableVillagerBase.java From EntityAPI with GNU Lesser General Public License v3.0 | 6 votes |
@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)) }; }
Example #2
Source File: PlayersManager.java From UhcCore with GNU General Public License v3.0 | 5 votes |
public void spawnOfflineZombieFor(Player player){ UhcPlayer uhcPlayer = getUhcPlayer(player); Zombie zombie = (Zombie) player.getWorld().spawnEntity(player.getLocation(), EntityType.ZOMBIE); zombie.setCustomName(uhcPlayer.getDisplayName()); zombie.setCustomNameVisible(true); // 1.8 doesn't have setAI method so use VersionUtils. VersionUtils.getVersionUtils().setEntityAI(zombie, false); zombie.setBaby(false); zombie.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 999999, 1, true, true)); EntityEquipment equipment = zombie.getEquipment(); equipment.setHelmet(VersionUtils.getVersionUtils().createPlayerSkull(player.getName(), player.getUniqueId())); equipment.setChestplate(player.getInventory().getChestplate()); equipment.setLeggings(player.getInventory().getLeggings()); equipment.setBoots(player.getInventory().getBoots()); equipment.setItemInHand(player.getItemInHand()); uhcPlayer.getStoredItems().clear(); for (ItemStack item : player.getInventory().getContents()){ if (item != null){ uhcPlayer.getStoredItems().add(item); } } uhcPlayer.setOfflineZombie(zombie); }
Example #3
Source File: Headless.java From ce with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void effect(Event e, ItemStack item, int level) { EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) e; final Player player = (Player) event.getDamager(); final LivingEntity ent = (LivingEntity) event.getEntity(); new BukkitRunnable() { @Override public void run() { if (ent.getHealth() <= 0) { byte type = 3; if (ent instanceof Skeleton) { type = 0; if (((Skeleton) ent).getSkeletonType().equals(SkeletonType.WITHER)) type = 1; } else if (ent instanceof Zombie) type = 2; else if (ent instanceof Creeper) type = 4; ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, type); if (type == 3) { SkullMeta sm = (SkullMeta) skull.getItemMeta(); sm.setOwner(ent.getName()); skull.setItemMeta(sm); } ent.getWorld().dropItem(ent.getLocation(), skull); EffectManager.playSound(player.getLocation(), "BLOCK_ANVIL_LAND", 0.1f, 1.5f); } } }.runTaskLater(getPlugin(), 5l); }
Example #4
Source File: EntityDeathListener.java From UhcCore with GNU General Public License v3.0 | 5 votes |
private void handleOfflineZombieDeath(EntityDeathEvent event){ if (event.getEntityType() != EntityType.ZOMBIE){ return; } Zombie zombie = (Zombie) event.getEntity(); GameManager gm = GameManager.getGameManager(); if (zombie.getCustomName() == null){ return; } UhcPlayer uhcPlayer = null; for (UhcPlayer player : gm.getPlayersManager().getPlayersList()){ if (player.getOfflineZombie() != null && player.getOfflineZombie().equals(zombie)){ // found player uhcPlayer = player; break; } } if (uhcPlayer == null){ return; } event.getDrops().clear(); uhcPlayer.setOfflineZombie(null); gm.getPlayersManager().killOfflineUhcPlayer(uhcPlayer, zombie.getLocation(), new HashSet<>(uhcPlayer.getStoredItems()), zombie.getKiller()); }
Example #5
Source File: ZombieTrait.java From StackMob-3 with GNU General Public License v3.0 | 5 votes |
@Override public boolean checkTrait(Entity original, Entity nearby) { if(original instanceof Zombie){ return (((Zombie) original).isBaby() != ((Zombie) nearby).isBaby()); } return false; }
Example #6
Source File: SwordOfBeheading.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
@Override public EntityKillHandler getItemHandler() { return (e, entity, killer, item) -> { Random random = ThreadLocalRandom.current(); if (e.getEntity() instanceof Zombie) { if (random.nextInt(100) < chanceZombie.getValue()) { e.getDrops().add(new ItemStack(Material.ZOMBIE_HEAD)); } } else if (e.getEntity() instanceof WitherSkeleton) { if (random.nextInt(100) < chanceWitherSkeleton.getValue()) { e.getDrops().add(new ItemStack(Material.WITHER_SKELETON_SKULL)); } } else if (e.getEntity() instanceof Skeleton) { if (random.nextInt(100) < chanceSkeleton.getValue()) { e.getDrops().add(new ItemStack(Material.SKELETON_SKULL)); } } else if (e.getEntity() instanceof Creeper) { if (random.nextInt(100) < chanceCreeper.getValue()) { e.getDrops().add(new ItemStack(Material.CREEPER_HEAD)); } } else if (e.getEntity() instanceof Player && random.nextInt(100) < chancePlayer.getValue()) { ItemStack skull = new ItemStack(Material.PLAYER_HEAD); ItemMeta meta = skull.getItemMeta(); ((SkullMeta) meta).setOwningPlayer((Player) e.getEntity()); skull.setItemMeta(meta); e.getDrops().add(skull); } }; }
Example #7
Source File: SpawnEventsTest.java From uSkyBlock with GNU General Public License v3.0 | 5 votes |
@Test public void onPhantomSpawn_noPhantom() { Zombie entity = mock(Zombie.class); CreatureSpawnEvent event = new CreatureSpawnEvent(entity, CreatureSpawnEvent.SpawnReason.NATURAL); spawnEvents.onPhantomSpawn(event); assertFalse(event.isCancelled()); }
Example #8
Source File: MobSpawnEvent.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
@Override public void doEvent() { if (gMap.getMatchState() == MatchState.PLAYING) { this.fired = true; sendTitle(); World world = gMap.getCurrentWorld(); for (int i = 0; i < gMap.getAlivePlayers().size(); i++) { Player player = gMap.getAlivePlayers().get(i); br1 = new BukkitRunnable() { @Override public void run() { if (player != null) { List<Block> blocks = getSpawnableBlocks(player.getLocation()); Collections.shuffle(blocks); for (int i = 0; i < Util.get().getRandomNum(minMobsPerPlayer, maxMobsPerPlayer); i++) { Location spawn = blocks.get(i).getLocation().clone().add(0, 1, 0); LivingEntity ent = (LivingEntity) world.spawnEntity(spawn, EntityType.valueOf(mobs.get(ThreadLocalRandom.current().nextInt(0, mobs.size())).toUpperCase())); if (ent instanceof Zombie || ent instanceof Skeleton) { ent.getEquipment().setHelmet(new ItemStack(Material.CHAINMAIL_HELMET, 1)); } SkyWarsReloaded.getNMS().setEntityTarget(ent, player); mobsSpawned.add(ent); } } } }.runTaskLater(SkyWarsReloaded.get(), i * 3L); } if (length != -1) { br2 = new BukkitRunnable() { @Override public void run() { endEvent(false); } }.runTaskLater(SkyWarsReloaded.get(), length * 20L); } } }
Example #9
Source File: UhcPlayer.java From UhcCore with GNU General Public License v3.0 | 4 votes |
public Zombie getOfflineZombie() { return offlineZombie; }
Example #10
Source File: AbstractEntityZombiePet.java From SonarPet with GNU General Public License v3.0 | 4 votes |
@Override public Zombie getBukkitEntity() { return (Zombie) super.getBukkitEntity(); }
Example #11
Source File: ZombiePet.java From SonarPet with GNU General Public License v3.0 | 4 votes |
@SuppressWarnings("deprecation") @Override public void setZombieType(ZombieType newType) { if (newType == this.zombieType) return; if (Versioning.NMS_VERSION.compareTo(NmsVersion.v1_11_R1) >= 0) { final EntityHookType hookType; switch (newType) { case NORMAL: hookType = EntityHookType.ZOMBIE; break; case HUSK: hookType = EntityHookType.HUSK_ZOMBIE; break; case VILLAGER: hookType = EntityHookType.VILLAGER_ZOMBIE; break; case PIGMAN: hookType = EntityHookType.PIG_ZOMBIE; break; default: throw new IllegalArgumentException("Unknown zombie type: " + newType); } switchHookType(getOwner(), hookType); } else { if (this.getZombieType() == ZombieType.PIGMAN && newType != ZombieType.PIGMAN) { // Switch to a normal zombie switchHookType(getOwner(), EntityHookType.ZOMBIE); } switch (newType) { case PIGMAN: // Pigmen are considered a separate entity type, even on old versions switchHookType(getOwner(), EntityHookType.PIG_ZOMBIE); break; case NORMAL: ((Zombie) getEntityPet().getBukkitEntity()).setVillager(false); break; case VILLAGER: ((Zombie) getEntityPet().getBukkitEntity()).setVillager(true); default: throw new IllegalArgumentException("Unknown zombie type: " + newType); } } this.zombieType = newType; }
Example #12
Source File: SmallTreasureGoblin.java From EliteMobs with GNU General Public License v3.0 | 4 votes |
@EventHandler (priority = EventPriority.HIGHEST) public void onSpawn(CreatureSpawnEvent event) { if (event.isCancelled()) return; if (!EventLauncher.verifyPlayerCount()) return; if (EliteMobs.validWorldList.contains(event.getEntity().getWorld())) { if (entityQueued && (event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.NATURAL) || event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.CUSTOM)) && event.getEntity() instanceof Zombie) { entityQueued = false; initalizeEvent(event.getLocation()); } } }
Example #13
Source File: ZombieTrait.java From StackMob-3 with GNU General Public License v3.0 | 4 votes |
@Override public void applyTrait(Entity original, Entity spawned) { if(original instanceof Zombie) { ((Zombie) spawned).setBaby(((Zombie) original).isBaby()); } }
Example #14
Source File: EntityDamageListener.java From UhcCore with GNU General Public License v3.0 | 4 votes |
private void handleOfflinePlayers(EntityDamageByEntityEvent e){ if (e.getEntityType() != EntityType.ZOMBIE || !(e.getDamager() instanceof Player)){ return; } GameManager gm = GameManager.getGameManager(); MainConfiguration cfg = gm.getConfiguration(); PlayersManager pm = gm.getPlayersManager(); // Offline players are disabled if (!cfg.getSpawnOfflinePlayers()){ return; } Zombie zombie = (Zombie) e.getEntity(); UhcPlayer damager = pm.getUhcPlayer((Player) e.getDamager()); UhcPlayer owner = null; // Find zombie owner for (UhcPlayer uhcPlayer : pm.getPlayersList()){ if (uhcPlayer.getOfflineZombie() != null && uhcPlayer.getOfflineZombie() == zombie){ owner = uhcPlayer; break; } } // Not a offline player if (owner == null){ return; } boolean pvp = gm.getPvp(); boolean isTeamMember = owner.isInTeamWith(damager); boolean friendlyFire = gm.getConfiguration().getEnableFriendlyFire(); // If PvP is false or is team member & friendly fire is off if (!pvp || (isTeamMember && !friendlyFire)){ e.setCancelled(true); // Canceled due to friendly fire, so send message if (pvp){ damager.sendMessage(Lang.PLAYERS_FF_OFF); } } }
Example #15
Source File: UhcPlayer.java From UhcCore with GNU General Public License v3.0 | 4 votes |
public void setOfflineZombie(Zombie offlineZombie) { this.offlineZombie = offlineZombie; }
Example #16
Source File: TheReturned.java From EliteMobs with GNU General Public License v3.0 | 3 votes |
public static void theReturnedConstructor(int mobLevel, Zombie zombie) { Location spawnLocation = zombie.getLocation(); ReinforcementMobEntity reinforcementMobEntity = new ReinforcementMobEntity(EntityType.HUSK, spawnLocation, mobLevel, ConfigValues.eventsConfig.getString(EventsConfig.DEAD_MOON_THE_RETURNED_NAME), CreatureSpawnEvent.SpawnReason.NATURAL); double x = ThreadLocalRandom.current().nextDouble() - 0.5; double z = ThreadLocalRandom.current().nextDouble() - 0.5; reinforcementMobEntity.getLivingEntity().setVelocity(new Vector(x, 0.5, z)); new BukkitRunnable() { @Override public void run() { reinforcementMobEntity.getLivingEntity().getEquipment().setBoots(new ItemStack(Material.AIR)); reinforcementMobEntity.getLivingEntity().getEquipment().setLeggings(new ItemStack(Material.AIR)); reinforcementMobEntity.getLivingEntity().getEquipment().setChestplate(new ItemStack(Material.AIR)); reinforcementMobEntity.getLivingEntity().getEquipment().setHelmet(new ItemStack(Material.AIR)); reinforcementMobEntity.getLivingEntity().getEquipment().setItemInMainHand(new ItemStack(Material.AIR)); } }.runTaskLater(MetadataHandler.PLUGIN, 1); }
Example #17
Source File: TheReturned.java From EliteMobs with GNU General Public License v3.0 | 3 votes |
private void spawnTheReturned(Zombie zombie) { /* Wait a tick before spawning as third party compatibility can get messy with spawn events */ new BukkitRunnable() { @Override public void run() { if (!zombie.isValid()) return; if (theReturnedList.contains(zombie)) return; int mobLevel; if (EntityTracker.isEliteMob(zombie)) mobLevel = (int) Math.ceil(EntityTracker.getEliteMobEntity(zombie).getLevel() / 2); else mobLevel = 1; theReturnedConstructor(mobLevel, zombie); theReturnedConstructor(mobLevel, zombie); } }.runTaskLater(MetadataHandler.PLUGIN, 1); }
Example #18
Source File: TheReturned.java From EliteMobs with GNU General Public License v3.0 | 3 votes |
@EventHandler public void onSpawn(EntitySpawnEvent event) { if (!DeadMoon.eventOngoing) return; if (event.getEntity() instanceof LivingEntity && theReturnedList.contains(event.getEntity())) spawnTheReturned((Zombie) event.getEntity()); }