当前位置: 首页>>代码示例>>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;未经允许,请勿转载。