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


Java FallingBlock.setVelocity方法代碼示例

本文整理匯總了Java中org.bukkit.entity.FallingBlock.setVelocity方法的典型用法代碼示例。如果您正苦於以下問題:Java FallingBlock.setVelocity方法的具體用法?Java FallingBlock.setVelocity怎麽用?Java FallingBlock.setVelocity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.entity.FallingBlock的用法示例。


在下文中一共展示了FallingBlock.setVelocity方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: fragBallExplode

import org.bukkit.entity.FallingBlock; //導入方法依賴的package包/類
@EventHandler
public void fragBallExplode(EntityExplodeEvent e) {
    e.setCancelled(true);

    for(Block block : e.blockList()) {
        if(block.getRelative(BlockFace.UP).getType() == Material.AIR && block.getType().isSolid()) {
            FallingBlock fallingBlock = block.getWorld().spawnFallingBlock(block.getLocation().add(0, 1, 0), block.getType(), block.getData());
            double x = (block.getLocation().getX() - e.getLocation().getX()) / 3,
                    y = 1,
                    z = (block.getLocation().getZ() - e.getLocation().getZ()) / 3;
            fallingBlock.setVelocity(new Vector(x, y, z).normalize());
            fallingBlock.setMetadata("explode", new FixedMetadataValue(plugin, false));
            fallingBlock.setDropItem(false);
            e.setYield(0F);
        }
    }
}
 
開發者ID:ModernDayPlayer,項目名稱:SurvivalGamesX,代碼行數:18,代碼來源:BlockListener.java

示例2: effect

import org.bukkit.entity.FallingBlock; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
   @Override
public void effect(Event e, ItemStack item, final int level) {
	if(e instanceof EntityDamageByEntityEvent) {
	EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) e;
	Entity target = event.getEntity();

	World world = target.getWorld();
	world.playEffect(target.getLocation(), Effect.POTION_BREAK, 10);
	double boundaries = 0.1*level;
	for(double x = boundaries; x >= -boundaries; x-=0.1)
		for(double z = boundaries; z >= -boundaries; z-=0.1) {
			FallingBlock b = world.spawnFallingBlock(target.getLocation(), Material.FIRE.getId(), (byte) 0x0);
			b.setVelocity(new Vector(x, 0.1, z));
			b.setDropItem(false);
		}
	}
}
 
開發者ID:Taiterio,項目名稱:ce,代碼行數:19,代碼來源:Molotov.java

示例3: onEntityExplode

import org.bukkit.entity.FallingBlock; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled=true)
public void onEntityExplode(EntityExplodeEvent event) {
	if (event.getEntity() instanceof TNTPrimed &&
			bombSites.containsKey((TNTPrimed) event.getEntity())) {
		for (Block b : event.blockList()) {
			if (Math.random() < 0.4) {
				FallingBlock block = event.getEntity().getWorld().spawnFallingBlock(b.getLocation().add(0, 1, 0), b.getType(), b.getData());
				Location bLoc = b.getLocation();
				Location tLoc = event.getEntity().getLocation();
				double power = 0.15;
				double x = (bLoc.getX() - tLoc.getX()) * power + Math.random() - 0.5;
				double z = (bLoc.getZ() - tLoc.getZ()) * power + Math.random() - 0.5;
				double y = 0.8;
				block.setVelocity(new Vector(x, y, z));
				block.setDropItem(false);
			}
			b.setType(Material.AIR);
		}
	}
}
 
開發者ID:EvilKanoa,項目名稱:RodsTwo,代碼行數:21,代碼來源:Explosion.java

示例4: bounceBlock

import org.bukkit.entity.FallingBlock; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
public void bounceBlock(BlockState b) {
	if(b == null) return;

	if(fallingBlocks.size() > 1500) {
		return;
	}
	
	for(Material mat : allowedMaterials()) {
		if(b.getType() == mat) {
			FallingBlock fb = b.getWorld().spawnFallingBlock(b.getLocation(), b.getData().getItemType(), b.getData().getData());
			

			float x = (float) -1 + (float) (Math.random() * ((1 - -1) + 1));
			float y = 2;//(float) -5 + (float)(Math.random() * ((5 - -5) + 1));
			float z = (float) -0.3 + (float)(Math.random() * ((0.3 - -0.3) + 1));

			fb.setDropItem(false);
			fb.setVelocity(new Vector(x, y, z));
			fallingBlocks.add(fb);
			fb.setMetadata("xe:explosion", new FixedMetadataValue(pl, ""));
		}
	}
}
 
