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


Java Item.setVelocity方法代碼示例

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


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

示例1: grenadeEvent

import org.bukkit.entity.Item; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
@EventHandler
public void grenadeEvent(PlayerInteractEvent e){
	final Player p = e.getPlayer();
	if(e.getAction().equals(Action.RIGHT_CLICK_AIR) || e.getAction().equals(Action.RIGHT_CLICK_BLOCK)){
		if(p.getItemInHand().hasItemMeta()){
			if(p.getItemInHand().getItemMeta().getLore() == null) return;
			if(p.getItemInHand().getItemMeta().getLore().contains(ChatColor.GRAY + "Grenade I")){
				p.getItemInHand().setDurability((short) (p.getItemInHand().getDurability() - 4));
				final Item grenade = p.getWorld().dropItem(p.getEyeLocation(), new ItemStack(Material.CLAY_BALL));
				grenade.setVelocity(p.getEyeLocation().getDirection().normalize().multiply(0.8D));
				Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
					public void run(){
						p.getWorld().createExplosion(grenade.getLocation().getX(), grenade.getLocation().getY(), 
								grenade.getLocation().getZ(), 3, false, false);
						grenade.remove();
					}
				},30L);
			}
		}
	}
}
 
開發者ID:OverloadedCore,項目名稱:chaoticWeapons,代碼行數:23,代碼來源:Core.java

示例2: play

import org.bukkit.entity.Item; //導入方法依賴的package包/類
public void play(TOAUser u){
    if (!canUse(u)) return;
    if (isInCooldown(u, getName())) return;
    int lvl = u.getUserData().getLvl();

    for (int x = 0; x < r.nextInt(4) + 2; x++) {
        final Item d1 = u.getLoc().getWorld().dropItemNaturally(u.getLoc(), new ItemStack(Material.IRON_SWORD));

        d1.setVelocity(u.getPlayer().getVelocity().multiply(2));

        plugin.getServer().getScheduler().runTaskTimer(plugin, () -> {
            World w = d1.getLocation().getWorld();

            w.getNearbyEntities(d1.getLocation(), 1, 1, 1).stream()
                    .filter(en -> !en.getType().equals(EntityType.PLAYER)).forEach(en -> {
                if (en instanceof Monster) ((Monster) en).damage(40 + (lvl * 0.7));
                d1.remove();
            });
        }, 0, 20);
    }
    cool.setOnCooldown(getName());
}
 
開發者ID:cadox8,項目名稱:PA,代碼行數:23,代碼來源:Dagas.java

示例3: onInteract

import org.bukkit.entity.Item; //導入方法依賴的package包/類
@EventHandler
public void onInteract(PlayerInteractEvent e) {
	if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
		if (e.getClickedBlock().getType() == Material.CAULDRON) {
			if (e.getClickedBlock().getLocation().add(0, -1, 0).getBlock().getType() == Material.DIAMOND_BLOCK) {
				Item item = e.getPlayer().getWorld().dropItem(e.getClickedBlock().getLocation().add(0.5, 2, 0.5), e.getPlayer().getEquipment().getItemInMainHand());
				item.setMetadata("item-owner", new FixedMetadataValue(NationZ.plugin, e.getPlayer().getUniqueId().toString()));
				item.setVelocity(new Vector(0, 0, 0));
				item.setCustomName(item.getName());
				item.setCustomNameVisible(true);
				e.getPlayer().getEquipment().setItemInMainHand(null);
				e.setCancelled(true);
			}
		}
	}
}
 
開發者ID:crazyhorse961,項目名稱:NationZ,代碼行數:17,代碼來源:JobEnchanter.java

示例4: specialItemActionCheck

import org.bukkit.entity.Item; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST)
public void specialItemActionCheck(final PlayerInteractEvent event)
{
	if(event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)
	{
		Player player = event.getPlayer();
		AnniPlayer pl = AnniPlayer.getPlayer(player.getUniqueId());
		if(pl != null && pl.getKit().equals(this))
		{
			if(this.isHookItem(player.getItemInHand()))
			{
				if(!Delays.getInstance().hasActiveDelay(player, this.getInternalName()))
				{
					Delays.getInstance().addDelay(player, System.currentTimeMillis()+5000, this.getInternalName());//kits.addDelay(player.getName(), DelayType.SCORPIO, 10, TimeUnit.SECONDS);
					Item item = player.getWorld().dropItem(player.getEyeLocation(), new ItemStack(Material.NETHER_STAR,1));
					item.setPickupDelay(Integer.MAX_VALUE);
					item.setVelocity(player.getEyeLocation().getDirection().multiply(2));
					Bukkit.getScheduler().scheduleSyncDelayedTask(AnnihilationMain.getInstance(), new HookTracer(item,pl,90,this.getName()), 1);
				}
			}
		}
	}
}
 
