本文整理汇总了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);
}
}
}
}
示例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());
}
示例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);
}
}
}
}
示例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);
}
}
}
}
}
示例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;
}
}
示例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;
}
示例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);
}
示例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;
}
示例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())));
}
}
示例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);
}
}
示例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>();
}
示例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();
}
示例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));
}
}
示例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);
}
示例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();
}
}