開發者ID:xEssentials,項目名稱:xEssentials-deprecated-bukkit,代碼行數:25,代碼來源:ExplosionRegenEvent.java

示例5: onExplode

import org.bukkit.entity.FallingBlock; //導入方法依賴的package包/類
@EventHandler
public void onExplode(EntityExplodeEvent e) {
	for (Block b : e.blockList()) {
		FallingBlock fb = b.getWorld().spawnFallingBlock(b.getLocation(), b.getType(), b.getData());
		b.setType(Material.AIR);
		float x = (float) 0.1 + (float) (Math.random() * 0.4);
		double y = 0.5;// (float) -5 + (float)(Math.random() * ((5 - -5) + 1));
		float z = (float) 0.1 + (float) (Math.random() * 0.4);
		fb.setVelocity(new Vector(x, y, z));
	}
}
 
開發者ID:xdev-pl,項目名稱:LeagueOfLegends,代碼行數:12,代碼來源:EntityExplodeList.java

示例6: onExplode

import org.bukkit.entity.FallingBlock; //導入方法依賴的package包/類
@EventHandler
@SuppressWarnings("deprecation")
public void onExplode(EntityExplodeEvent event) {
    for (final Block block : event.blockList()) {
        if(!ArenaUtils.isProtected(block.getLocation())){
            return;
        }
        Random r = new Random();
        FallingBlock fb = block.getWorld().spawnFallingBlock(block.getLocation(), block.getType(), block.getData());
        fb.setVelocity(new Vector(0, r.nextInt(3), 0));
        fb.setDropItem(false);
    }
}
 
開發者ID:mrkirby153,項目名稱:The-Plague,代碼行數:14,代碼來源:ArenaListener.java

示例7: spawnDragon

import org.bukkit.entity.FallingBlock; //導入方法依賴的package包/類
public void spawnDragon() {
	trappedEgg = false;
	eggLocation.getBlock().setType(Material.AIR);
	@SuppressWarnings("deprecation")
	final FallingBlock fallingEgg = eggLocation.getWorld().spawnFallingBlock(eggLocation, Material.DRAGON_EGG, (byte) 0);
	fallingEgg.setVelocity(new Vector(0, 2, 0));

	Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
		@Override
		public void run() {
			fallingEgg.getWorld().spawnEntity(fallingEgg.getLocation(), EntityType.ENDER_DRAGON);
			fallingEgg.remove();
		}
	}, 35);
}
 
開發者ID:kyriog,項目名稱:rftd,代碼行數:16,代碼來源:RftdController.java

示例8: effect

import org.bukkit.entity.FallingBlock; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
   @Override
public void effect(Event e, ItemStack item, final int level) {
	if(e instanceof EntityDamageByEntityEvent) {
	EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) e;
	Entity target = event.getEntity();

	final World world = target.getWorld();
	Vector vec = new Vector(0, -5, 0);
	Location spawnLocation = new Location(world, target.getLocation().getX(), 255, target.getLocation().getZ());
	final FallingBlock b = world.spawnFallingBlock(spawnLocation, 46, (byte) 0x0);
	b.setVelocity(vec);

	new BukkitRunnable() {

		Location	l	= b.getLocation();

		@Override
		public void run() {
			l = b.getLocation();
			if(b.isDead()) {
				l.getBlock().setType(Material.AIR);
				for(int i = 0; i <= TNTAmount + level; i++) {
					TNTPrimed tnt = world.spawn(l, TNTPrimed.class);
					tnt.setFuseTicks(0);
					if(!Main.createExplosions)
						tnt.setMetadata("ce.explosive", new FixedMetadataValue(getPlugin(), null));
				}
				this.cancel();
			}
			
			EffectManager.playSound(l, "ENTITY_ENDERDRAGON_GROWL", Volume, 2f);
		}
	}.runTaskTimer(getPlugin(), 0l, 5l);
	}
}
 
開發者ID:Taiterio,項目名稱:ce,代碼行數:37,代碼來源:Bombardment.java

示例9: run