開發者ID:MrLittleKitty,項目名稱:AnnihilationPro,代碼行數:24,代碼來源:Scorpio.java

示例5: autoEject

import org.bukkit.entity.Item; //導入方法依賴的package包/類
private boolean autoEject(ItemStack result) {
    Location loc = getRelativeLocation(getAutoEjectDirection());
    Block target = loc.getBlock();
    ItemStack item = result.clone();
    item.setAmount(1);
    if (!target.getType().isSolid() || target.getType() == Material.WALL_SIGN) {
        // no (solid) block there - just drop the item
        Item i = loc.getWorld().dropItem(loc.add(0.5, 0.5, 0.5), item);
        i.setVelocity(new Vector(0, 0, 0));
        return true;
    } else {
        BaseSTBBlock stb = LocationManager.getManager().get(loc);
        int nInserted = stb instanceof STBInventoryHolder ?
                ((STBInventoryHolder) stb).insertItems(item, getAutoEjectDirection().getOppositeFace(), false, getOwner()) :
                VanillaInventoryUtils.vanillaInsertion(target, item, 1, getAutoEjectDirection().getOppositeFace(), false, getOwner());
        return nInserted > 0;
    }
}
 
開發者ID:desht,項目名稱:sensibletoolbox,代碼行數:19,代碼來源:AbstractProcessingMachine.java

示例6: execute

import org.bukkit.entity.Item; //導入方法依賴的package包/類
@Override
public boolean execute(Location loc) {
    if (getItemRouter() != null && getItemRouter().getBufferItem() != null) {
        if (getFilter() != null && !getFilter().shouldPass(getItemRouter().getBufferItem())) {
            return false;
        }
        int toDrop = getItemRouter().getStackSize();
        ItemStack stack = getItemRouter().extractItems(BlockFace.SELF, null, toDrop, null);
        if (stack != null) {
            Location targetLoc = getTargetLocation(loc).add(0.5, 0.5, 0.5);
            Item item = targetLoc.getWorld().dropItem(targetLoc, stack);
            item.setVelocity(new Vector(0, 0, 0));
            Debugger.getInstance().debug(2, "dropper dropped " + stack + " from " + getItemRouter());
        }
        return true;
    }
    return false;
}
 
開發者ID:desht,項目名稱:sensibletoolbox,代碼行數:19,代碼來源:DropperModule.java

示例7: doOnLeftClick

import org.bukkit.entity.Item; //導入方法依賴的package包/類
@Override
public void doOnLeftClick(Racer racer, Action action)
{
    ItemStack stack = racer.getPlayer().getItemInHand();
    final ItemStack thro = racer.getPlayer().getItemInHand().clone();
    thro.setAmount(1);

    racer.getPlayer().getInventory().clear();
    if(stack.getAmount() - 1 > 0)
    {
        stack.setAmount(stack.getAmount() - 1);
    }

    racer.getPlayer().getInventory().setItem(0, stack);

    Item item = racer.getPlayer().getWorld().dropItem(racer.getPlayer().getLocation(), thro);
    item.setVelocity(racer.getPlayer().getEyeLocation().getDirection().multiply(plugin.getConfig().getDouble("Powerups.Lightning.ThrowAheadMultiplier")));
    item.setPickupDelay(0);
}
 
開發者ID:ColonelHedgehog,項目名稱:Equestrian-Dash,代碼行數:20,代碼來源:LightningPowerup.java

示例8: cast

