当前位置: 首页>>代码示例>>Java>>正文


Java Vector.multiply方法代码示例

本文整理汇总了Java中org.bukkit.util.Vector.multiply方法的典型用法代码示例。如果您正苦于以下问题:Java Vector.multiply方法的具体用法?Java Vector.multiply怎么用?Java Vector.multiply使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.util.Vector的用法示例。


在下文中一共展示了Vector.multiply方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onItemDamage

import org.bukkit.util.Vector; //导入方法依赖的package包/类
@EventHandler
public void onItemDamage(EntityDamageEvent event) {
    if (event.getEntityType() == EntityType.DROPPED_ITEM && (event.getCause() == DamageCause.LAVA || event.getCause() == DamageCause.FIRE_TICK || event.getCause() == DamageCause.FIRE)) {
        Vector v = Vector.getRandom().normalize();
        v = v.setX(v.getX() - 0.5f);
        v = v.setZ(v.getZ() - 0.5f);
        v = v.multiply(0.35);
        if (v.getX() > 0 && v.getX() < 0.10)
            v.setX(0.10);
        if (v.getZ() > 0 && v.getZ() < 0.10)
            v.setZ(0.10);
        if (v.getX() < 0 && v.getX() > -0.10)
            v.setX(-0.10);
        if (v.getZ() < 0 && v.getZ() > -0.10)
            v.setZ(-0.10);
        v.setY(0.3);
        event.getEntity().setVelocity(v);
        event.setCancelled(true);
        RScheduler.schedule(plugin, () -> {
            event.getEntity().setFireTicks(0);
        }, RTicks.seconds(1));
    }
    if (event.getEntityType() == EntityType.ARMOR_STAND && (event.getCause() == DamageCause.LAVA || event.getCause() == DamageCause.FIRE_TICK || event.getCause() == DamageCause.FIRE)) {
        event.setCancelled(true);
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:27,代码来源:EnvironmentManager.java

示例2: onRun

import org.bukkit.util.Vector; //导入方法依赖的package包/类
@Override
public void onRun() {
    Location location = getLocation();
    location.add(0, 2, 0);
    float radius = 3 * innerRadius / MathUtils.SQRT_3;
    for (int i = 0; i < spikesHalf * 2; i++) {
        double xRotation = i * Math.PI / spikesHalf;
        for (int x = 0; x < particles; x++) {
            double angle = 2 * Math.PI * x / particles;
            float height = RandomUtils.random.nextFloat() * spikeHeight;
            Vector v = new Vector(Math.cos(angle), 0, Math.sin(angle));
            v.multiply((spikeHeight - height) * radius / spikeHeight);
            v.setY(innerRadius + height);
            VectorUtils.rotateAroundAxisX(v, xRotation);
            location.add(v);
            display(particle, location);
            location.subtract(v);
            VectorUtils.rotateAroundAxisX(v, Math.PI);
            VectorUtils.rotateAroundAxisY(v, Math.PI / 2);
            location.add(v);
            display(particle, location);
            location.subtract(v);
        }
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:26,代码来源:EmeraldStarEffect.java

示例3: run

import org.bukkit.util.Vector; //导入方法依赖的package包/类
public void run()
{
    if(Bukkit.getPlayer(uuid) == null)
        Bukkit.getScheduler().cancelTask(id);
    else
    if(Bukkit.getPlayer(uuid).isDead())
        Bukkit.getScheduler().cancelTask(id);
    else
    if(!Bukkit.getPlayer(uuid).isSneaking())
    {
        Bukkit.getScheduler().cancelTask(id);
    } else
    {
        Player p = Bukkit.getPlayer(uuid);
        Vector vector = new Vector(0, 1, 0);
        vector.multiply(-0.10000000000000001D);
        p.setVelocity(vector);
        p.setFallDistance(0.0F);
        if(!p.isSneaking())
            Bukkit.getScheduler().cancelTask(id);
    }
}
 
开发者ID:StarWishsama,项目名称:Slimefun4-Chinese-Version,代码行数:23,代码来源:ParachuteTask.java

示例4: flightPath

import org.bukkit.util.Vector; //导入方法依赖的package包/类
/**
 * Override this class, you can use it to provide particle effects along travel path. 
 * 
 * It is called after all other handling is done. Keep it lightweight
 * 
 * @param start The start location of flight
 * @param end The end location of impact / miss
 * @param type the type of bullet in play
 * @param endOfFlight is the bullet still flying after this or has it impacted?
 */
public void flightPath(Location start, Location end, Bullet type, boolean endOfFlight) {
	// no special flight path stuff. maybe a whizzing sound?

	World world = start.getWorld();
	if (endOfFlight) {
		// make a new sound where it hits.
		world.playSound(end, Sound.ENTITY_FIREWORK_BLAST, 1.0f, 1.5f);
	}
	if (type.getFireChance() > 0.0d) {
		if (start != null) {
			double distance = end.distance(start);

			Vector vector = end.subtract(start).toVector();
			vector = vector.multiply(0.1d / distance);
			for (int i = 0; i < distance; i++) {
				world.spawnParticle(Particle.SMOKE_NORMAL, start.add(vector), 5, 0.01, 0.01, 0.01, 0.001);
			}
		}
	}
}
 
开发者ID:ProgrammerDan,项目名称:AddGun,代码行数:31,代码来源:StandardGun.java

示例5: onPlayerToggleFlight

import org.bukkit.util.Vector; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerToggleFlight(final PlayerToggleFlightEvent event) {
    Player player = event.getPlayer();
    Jumper jumper = this.jumpers.get(player);
    if(jumper == null) return;

    if(event.isFlying()) {
        event.setCancelled(true);

        this.setCharge(jumper, 0f);
        this.refreshJump(player);

        // calculate jump
        Vector impulse = player.getLocation().getDirection();

        impulse.setY(0.75 + Math.abs(impulse.getY()) * 0.5);
        impulse.multiply(jumper.kit.power / 3f);
        event.getPlayer().applyImpulse(impulse, true);

        player.getWorld().playSound(player.getLocation(), Sound.ENTITY_ZOMBIE_INFECT, 0.5f, 1.8f);
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:23,代码来源:DoubleJumpMatchModule.java

示例6: boost

import org.bukkit.util.Vector; //导入方法依赖的package包/类
private boolean boost(Entity source, Entity receiver) {
    if (!(source instanceof Player) || !(receiver instanceof Player) || !isPlaying((Player) source) || !isPlaying((Player) receiver))
        return false;
    receiver.sendMessage(ChatColor.GREEN + "Whoosh!");
    Vector toSender = source.getVelocity().subtract(receiver.getVelocity());
    toSender.setY(0);
    double distance = toSender.length();
    if(distance > 0) {
        toSender.multiply(1D / distance);
    } else {
        float yaw = source.getLocation().getYaw();
        toSender.setX(-1 * Math.sin(toRad(yaw)));
        toSender.setZ(Math.cos(toRad(yaw)));
    }
    toSender.multiply(2.5D);
    toSender.setY(2);
    receiver.setVelocity(toSender);
    return true;
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:20,代码来源:Boost.java

示例7: stepLocation

import org.bukkit.util.Vector; //导入方法依赖的package包/类
private void stepLocation(Entity ent, Location to, double blocksPerTick) {
    if (!ent.isValid())
        return;

    Location from = ent.getLocation();
    World world = from.getWorld();
    Vector fv = new Vector(from.getX(), from.getY(), from.getZ());
    Vector tv = new Vector(to.getX(), to.getY(), to.getZ());

    double bpt = blocksPerTick;
    Vector dv = new Vector(0d, 0d, 0d);
    dv.add(tv);
    dv.subtract(fv);
    Vector nv = dv.clone();
    nv.multiply(1 / dv.length() * bpt);

    if (nv.length() > dv.length())
        return;

    nv.add(fv);
    Location nl = new Location(world, nv.getX(), nv.getY(), nv.getZ());
    nl.setDirection(dv);
    ent.teleport(nl);
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:25,代码来源:ActionEntityPathfind.java

示例8: cast

import org.bukkit.util.Vector; //导入方法依赖的package包/类
@Override
public boolean cast(final Player p, PlayerDataRPG pd, int level) {
    double force = 0;
    switch (level) {
        case 1:
            force = 1.5;
            break;
        case 2:
            force = 3;
            break;
        case 3:
            force = 5;
            break;
    }
    for (Entity e : RMath.getNearbyEntitiesCylinder(p.getLocation(), 7, 9)) {
        boolean pull = false;
        if (e instanceof Player && e != p) {
            Player p2 = (Player) e;
            PlayerDataRPG pd2 = Spell.plugin.getPD(p2);
            if (pd2 == null)
                continue;
            if (pd.party != null && pd2.party != null && pd.party == pd2.party)
                continue;
            if (pd2 != null && pd2.isPVP())
                pull = true;
        } else if (MobManager.spawnedMobs_onlyMain.containsKey(e.getUniqueId())) {
            pull = true;
        }
        if (pull) {
            Vector pushVector = e.getLocation().toVector().subtract(p.getLocation().toVector()).normalize();
            pushVector.multiply(force);
            if (pushVector.getY() > 0.5)
                pushVector.setY(0.5);
            e.setVelocity(pushVector);
        }
    }
    RParticles.show(ParticleEffect.EXPLOSION_LARGE, p.getLocation(), 5);
    Spell.notify(p, "You push away nearby enemies.");
    return true;
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:41,代码来源:AntiGravity.java

示例9: cast

import org.bukkit.util.Vector; //导入方法依赖的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

示例10: getDirection

import org.bukkit.util.Vector; //导入方法依赖的package包/类
/**
 * Returns the launch direction for holding pets.
 *
 * @param player player
 * @return launchDirection
 */
private Vector getDirection(Player player) {
    final Vector vector = new Vector();
    final double rotX = player.getLocation().getYaw();
    final double rotY = player.getLocation().getPitch();
    vector.setY(-Math.sin(Math.toRadians(rotY)));
    final double h = Math.cos(Math.toRadians(rotY));
    vector.setX(-h * Math.sin(Math.toRadians(rotX)));
    vector.setZ(h * Math.cos(Math.toRadians(rotX)));
    return vector.multiply(1.2);
}
 
开发者ID:Shynixn,项目名称:PetBlocks,代码行数:17,代码来源:PetBlockListener.java

示例11: getDirection

import org.bukkit.util.Vector; //导入方法依赖的package包/类
/**
 * Returns the launch Direction for the cannon
 *
 * @param player player
 * @return launchDirection
 */
private Vector getDirection(Player player) {
    final Vector vector = new Vector();
    final double rotX = player.getLocation().getYaw();
    final double rotY = player.getLocation().getPitch();
    vector.setY(-Math.sin(Math.toRadians(rotY)));
    final double h = Math.cos(Math.toRadians(rotY));
    vector.setX(-h * Math.sin(Math.toRadians(rotX)));
    vector.setZ(h * Math.cos(Math.toRadians(rotX)));
    vector.setY(0.5);
    return vector.multiply(3);
}
 
开发者ID:Shynixn,项目名称:PetBlocks,代码行数:18,代码来源:PetDataListener.java

示例12: run

import org.bukkit.util.Vector; //导入方法依赖的package包/类
public void run()
{
    if(Bukkit.getPlayer(uuid) == null)
        Bukkit.getScheduler().cancelTask(id);
    else
    if(Bukkit.getPlayer(uuid).isDead())
        Bukkit.getScheduler().cancelTask(id);
    else
    if(!Bukkit.getPlayer(uuid).isSneaking())
    {
        Bukkit.getScheduler().cancelTask(id);
    } else
    {
        Player p = Bukkit.getPlayer(uuid);
        float cost = 0.08F;
        float charge = ItemEnergy.getStoredEnergy(p.getInventory().getChestplate());
        if(charge >= cost)
        {
            p.getInventory().setChestplate(ItemEnergy.chargeItem(p.getInventory().getChestplate(), -cost));
            me.mrCookieSlime.CSCoreLibPlugin.general.Player.PlayerInventory.update(p);
            p.getWorld().playSound(p.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 0.25F, 1.0F);
            p.getWorld().playEffect(p.getLocation(), Effect.SMOKE, 1, 1);
            p.setFallDistance(0.0F);
            Vector vector = new Vector(0, 1, 0);
            vector.multiply(thrust);
            vector.add(p.getEyeLocation().getDirection().multiply(0.2F));
            p.setVelocity(vector);
        } else
        {
            Bukkit.getScheduler().cancelTask(id);
        }
    }
}
 
开发者ID:StarWishsama,项目名称:Slimefun4-Chinese-Version,代码行数:34,代码来源:JetpackTask.java

示例13: calculateVectorPath

import org.bukkit.util.Vector; //导入方法依赖的package包/类
public static ArrayList<Location> calculateVectorPath(Location start, Vector direction, int length, int spacing, boolean ignoreBlock) {
    ArrayList<Location> locs = new ArrayList<Location>();
    Location loc = start;
    direction = direction.normalize();
    length *= spacing;
    direction = direction.multiply(1.0 / spacing);
    for (int k = 0; k < length; k++) {
        loc = loc.add(direction);
        if (!ignoreBlock && !RParticles.isAirlike(loc.getBlock()))
            break;
        locs.add(loc.clone());
    }
    return locs;
}
 
开发者ID:edasaki,项目名称:ZentrelaCore,代码行数:15,代码来源:RMath.java

示例14: cast

import org.bukkit.util.Vector; //导入方法依赖的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.FURNACE));
    item.setMetadata(RMetadata.META_NO_PICKUP, new FixedMetadataValue(Spell.plugin, 0));
    //        ItemManager.attachLabel(item, ChatColor.BOLD + "= " + p.getName() + "'s Smoke =");
    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 duration = 1;
    switch (level) {
        case 1:
            duration = 3;
            break;
        case 2:
            duration = 5;
            break;
        case 3:
            duration = 7;
            break;
    }
    final int fDuration = duration * 2;
    for (int k = 1; k <= fDuration; k++) {
        final int kVal = k;
        RScheduler.schedule(Spell.plugin, new Runnable() {
            static final int RANGE = 10;

            public void run() {
                if (item == null || !item.isValid())
                    return;
                for (int k = 0; k < 25; k++) {
                    switch ((int) (Math.random() * 4)) {
                        case 0:
                            RParticles.showWithOffsetPositiveY(ParticleEffect.SMOKE_LARGE, item.getLocation(), RANGE, 30);
                            break;
                        case 1:
                            RParticles.showWithOffsetPositiveY(ParticleEffect.SMOKE_NORMAL, item.getLocation(), RANGE, 30);
                            break;
                        case 2:
                            RParticles.showWithOffsetPositiveY(ParticleEffect.CLOUD, item.getLocation(), RANGE, 30);
                            break;
                        case 3:
                            RParticles.showWithOffsetPositiveY(ParticleEffect.EXPLOSION_LARGE, item.getLocation(), RANGE, 20);
                            break;
                    }
                }
                if (kVal == fDuration) {
                    DropManager.removeLabel(item);
                    item.remove();
                }
            }
        }, k * 10);
    }
    Spell.notify(p, "You throw a device that generates smoke.");
    return true;
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:60,代码来源:QuickSmoke.java

示例15: gunBulletHitGroundEvent

import org.bukkit.util.Vector; //导入方法依赖的package包/类
/**
 * It hit the ground maybe!
 * 
 * @param event the impact event, we ignore any that aren't just blockhits
 */
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void gunBulletHitGroundEvent(ProjectileHitEvent event) {
	if (!EntityType.SMALL_FIREBALL.equals(event.getEntityType()))
		return;
	if (event.getHitBlock() == null)
		return;

	SmallFireball bullet = (SmallFireball) event.getEntity();
	if (!bullet.getName().equals(this.tag))
		return;

	Location end = event.getHitBlock().getLocation().clone().add(0.5, 0.5, 0.5);
	World world = end.getWorld();

	// make a new sound where it hits.
	world.playSound(end, Sound.ENTITY_FIREWORK_BLAST, 1.0f, 1.5f);
	
	// make a splash
	world.spawnParticle(Particle.BLOCK_DUST, end.clone().add( 0.5, 0.0, 0.0), 5);
	world.spawnParticle(Particle.BLOCK_DUST, end.clone().add(-0.5, 0.0, 0.0), 5);
	world.spawnParticle(Particle.BLOCK_DUST, end.clone().add( 0.0, 0.5, 0.0), 5);
	world.spawnParticle(Particle.BLOCK_DUST, end.clone().add( 0.0,-0.5, 0.0), 5);
	world.spawnParticle(Particle.BLOCK_DUST, end.clone().add( 0.0, 0.0, 0.5), 5);
	world.spawnParticle(Particle.BLOCK_DUST, end.clone().add( 0.0, 0.0,-0.5), 5);

	Entity hit = event.getEntity();
	if (hit == null) {
		Location start = travelPaths.remove(bullet.getUniqueId());

		if (start != null) {
			double distance = end.distance(start);

			Vector vector = end.subtract(start).toVector();
			vector = vector.multiply(1.0d / distance);
			for (int i = 0; i < distance; i++) {
				world.spawnParticle(Particle.FLAME, start.add(vector), 5);
			}
		}

		bullet.remove();
		return;
	}
}
 
开发者ID:ProgrammerDan,项目名称:AddGun,代码行数:49,代码来源:RailGun.java


注:本文中的org.bukkit.util.Vector.multiply方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。