當前位置: 首頁>>代碼示例>>Java>>正文


Java World.createExplosion方法代碼示例

本文整理匯總了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));
}
 
開發者ID:twizmwazin,項目名稱:OpenUHC,代碼行數:24,代碼來源:Overcook.java

示例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;
}
 
開發者ID:ProgrammerDan,項目名稱:AddGun,代碼行數:40,代碼來源:StandardGun.java

示例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();
	}
}
 
開發者ID:2008Choco,項目名稱:DragonEggDrop,代碼行數:71,代碼來源:RespawnRunnable.java


注:本文中的org.bukkit.World.createExplosion方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。