private void spawnSnowman(Location location) { if (SNOWMAN_PATTERN.matches(location, true, 0, 0)) { location.getWorld() .spawnEntity(location.clone().subtract(-0.5, 2, -0.5), EntityType.SNOWMAN); } } }
@Override public void populate(World world, Random random, Chunk chunk) { obsidianPillarDecorator.populate(world, random, chunk); // spawn the enderdragon if (chunk.getX() == 0 && chunk.getZ() == 0) { final Location loc = new Location(world, (chunk.getX() << 4) + 8, 128, (chunk.getZ() << 4) + 8, random.nextFloat() * 360, 0); world.spawnEntity(loc, EntityType.ENDER_DRAGON); } } }
private boolean spawnIronGolem(Location location) { if (IRONGOLEM_PATTERN.matches(location, true, 1, 0)) { Entity entity = location.getWorld() .spawnEntity(location.clone().subtract(-0.5, 2, -0.5), EntityType.IRON_GOLEM); ((GlowIronGolem) entity).setPlayerCreated(true); return true; } return false; }
/** * Spawns an entity if the given position is within this structure's bounding box. * * @param pos a point relative to this structure's root point * @param entityType the type of entity to spawn * @return true if the entity was spawned; false if {@code pos} is outside the builder's * bounding box or {@link World#spawnEntity(Location, EntityType)} fails */ public boolean spawnMob(Vector pos, EntityType entityType) { Vector vec = translate(pos); return boundingBox.isVectorInside(vec) && world .spawnEntity(new Location(world, vec.getBlockX(), vec.getBlockY(), vec.getBlockZ()), entityType) != null; }
location.subtract(0, 1, 0); world.spawnEntity(location, type);
world.spawnEntity(loc, EntityType.ENDER_CRYSTAL); Block block = world.getBlockAt(sourceX, sourceY + height, sourceZ); block.setType(Material.BEDROCK);
for (int i = 0; i < amount; i++) { GlowEntity entity = (GlowEntity) location.getWorld().spawnEntity( location.clone().add(0, 0.3, 0), hatchingType); if (entity instanceof GlowAgeable) {
/** * Convert a TNT block into a primed TNT entity with the player who ignited the TNT. * * @param tntBlock The block to ignite. * @param ignitedByExplosion True if another explosion caused this ignition. * @param player The player who ignited the TNT. */ public static void igniteBlock( Block tntBlock, boolean ignitedByExplosion, GlowPlayer player) { tntBlock.setType(Material.AIR); World world = tntBlock.getWorld(); GlowTntPrimed tnt = (GlowTntPrimed) world .spawnEntity(tntBlock.getLocation().add(0.5, 0, 0.5), EntityType.PRIMED_TNT); tnt.setSource(player); tnt.setIgnitedByExplosion(ignitedByExplosion); world.playSound(tntBlock.getLocation(), Sound.ENTITY_TNT_PRIMED, 1, 1); }
if (EntityType.fromName(entityName) != null) { entity = (GlowEntity) location.getWorld() .spawnEntity(location, EntityType.fromName(entityName)); } else { Class<? extends GlowEntity> clazz = EntityRegistry.getCustomEntityDescriptor(entityName)
private void createEffectCloud() { AreaEffectCloud cloud = (AreaEffectCloud) location.getWorld().spawnEntity(location, EntityType.AREA_EFFECT_CLOUD); cloud.setRadius(3); cloud.setRadiusPerTick(-.005f); ItemMeta meta = getItem().getItemMeta(); if (meta instanceof PotionMeta) { PotionMeta potionMeta = (PotionMeta) meta; cloud.setColor(potionMeta.getColor()); cloud.setBasePotionData(potionMeta.getBasePotionData()); for (PotionEffect effect : getEffects()) { cloud.addCustomEffect(effect, true); } } remove(); } }
@Override public void run() { // A villager is born World world = Bukkit.getWorld("world"); world.spawnEntity(world.getSpawnLocation(), EntityType.VILLAGER); } },
@Override public MCEntity spawn(MCLocation l, MCEntityType entType) { return BukkitConvertor.BukkitGetCorrectEntity(w.spawnEntity( ((BukkitMCLocation) l).asLocation(), ((BukkitMCEntityType) entType).getConcrete())); }
private List<Entity> getJunkTravellers() { // spawn an entity Entity orb = junkLoc.getWorld().spawnEntity(junkLoc, EntityType.EXPERIENCE_ORB); List<Entity> ents = orb.getNearbyEntities(4.0, 4.0, 4.0); orb.remove(); return ents; }
@Override public MCEntity spawn(MCLocation l, MCEntityType.MCVanillaEntityType entityType) { return BukkitConvertor.BukkitGetCorrectEntity(w.spawnEntity( ((BukkitMCLocation) l).asLocation(), (EntityType) MCEntityType.valueOfVanillaType(entityType).getConcrete())); }
private List<Entity> getJunkTravellers() { // spawn an entity Entity orb = dd.getLocation().getWorld().spawnEntity(dd.getLocation(), EntityType.EXPERIENCE_ORB); List<Entity> ents = orb.getNearbyEntities(1.0, 1.0, 1.0); orb.remove(); return ents; }
@Override public void setType(MCEntityType type) { e.setCancelled(true); e.getLocation().getWorld().spawnEntity(e.getLocation(), EntityType.valueOf(type.name())); } }
public void spawnFireworks(Player player) { int power = Misc.getRandom().nextInt(3) + 1; Type fireworkType = Type.values()[Misc.getRandom().nextInt(Type.values().length)]; double varX = Misc.getRandom().nextGaussian() * 3; double varZ = Misc.getRandom().nextGaussian() * 3; Firework fireworks = (Firework) player.getWorld().spawnEntity(player.getLocation().add(varX, 0, varZ), EntityType.FIREWORK); FireworkMeta fireworkmeta = fireworks.getFireworkMeta(); FireworkEffect effect = FireworkEffect.builder().flicker(Misc.getRandom().nextBoolean()).withColor(colorChoose()).withFade(colorChoose()).with(fireworkType).trail(Misc.getRandom().nextBoolean()).build(); fireworkmeta.addEffect(effect); fireworkmeta.setPower(power); fireworks.setFireworkMeta(fireworkmeta); }
@Override public MCFirework launchFirework(MCLocation l, int strength, List<MCFireworkEffect> effects) { Firework firework = (Firework) w.spawnEntity(((BukkitMCLocation) l).asLocation(), EntityType.FIREWORK); FireworkMeta meta = firework.getFireworkMeta(); meta.setPower(strength); for(MCFireworkEffect effect : effects) { meta.addEffect((FireworkEffect) effect.getHandle()); } firework.setFireworkMeta(meta); return new BukkitMCFirework(firework); }
protected void detonate(Location location, Vector v) { final Firework fw = (Firework) location.getWorld().spawnEntity(location.add(v), EntityType.FIREWORK); location.subtract(v); FireworkMeta meta = fw.getFireworkMeta(); meta.setPower(0); for (int i = 0; i < intensity; i++) { meta.addEffect(firework); } fw.setFireworkMeta(meta); fw.detonate(); } }
public static void fireworkParticleShower(Player player, Color color) { Location location = player.getLocation(); location.setY(location.getY() + (player.isInsideVehicle() ? 1.0 : -1.0)); location.setPitch(-90); Firework firework = (Firework) player.getWorld().spawnEntity(location, EntityType.FIREWORK); firework.setMetadata(mcMMO.funfettiMetadataKey, new FixedMetadataValue(mcMMO.p, null)); FireworkMeta fireworkMeta = firework.getFireworkMeta(); FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(color).with((Config.getInstance().getLargeFireworks() ? Type.BALL_LARGE : Type.BALL)).trail(true).build(); fireworkMeta.addEffect(effect); fireworkMeta.addEffect(effect); fireworkMeta.setPower(0); firework.setFireworkMeta(fireworkMeta); }