import org.bukkit.entity.FallingBlock; //導入方法依賴的package包/類
@Override
public void run()
{
    int distance = 5;
    Block block = null;
    while (distance > 0) {
        block = player.getDelegate().getTargetBlock((Set<Material>) null, distance);
        if (block.getType().equals(Material.AIR)) {
            break;
        }

        distance--;
    }

    if (currentBlock != null) {
        currentBlock.remove();
        currentBlock = null;
    }

    FallingBlock gravityBlock =
        player.getWorld().spawnFallingBlock(block.getLocation(),
                                            material,
                                            data);
    gravityBlock.setDropItem(false);
    gravityBlock.setFallDistance(0f);
    gravityBlock.setVelocity(new Vector(0, 0.1, 0));

    dstLocation = gravityBlock.getLocation();
    currentBlock = gravityBlock;
}
 
開發者ID:EmilHernvall,項目名稱:tregmine,代碼行數:31,代碼來源:PortalListener.java

示例10: throwAnvil

import org.bukkit.entity.FallingBlock; //導入方法依賴的package包/類
private void throwAnvil(World world, Location playerLoc, Location hookLoc) {
    double d5 = playerLoc.getX() - hookLoc.getX();
    double d6 = playerLoc.getY() - hookLoc.getY();
    double d7 = playerLoc.getZ() - hookLoc.getZ();
    double d8 = (double) Math.sqrt(d5 * d5 + d6 * d6 + d7 * d7);
    double d9 = 0.03D;
    
    FallingBlock anvil = world.spawnFallingBlock(hookLoc, Material.ANVIL, (byte) 8);
    anvil.setVelocity(new Vector(d5 * d9, d6 * d9 + (double) Math.sqrt(d8) * 0.32D, d7 * d9));
    anvil.setDropItem(true);

    enableFallingBlockDamage(anvil);
}
 
開發者ID:YaLTeR,項目名稱:UnexpectedFishing,代碼行數:14,代碼來源:UnexpectedFishingListener.java

示例11: doStep

import org.bukkit.entity.FallingBlock; //導入方法依賴的package包/類
@Override
public void doStep(final Altar altar) {
    final Location locBlock = altar.getCenterLocation().toBukkitLocation().add(this.block.getRelativeLocation());
    locBlock.getBlock().setType(Material.AIR);
    locBlock.getWorld().playEffect(locBlock, Effect.MOBSPAWNER_FLAMES, (byte)4);
    locBlock.getWorld().playSound(locBlock, Sound.IRONGOLEM_THROW, 1.0f, 1.0f);

    final Location locSpawn = locBlock.clone().add(0, this.fromHeight, 0);
    if (locSpawn.getY() >= locSpawn.getWorld().getMaxHeight()) {
        locSpawn.setY(locSpawn.getWorld().getMaxHeight() - 1);
    }
    final FallingBlock fb = locSpawn.getWorld().spawnFallingBlock(locSpawn, this.block.getBlockMaterial(), this.block.getBlockData());
    fb.setDropItem(false);
    fb.setVelocity(this.initialVelocity);
}
 
開發者ID:Ribesg,項目名稱:NPlugins,代碼行數:16,代碼來源:FallingBlockStep.java

示例12: doBlockDrops

import org.bukkit.entity.FallingBlock; //導入方法依賴的package包/類
/**
 * This is not an event handler. It is called explicitly by BlockTransformListener
 * after all event handlers have been called.
 */
