本文整理匯總了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();
}
}