本文整理汇总了Java中org.bukkit.World.createExplosion方法的典型用法代码示例。如果您正苦于以下问题:Java World.createExplosion方法的具体用法?Java World.createExplosion怎么用?Java World.createExplosion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.World
的用法示例。
在下文中一共展示了World.createExplosion方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onFurnaceSmelt
import org.bukkit.World; //导入方法依赖的package包/类
/**
* Handles the action of smelting all items at once, exploding the furnace, and dropping the smelted items on the
* ground.
*
* @param event The event
*/
@EventHandler(ignoreCancelled = true)
public void onFurnaceSmelt(FurnaceSmeltEvent event) {
ItemStack resultItem = event.getResult();
final Material result = resultItem.getType();
//TODO: Verify that the "smelting amount" contains any extra ingredients
final int amount = ((Furnace) event.getBlock().getState()).getInventory().getSmelting().getAmount();
event.getSource().setType(Material.AIR);
resultItem.setType(Material.AIR);
Block block = event.getBlock();
block.setType(Material.AIR);
Location location = block.getLocation().add(0.5, 0.5, 0.5);
World world = location.getWorld();
world.createExplosion(location, 7);
world.dropItem(location, new ItemStack(result, amount));
}
示例2: blowout
import org.bukkit.World; //导入方法依赖的package包/类
/**
* Gets chance that the misfiring gun also explodes! Yikes.
*
* @param entity the entity shooting the gun
* @param bulletType the type of bullet
* @param item the gunItem, could be modified by this.
* @param gunData the gunData
* @param hand the hand holding the gun.
* @return true if blowout, false otherwise
*/
public boolean blowout(LivingEntity entity, Bullet bulletType, ItemStack gun, Map<String, Object> gunData,
EquipmentSlot hand) {
if (entity == null || !enabled)
return true;
double random = Math.random();
if (random < this.misfireBlowoutChance) {
Location explosion = entity.getLocation().clone().add(0.0d, 1.3d, 0.0d);
World world = explosion.getWorld();
random = Math.random();
world.createExplosion(explosion.getX(), explosion.getY(), explosion.getZ(), this.baseBlowoutStrength + bulletType.getExplosionLevel(), (random < bulletType.getFireChance()) ? true : false, true);
gunData.clear();
gunData.put("health", Integer.valueOf(0));
gun = updateGunLore(updateGunData(gun, gunData));
switch(hand) {
case HAND:
entity.getEquipment().setItemInMainHand(gun);
break;
case OFF_HAND:
entity.getEquipment().setItemInOffHand(gun);
break;
default:
}
return true;
}
return false;
}
示例3: run
import org.bukkit.World; //导入方法依赖的package包/类
@Override
public void run() {
if (this.secondsUntilRespawn > 0) {
if (announceRespawn) {
if (this.currentMessage >= announceMessages.size()) this.currentMessage = 0;
// Show actionbar messages
String message = announceMessages.get(currentMessage++)
.replace("%time%", String.valueOf(secondsUntilRespawn))
.replace("%formatted-time%", this.getFormattedTime(secondsUntilRespawn));
plugin.getNMSAbstract().broadcastActionBar(message, worldWrapper.getWorld());
}
this.secondsUntilRespawn--;
return;
}
// Only respawn if a Player is in the World
World world = this.worldWrapper.getWorld();
if (world.getPlayers().size() <= 0) return;
// Start respawn process
PortalCrystal crystalPos = PortalCrystal.values()[currentCrystal++];
Location crystalLocation = crystalPos.getRelativeToPortal(world);
World crystalWorld = crystalLocation.getWorld();
Chunk crystalChunk = crystalWorld.getChunkAt(crystalLocation);
if (!crystalChunk.isLoaded())
crystalChunk.load();
// Remove any existing crystal
EnderCrystal existingCrystal = crystalPos.get(world);
if (existingCrystal != null) existingCrystal.remove();
crystalPos.spawn(world);
crystalWorld.createExplosion(crystalLocation.getX(), crystalLocation.getY(), crystalLocation.getZ(), 0F, false, false);
crystalWorld.spawnParticle(Particle.EXPLOSION_HUGE, crystalLocation, 0);
// All crystals respawned
if (currentCrystal >= 4) {
// If dragon already exists, cancel the respawn process
if (crystalWorld.getEntitiesByClass(EnderDragon.class).size() >= 1) {
plugin.getLogger().warning("An EnderDragon is already present in world " + crystalWorld.getName() + ". Dragon respawn cancelled");
this.nmsAbstract.broadcastActionBar(ChatColor.RED + "Dragon respawn abandonned! Dragon already exists! Slay it!", crystalWorld);
// Destroy all crystals
for (PortalCrystal portalCrystal : PortalCrystal.values()) {
Location location = portalCrystal.getRelativeToPortal(world);
portalCrystal.get(world).remove();
crystalWorld.getPlayers().forEach(p -> p.playSound(location, Sound.BLOCK_FIRE_EXTINGUISH, 1000, 1));
crystalWorld.createExplosion(location.getX(), location.getY(), location.getZ(), 0F, false, false);
}
this.cancel();
return;
}
this.dragonBattle.respawnEnderDragon();
RespawnSafeguardRunnable.newTimeout(plugin, worldWrapper.getWorld(), dragonBattle);
BattleStateChangeEvent bscEventRespawning = new BattleStateChangeEvent(dragonBattle, dragon, BattleState.CRYSTALS_SPAWNING, BattleState.DRAGON_RESPAWNING);
Bukkit.getPluginManager().callEvent(bscEventRespawning);
this.worldWrapper.stopRespawn();
this.cancel();
}
}