本文整理汇总了Java中org.bukkit.World.spawn方法的典型用法代码示例。如果您正苦于以下问题:Java World.spawn方法的具体用法?Java World.spawn怎么用?Java World.spawn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.World
的用法示例。
在下文中一共展示了World.spawn方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shoot
import org.bukkit.World; //导入方法依赖的package包/类
/**
* A basic shoot method, it _can_ be overridden but take care.
* Handles passing the bullet to its BulletType for configuration, sets shooter, velocity, etc.
*
* @param begin The location to shoot from
* @param bulletType the Bullet type of this bullet
* @param shooter the entity shooting
* @param velocity the velocity to use as base for this shooting, if any
* @param overrideVelocity if true, use the passed velocity and override anything set up by the bullet type.
* @return the new Projectile that has been unleashed.
*/
public Projectile shoot(Location begin, Bullet bulletType, ProjectileSource shooter, Vector velocity, boolean overrideVelocity) {
World world = begin.getWorld();
begin = begin.clone();
begin.setDirection(velocity);
Projectile newBullet = world.spawn(begin, bulletType.getProjectileType() );
newBullet.setCustomName(this.bulletTag);
newBullet.setBounce(false);
newBullet.setGravity(true);
newBullet.setShooter(shooter);
bulletType.configureBullet(newBullet, world, shooter, velocity);
if (overrideVelocity) {
newBullet.setVelocity(velocity);
}
return newBullet;
}
示例2: launchFireworkDisplay
import org.bukkit.World; //导入方法依赖的package包/类
public void launchFireworkDisplay(final World w, final Location loc) {
Firework fw = (Firework) w.spawn(loc.clone().add(new Vector(getRandomNum(5, -5), 1, getRandomNum(5, -5))), Firework.class);
FireworkMeta meta = fw.getFireworkMeta();
FireworkEffect effect = SkyWarsReloaded.getNMS().getFireworkEffect(getRandomColor(),getRandomColor(), getRandomColor(), getRandomColor(), getRandomColor(), getRandomType());
meta.addEffect(effect);
meta.setPower(getRandomNum(4, 1));
fw.setFireworkMeta(meta);
fireworksCount++;
if (fireworksCount < ((SkyWarsReloaded.getCfg().getTimeAfterGame() - 5)*4)) {
SkyWarsReloaded.get().getServer().getScheduler().scheduleSyncDelayedTask(SkyWarsReloaded.get(), new Runnable() {
public void run() {
launchFireworkDisplay(w, loc);
}
}, 5);
}
}
示例3: handleInstantActivation
import org.bukkit.World; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void handleInstantActivation(BlockPlaceEvent event) {
if(this.properties.instantIgnite && event.getBlock().getType() == Material.TNT) {
World world = event.getBlock().getWorld();
TNTPrimed tnt = world.spawn(BlockUtils.base(event.getBlock()), TNTPrimed.class);
if(this.properties.fuse != null) {
tnt.setFuseTicks(this.getFuseTicks());
}
if(this.properties.power != null) {
tnt.setYield(this.properties.power); // Note: not related to EntityExplodeEvent.yield
}
if(callPrimeEvent(tnt, event.getPlayer(), true)) {
// Only cancel the block placement if the prime event is NOT cancelled.
// If priming is cancelled, the block is allowed to stay (unless some
// other handler has already cancelled the place event).
event.setCancelled(true);
world.playSound(tnt.getLocation(), Sound.ENTITY_TNT_PRIMED, 1, 1);
ItemStack inHand = event.getItemInHand();
if(inHand.getAmount() == 1) {
inHand = null;
} else {
inHand.setAmount(inHand.getAmount() - 1);
}
event.getPlayer().getInventory().setItem(event.getHand(), inHand);
}
}
}
示例4: changeBowProjectile
import org.bukkit.World; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void changeBowProjectile(EntityShootBowEvent event) {
Plugin plugin = this.getMatch().getPlugin();
Entity newProjectile;
if(this.projectile == Arrow.class && event.getProjectile() instanceof Arrow) {
// Don't change the projectile if it's an Arrow and the custom entity type is also Arrow
newProjectile = event.getProjectile();
} else {
// Replace the projectile
World world = event.getEntity().getWorld();
Projectile oldEntity = (Projectile) event.getProjectile();
if(Projectile.class.isAssignableFrom(projectile)) {
// Ender Pearls need to be soawned this way, otherwise they will hit the shooter sometimes
newProjectile = event.getEntity().launchProjectile(projectile.asSubclass(Projectile.class), oldEntity.getVelocity());
} else {
newProjectile = world.spawn(oldEntity.getLocation(), projectile);
newProjectile.setVelocity(oldEntity.getVelocity());
}
event.setProjectile(newProjectile);
// Copy some things from the old projectile
newProjectile.setFallDistance(oldEntity.getFallDistance());
newProjectile.setFireTicks(oldEntity.getFireTicks());
if(newProjectile instanceof Projectile) {
((Projectile) newProjectile).setShooter(oldEntity.getShooter());
((Projectile) newProjectile).setBounce(oldEntity.doesBounce());
}
// Save some special properties of Arrows
if(oldEntity instanceof Arrow) {
Arrow arrow = (Arrow) oldEntity;
newProjectile.setMetadata("critical", new FixedMetadataValue(plugin, arrow.isCritical()));
newProjectile.setMetadata("knockback", new FixedMetadataValue(plugin, arrow.getKnockbackStrength()));
newProjectile.setMetadata("damage", new FixedMetadataValue(plugin, arrow.getDamage()));
}
}
// Tag the projectile as custom
newProjectile.setMetadata("customProjectile", new FixedMetadataValue(plugin, true));
getMatch().callEvent(new EntityLaunchEvent(newProjectile, event.getEntity()));
}