org.bukkit.entity.WitherSkeleton Java Examples

The following examples show how to use org.bukkit.entity.WitherSkeleton. 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: EntitySkeletonPet.java    From SonarPet with GNU General Public License v3.0 6 votes vote down vote up
@Override
@SuppressWarnings("deprecation") // We do a version check ;)
public SkeletonType getSkeletonType() {
    if (Versioning.NMS_VERSION.compareTo(NmsVersion.v1_11_R1) >= 0) {
        if (getBukkitEntity() instanceof WitherSkeleton) {
            return SkeletonType.WITHER;
        } else if (getBukkitEntity() instanceof Stray) {
            return SkeletonType.STRAY;
        } else {
            return SkeletonType.NORMAL;
        }
    } else {
        switch (getBukkitEntity().getSkeletonType()) {
            case WITHER:
                return SkeletonType.WITHER;
            case STRAY:
                return SkeletonType.STRAY;
            case NORMAL:
                return SkeletonType.NORMAL;
            default:
                throw new AssertionError("Unknown skeleton type!");
        }
    }
}
 
Example #2
Source File: NetherTerraFormEvents.java    From uSkyBlock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Comes AFTER the SpawnEvents{@link #onCreatureSpawn(CreatureSpawnEvent)} - so cancelled will have effect
 * @param e
 */
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onCreatureSpawn(CreatureSpawnEvent e) {
    if (!spawnEnabled || e.getSpawnReason() != CreatureSpawnEvent.SpawnReason.NATURAL) {
        return;
    }
    if (!plugin.getWorldManager().isSkyNether(e.getLocation().getWorld())) {
        return;
    }
    if (e.getLocation().getBlockY() > plugin.getWorldManager().getNetherWorld().getMaxHeight()) {
        // Block spawning above nether...
        e.setCancelled(true);
        return;
    }
    if (e.getEntity() instanceof PigZombie) {
        Block block = e.getLocation().getBlock().getRelative(BlockFace.DOWN);
        if (isNetherFortressWalkway(block)) {
            e.setCancelled(true);
            double p = RND.nextDouble();
            if (p <= chanceWither && block.getRelative(BlockFace.UP, 3).getType() == Material.AIR) {
                WitherSkeleton mob = (WitherSkeleton) e.getLocation().getWorld().spawnEntity(
                    e.getLocation(), EntityType.WITHER_SKELETON);
                mob.getEquipment().setItemInMainHand(new ItemStack(Material.STONE_SWORD, 1));
            } else if (p <= chanceWither+chanceBlaze) {
                e.getLocation().getWorld().spawnEntity(e.getLocation(), EntityType.BLAZE);
            } else if (p <= chanceWither+chanceBlaze+chanceSkeleton) {
                e.getLocation().getWorld().spawnEntity(e.getLocation(), EntityType.SKELETON);
            } else {
                e.setCancelled(false); // Spawn PigZombie
            }
        }
    }
}
 
Example #3
Source File: SwordOfBeheading.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
@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);
        }
    };
}