@SuppressWarnings("deprecation")
public void doBlockDrops(final BlockTransformEvent event) {
    if(!causesDrops(event.getCause())) {
        return;
    }

    final BlockDrops drops = event.getDrops();
    if(drops != null) {
        event.setCancelled(true);
        final BlockState oldState = event.getOldState();
        final BlockState newState = event.getNewState();
        final Block block = event.getOldState().getBlock();
        final int newTypeId = newState.getTypeId();
        final byte newData = newState.getRawData();

        block.setTypeIdAndData(newTypeId, newData, true);

        boolean explosion = false;
        MatchPlayer player = ParticipantBlockTransformEvent.getParticipant(event);

        if(event.getCause() instanceof EntityExplodeEvent) {
            EntityExplodeEvent explodeEvent = (EntityExplodeEvent) event.getCause();
            explosion = true;

            if(drops.fallChance != null &&
               oldState.getType().isBlock() &&
               oldState.getType() != Material.AIR &&
               this.getMatch().getRandom().nextFloat() < drops.fallChance) {

                FallingBlock fallingBlock = event.getOldState().spawnFallingBlock();
                fallingBlock.setDropItem(false);

                if(drops.landChance != null && this.getMatch().getRandom().nextFloat() >= drops.landChance) {
                    this.fallingBlocksThatWillNotLand.add(fallingBlock);
                }

                Vector v = fallingBlock.getLocation().subtract(explodeEvent.getLocation()).toVector();
                double distance = v.length();
                v.normalize().multiply(BASE_FALL_SPEED * drops.fallSpeed / Math.max(1d, distance));

                // A very simple deflection model. Check for a solid
                // neighbor block and "bounce" the velocity off of it.
                Block west = block.getRelative(BlockFace.WEST);
                Block east = block.getRelative(BlockFace.EAST);
                Block down = block.getRelative(BlockFace.DOWN);
                Block up = block.getRelative(BlockFace.UP);
                Block north = block.getRelative(BlockFace.NORTH);
                Block south = block.getRelative(BlockFace.SOUTH);

                if((v.getX() < 0 && west != null && Materials.isColliding(west.getType())) ||
                    v.getX() > 0 && east != null && Materials.isColliding(east.getType())) {
                    v.setX(-v.getX());
                }

                if((v.getY() < 0 && down != null && Materials.isColliding(down.getType())) ||
                    v.getY() > 0 && up != null && Materials.isColliding(up.getType())) {
                    v.setY(-v.getY());
                }

                if((v.getZ() < 0 && north != null && Materials.isColliding(north.getType())) ||
                    v.getZ() > 0 && south != null && Materials.isColliding(south.getType())) {
                    v.setZ(-v.getZ());
                }

                fallingBlock.setVelocity(v);
            }
        }

        dropObjects(drops, player, newState.getLocation(), 1d, explosion);

    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:77,代碼來源:BlockDropsMatchModule.java

示例13: effect

import org.bukkit.entity.FallingBlock; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
   @Override
public boolean effect(Event event, final Player player) {
	PlayerInteractEvent e = (PlayerInteractEvent) event;
		e.setCancelled(true);

		if(player.getItemInHand().getDurability() >= 64) {
			if(IsReloadable) {
			addLock(player);
			player.getWorld().playEffect(player.getLocation(), Effect.CLICK1, 2);
			player.sendMessage(ChatColor.RED + "Reloading...");
			new BukkitRunnable() {
				@Override
				public void run() {
					if(player.getItemInHand().getDurability() == 0) {
						removeLock(player);
						player.getWorld().playEffect(player.getLocation(), Effect.CLICK2, 2);
						this.cancel();
					} else {
						player.getItemInHand().setDurability((short) (player.getItemInHand().getDurability() - 1));
					}
				}
			}.runTaskTimer(main, 0l, 2l);
		} else { 
			player.getItemInHand().setType(Material.AIR);
		}
		} else {
			final List<Location> list = getLinePlayer(player, FireBlocksPerBurst);
			for(final Location l: list) {
				if(l.getBlock().getType().equals(Material.AIR))
					l.getBlock().setType(Material.FIRE);
				l.getWorld().playEffect(l, Effect.SMOKE, 20);
				final FallingBlock fire = l.getWorld().spawnFallingBlock(l, Material.FIRE.getId(), (byte) 0);
				fire.setDropItem(false);
				fire.setVelocity(player.getLocation().getDirection());
				new BukkitRunnable() {
					@Override
					public void run() {
					if(fire.isDead()) {
						list.add(fire.getLocation());
						this.cancel();
					} else {
						if(!Tools.checkWorldGuard(fire.getLocation(), player, "BUILD", true) || fire.getLocation().getBlock().getType().equals(Material.WATER) || fire.getLocation().getBlock().getType().equals(Material.STATIONARY_WATER)) {
							fire.getWorld().playEffect(fire.getLocation(), Effect.EXTINGUISH, 60);
							fire.remove();
							this.cancel();
						}
						for(Entity ent:fire.getNearbyEntities(0, 0, 0)) {
							if(ent != player) {
								ent.setFireTicks(BurnDuration);
							}
						}
					}
					}
				}.runTaskTimer(main, 0l, 1l);
			}
			new BukkitRunnable() {
				@Override
				public void run() {
					for(Location ls:list) {
						if(ls.getBlock().getType().equals(Material.FIRE)) {
						ls.getWorld().playEffect(ls, Effect.EXTINGUISH, 60);
						ls.getBlock().setType(Material.AIR);
						}
					}
				}
			}.runTaskLater(main, 200l);
			player.getWorld().playEffect(player.getLocation(), Effect.BLAZE_SHOOT, 30);
			if(!player.getGameMode().equals(GameMode.CREATIVE)) {
			player.getItemInHand().setDurability((short) (player.getItemInHand().getDurability() + 1));
			}
		}
	
	return true;
}
 
開發者ID:Taiterio,項目名稱:ce,代碼行數:76,代碼來源:Flamethrower.java

示例14: effect

import org.bukkit.entity.FallingBlock; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
@Override
public void effect(Event e, ItemStack item, final int level) {

    final EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) e;
    Player damager = (Player) event.getDamager();

    new BukkitRunnable() {
        @Override
        public void run() {
            event.getEntity().setVelocity(new Vector(0, 1 + (level / 4), 0));
        }
    }.runTaskLater(getPlugin(), 1l);

    Location loc = damager.getLocation();
    loc.setY(damager.getLocation().getY() - 1);
    List<Location> list = Tools.getCone(loc);
    this.generateCooldown(damager, cooldown);
    damager.getWorld().playEffect(damager.getLocation(), Effect.ZOMBIE_DESTROY_DOOR, 10);
    for (final Location l : list) {
        final org.bukkit.block.Block block = l.getBlock();
        Material blockMat = block.getType();
        if (!ForbiddenMaterials.contains(blockMat) && checkSurrounding(block)) {

            if (!Tools.checkWorldGuard(l, damager, "PVP", false))
                return;
            final Material mat = blockMat;
            final byte matData = block.getData();
            final FallingBlock b = l.getWorld().spawnFallingBlock(l, mat, block.getData());
            b.setDropItem(false);
            b.setVelocity(new Vector(0, (0.5 + 0.1 * (list.indexOf(l))) + (level / 4), 0));
            block.setType(Material.AIR);
            new BukkitRunnable() {
                Location finLoc = l;

                @Override
                public void run() {
                    if (!b.isDead()) {
                        finLoc = b.getLocation();
                    } else {
                        //if(finLoc.getBlock().getLocation() != l) 
                        finLoc.getBlock().setType(Material.AIR);
                        block.setType(mat);
                        block.setData(matData);
                        this.cancel();
                    }
                }
            }.runTaskTimer(main, 0l, 5l);
        }
    }

}
 
開發者ID:Taiterio,項目名稱:ce,代碼行數:53,代碼來源:Shockwave.java

示例15: onBlockBreak

import org.bukkit.entity.FallingBlock; //導入方法依賴的package包/類
@Override
public void onBlockBreak(BlockBreakEvent event, PlayerDetails details) {
	Block root = event.getBlock();
	if (isLog(root.getType())) {
		// Initialize some variables:
		World world = event.getPlayer().getWorld();
		Location location = root.getLocation();
		Random random = new Random();
		Vector vel = event.getPlayer().getLocation().toVector().subtract(location.toVector()).normalize().setY(0).multiply(0.2);
		// Find the blocks
		Set<Block> blocks = getTreeBlocks(root);
		if (blocks.size() > 0) {
			world.playSound(location, Sound.ENTITY_ZOMBIE_BREAK_DOOR_WOOD, 0.5f, 1);
		}
		double durability = blocks.size()*0.25;
		// Bring 'em down.
		for (Block block : blocks) {
			Material mat = block.getType();
			if (mat == Material.LOG && random.nextFloat() < 0.1f) {
				world.playSound(block.getLocation(), Sound.ENTITY_ZOMBIE_BREAK_DOOR_WOOD, 0.6f, 1);
				block.breakNaturally();
				durability += 1;
			} else if (mat == Material.LEAVES && random.nextFloat() < 0.4f) {
				world.playSound(block.getLocation(), Sound.BLOCK_GRASS_BREAK, 0.5f, 1);
				block.breakNaturally();
				durability += 1;
			} else {
				FallingBlock fallingBlock = world.spawnFallingBlock(block.getLocation(), block.getType(), block.getData());
				fallingBlock.setVelocity(vel.multiply(random.nextFloat()*0.2 + 0.9));
				if (block.getType() == Material.LEAVES) {
					fallingBlock.setDropItem(false);
				}
				block.setType(Material.AIR);
			}
		}
		// Apply durability.
		if (event.getPlayer().getGameMode() != GameMode.CREATIVE) {
			ItemStack item = details.getItem();
			item.setDurability((short) (item.getDurability() + durability));
		}
	}
}
 
開發者ID:goncalomb,項目名稱:NBTEditor,代碼行數:43,代碼來源:GravitationalAxe.java


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