import org.bukkit.entity.Item; //導入方法依賴的package包/類
@Override
public boolean cast(final Player p, final PlayerDataRPG pd, int level) {
    Location loc = p.getLocation().add(0, p.getEyeHeight() * 0.8, 0);
    loc.add(p.getLocation().getDirection().normalize().multiply(0.4));
    final Item item = p.getWorld().dropItem(loc, new ItemStack(Material.FIREBALL));
    item.setMetadata(RMetadata.META_NO_PICKUP, new FixedMetadataValue(Spell.plugin, 0));
    //        ItemManager.attachLabel(item, ChatColor.BOLD + "= " + p.getName() + "'s Bomb =");
    Spell.plugin.getInstance(DropManager.class).attachLabel(item, ChatColor.DARK_GRAY.toString() + ChatColor.ITALIC + p.getName());
    Vector dir = p.getLocation().getDirection().normalize();
    dir.setY(dir.getY() * 1.1);
    dir.multiply(0.6);
    item.setVelocity(dir);
    int damage = pd.getDamage(true);
    damage *= this.functions[0].applyAsDouble(level) / 100.0;
    final int fDamage = damage;
    RScheduler.schedule(Spell.plugin, new Runnable() {
        public void run() {
            if (item == null || !item.isValid())
                return;
            RParticles.show(ParticleEffect.EXPLOSION_LARGE, item.getLocation(), 5);
            Spell.damageNearby(fDamage, p, item.getLocation(), 3, new ArrayList<Entity>());
            DropManager.removeLabel(item);
            item.remove();
        }
    }, RTicks.seconds(1));
    Spell.notify(p, "You throw a small bomb.");
    return true;
}
 
開發者ID:edasaki,項目名稱:ZentrelaRPG,代碼行數:29,代碼來源:Bomb.java

示例9: onGameTick

import org.bukkit.entity.Item; //導入方法依賴的package包/類
@EventHandler
public void onGameTick(GameTickEvent event) {
    if(event.getTicksInSecond() < potionDropPerSecond) {
        ItemStack itemStack = new ItemStack(Material.POTION, 1, (byte) 8197);
        Item entity = this.potionDropLocation.getWorld().dropItem(potionDropLocation, itemStack);
        entity.setCustomName(ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "Potion");
        entity.setCustomNameVisible(true);
        entity.setVelocity(new Vector(0, 0.47, 0).add(Utils.getRandomCircleVector()
            .multiply(potionVelocityMultiplier*Math.random())));
    }
}
 
開發者ID:ArcadiaPlugins,項目名稱:Arcadia-Spigot,代碼行數:12,代碼來源:PotionDropGame.java

示例10: insertItem

import org.bukkit.entity.Item; //導入方法依賴的package包/類
private void insertItem(Player p, Block b) {
	final ItemStack stack = p.getInventory().getItemInMainHand();
	if (stack != null) {
		PlayerInventory.consumeItemInHand(p);
		String nametag = StringUtils.formatItemName(stack, false);
		Item entity = b.getWorld().dropItem(b.getLocation().add(0.5, 1.2, 0.5), new CustomItem(new CustomItem(stack, 1), "&5&dALTAR &3Probe - &e" + System.nanoTime()));
		entity.setVelocity(new Vector(0, 0.1, 0));
		entity.setMetadata("no_pickup", new FixedMetadataValue(SlimefunStartup.instance, "altar_item"));
		entity.setCustomNameVisible(true);
		entity.setCustomName(nametag);
		p.playSound(b.getLocation(), Sound.ENTITY_ITEM_PICKUP, 0.3F, 0.3F);
	}
}
 
開發者ID:StarWishsama,項目名稱:Slimefun4-Chinese-Version,代碼行數:14,代碼來源:AncientAltarListener.java

示例11: CraftingOperation

import org.bukkit.entity.Item; //導入方法依賴的package包/類
public CraftingOperation(Block block, ItemStack stack) {
	this.block = block;
	ItemStack toDrop = stack.clone();
	toDrop.setAmount(1);
	stack.setAmount(stack.getAmount()-1);
	Item item = block.getWorld().dropItem(block.getLocation().add(0.5, 1.2, 0.5), toDrop);
	item.setVelocity(new Vector(0,0,0));
	item.teleport(block.getLocation().add(0.5, 1.5, 0.5));
	item.setPickupDelay(Integer.MAX_VALUE);
	item.setGlowing(true);
	item.setGravity(false);
	this.book = item;
	items = new HashMap<Item, BukkitRunnable>();
}
 
開發者ID:mcardy,項目名稱:MystiCraft,代碼行數:15,代碼來源:CraftingOperation.java

示例12: explode

import org.bukkit.entity.Item; //導入方法依賴的package包/類
private void explode(Creeper creeper)
{
    this.lovingTask.cancel();

    Location flowerSpawnLocation = creeper.getLocation().clone().add(0.0D, 1.5D, 0.0D);

    for (int i = 0; i < 64; i++)
    {
        ItemStack redDye = new ItemStack(Material.INK_SACK, 1, (short) 1);
        Item item = this.player.getWorld().dropItemNaturally(flowerSpawnLocation, redDye);
        item.setVelocity(new Vector(GadgetManager.RANDOM.nextInt(2) - 1, 1.5, GadgetManager.RANDOM.nextInt(2) - 1));

        try
        {
            GadgetManager.AGE_FIELD.set((((CraftItem) item).getHandle()), 5500);
        }
        catch (IllegalAccessException e)
        {
            e.printStackTrace();
        }
    }

    creeper.getWorld().strikeLightningEffect(creeper.getLocation());
    creeper.getWorld().createExplosion(creeper.getLocation().getX(), (creeper.getLocation().getY() + 2.0D), creeper.getLocation().getZ(), 2.5F, false, false);
    creeper.remove();

    HeartEffect heartEffect = new HeartEffect(this.hub.getCosmeticManager().getParticleManager().getEffectManager());
    heartEffect.particle = de.slikey.effectlib.util.ParticleEffect.HEART;
    heartEffect.setLocation(flowerSpawnLocation.clone().add(0.0D, 1.5D, 0.0D));
    heartEffect.start();

    this.end();
}
 
開發者ID:SamaGames,項目名稱:Hub,代碼行數:34,代碼來源:HolyCreeperDisplayer.java

示例13: dropItem

import org.bukkit.entity.Item; //導入方法依賴的package包/類
public void dropItem(Location dropLocation, ItemStack itemStack) {
  Item item = this.game.getRegion().getWorld().dropItemNaturally(dropLocation, itemStack);
  item.setPickupDelay(0);
  if (this.spread != 1.0) {
    item.setVelocity(item.getVelocity().multiply(this.spread));
  }
}
 
開發者ID:BedwarsRel,項目名稱:BedwarsRel,代碼行數:8,代碼來源:ResourceSpawner.java

示例14: throwGrenade

import org.bukkit.entity.Item; //導入方法依賴的package包/類
public void throwGrenade(final Player player){
	Location loc = player.getEyeLocation().toVector().add(player.getLocation()
			.getDirection().multiply(2))
			.toLocation(player.getWorld(), player.getLocation().getYaw(), player.getLocation().getPitch());
	
	ItemStack itemStack = super.getItemStack();

       ItemStack itemGrenade = new ItemStack(itemStack.getType());
       itemGrenade.setData(super.getItemStack().getData());
       
       final Item grenade = player.getWorld().dropItem(loc, itemGrenade);
       grenade.setVelocity(player.getLocation().getDirection().multiply(2));

       grenade.setPickupDelay(999999);

       if(player.getItemInHand().getAmount()==1){
           player.setItemInHand(new ItemStack(Material.AIR, 1));
       } else {
           ItemStack itemInHand = player.getItemInHand();
           itemInHand.setAmount(itemInHand.getAmount()-1);
           player.setItemInHand(itemInHand);
       }
       
       // Makes a delay of the delay variable, and triggers the grenade
       McAssault.plugin.getServer().getScheduler().scheduleSyncDelayedTask(McAssault.plugin, new Runnable() {
           @Override
           public void run() {
           	trigger(player, grenade);
           }
       }, delay);

}
 
開發者ID:viktorstrate,項目名稱:mcAssault,代碼行數:33,代碼來源:Grenade.java

示例15: doOnLeftClick

import org.bukkit.entity.Item; //導入方法依賴的package包/類
@Override
public void doOnLeftClick(Racer racer, Action action)
{
    if(EquestrianDash.plugin.getConfig().getBoolean("Powerups.Ice.ThrowAhead.Enabled"))
    {
        Location loc = racer.getPlayer().getEyeLocation();
        final Item dropped = loc.getWorld().dropItem(loc, this.getItem());
        dropped.setVelocity(loc.getDirection().multiply(EquestrianDash.plugin.getConfig().getDouble("Powerups.Ice.ThrowAhead.Multiplier")));

        racer.getPlayer().sendMessage(getMessage());
        dropped.getWorld().playSound(dropped.getLocation(), Sound.FIZZ, 3, 0);

        new BukkitRunnable()
        {

            @Override
            public void run()
            {
                // Ice thingy
                if (!dropped.isDead())
                {
                    createIceShardThings(dropped.getLocation());
                    dropped.getWorld().playSound(dropped.getLocation(), Sound.GLASS, 3, 1);
                    dropped.remove();
                }

            }


        }.runTaskLater(EquestrianDash.plugin, EquestrianDash.plugin.getConfig().getLong("Powerups.Ice.ThrowAhead.DelayInTicks"));
        racer.getPlayer().getInventory().clear();

    }
}
 
開發者ID:ColonelHedgehog,項目名稱:Equestrian-Dash,代碼行數:35,代碼來源:IcePowerup.java


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