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


Java Vector类代码示例

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


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

示例1: parseHalves

import org.bukkit.util.Vector; //导入依赖的package包/类
private Region parseHalves(Element el, double dir) throws InvalidXMLException {
    final List<HalfspaceRegion> halves = new ArrayList<>();

    XMLUtils.parseNumber(el, "x", Double.class).infinity(true).optional().ifPresent(x ->
        halves.add(new HalfspaceRegion(new Vector(x, 0, 0), new Vector(dir, 0, 0)))
    );

    XMLUtils.parseNumber(el, "y", Double.class).infinity(true).optional().ifPresent(y ->
        halves.add(new HalfspaceRegion(new Vector(0, y, 0), new Vector(0, dir, 0)))
    );

    XMLUtils.parseNumber(el, "z", Double.class).infinity(true).optional().ifPresent(z ->
        halves.add(new HalfspaceRegion(new Vector(0, 0, z), new Vector(0, 0, dir)))
    );

    if(halves.isEmpty()) {
        throw new InvalidXMLException("Expected at least one of x, y, or z attributes", el);
    }

    return new Intersection(halves);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:22,代码来源:RegionDefinitionParser.java

示例2: onTick

import org.bukkit.util.Vector; //导入依赖的package包/类
@Override
public void onTick() {
	if (target.isDead()) {
		return;
	}
	double speed = this.entity.getVelocity().length() * 0.9D + 0.14D;
	Vector velocity = null;
	Vector direction = this.entity.getVelocity().clone().normalize();
	Vector targetDirection = this.target.getLocation().clone().add(new Vector(0, 0.5D, 0))
			.subtract(this.entity.getLocation()).toVector();
	Vector targetDirectionNorm = targetDirection.clone().normalize();

	double angle = direction.angle(targetDirectionNorm);

	if (angle < 0.12D) {
		velocity = direction.clone().multiply(speed);
	} else {
		velocity = direction.clone().multiply((angle - 0.12D) / angle)
				.add(targetDirectionNorm.clone().multiply(0.12D / angle)).normalize().multiply(speed);
	}
	this.entity.setVelocity(velocity.add(new Vector(0.0D, 0.03D, 0.0D)));
}
 
开发者ID:mcardy,项目名称:MystiCraft,代码行数:23,代码来源:TargetedProjectile.java

示例3: getBB

import org.bukkit.util.Vector; //导入依赖的package包/类
public static BoundingBoxWrapper getBB(Entity forWhat) {
    try {
        Object aaBb = getBB.invoke(getHandle.invoke(craftEntity.cast(forWhat)));
        double[] c = new double[]{
                (double) coordinates[0].get(aaBb),
                (double) coordinates[1].get(aaBb),
                (double) coordinates[2].get(aaBb),
                (double) coordinates[3].get(aaBb),
                (double) coordinates[4].get(aaBb),
                (double) coordinates[5].get(aaBb)
        };
        BoundingBoxWrapper box = new BoundingBoxWrapper(new Vector(c[0], c[1], c[2]), new Vector(c[3], c[4],
                c[5]));
        box.unshift(forWhat.getLocation());
        return box;
    } catch (IllegalAccessException | InvocationTargetException e) {
        e.printStackTrace();
        return null;
    }
}
 
开发者ID:iso2013,项目名称:MultiLineAPI,代码行数:21,代码来源:HitboxUtil.java

示例4: ejectMass

import org.bukkit.util.Vector; //导入依赖的package包/类
public void ejectMass() {
    if(!action) return;
    if(mass >= 32) {
        mass -= 16;
        final StaticCell cell = new StaticCell(12, getX(), getY());
        cell.setInvinsible(true);
        int size = (int) (Math.floor(Math.cbrt(this.mass)));
        if (size < 3)
            size = 3;
        Vector vector = player.getPlayer().getLocation().getDirection().setY(0).normalize().multiply((double)size / 1.5D);
        cell.setVelocity(vector);

        AgarMC plugin = AgarMC.get();
        plugin.getGame().addStaticCell(cell);

        plugin.getServer().getScheduler().runTaskLater(plugin, () -> cell.setInvinsible(false), 10L);

        recalculateSize();
    }
}
 
开发者ID:SamaGames,项目名称:AgarMC,代码行数:21,代码来源:PlayerCell.java

示例5: KillAuraTask

import org.bukkit.util.Vector; //导入依赖的package包/类
public KillAuraTask(final Player player)
{
    super(player, true);

    this.touched = new HashMap<>();
    this.angles = new HashMap<>();
    this.positionsTemplate = new ArrayList<>();
    this.nextTest = System.currentTimeMillis();
    this.numberDisplayed = 1;
    this.activeCheck = true;
    this.isTouched = false;

    this.positionsTemplate.add(new Vector(3, 2.5, 1.5));
    this.positionsTemplate.add(new Vector(2.5, 1, -2));
    this.positionsTemplate.add(new Vector(0, 0.5, 4));
    this.positionsTemplate.add(new Vector(0, 4, -2.5));
    this.positionsTemplate.add(new Vector(0, 4, 2.5));
    this.positionsTemplate.add(new Vector(3, 0.5, -3));
    this.positionsTemplate.add(new Vector(-4, 0.5, 2));
    this.positionsTemplate.add(new Vector(0, 4.5, 0));
    this.positionsTemplate.add(new Vector(3, 0.2, 3));
    this.positionsTemplate.add(new Vector(-2, 4.5, 0));

    this.resetAngles();
}
 
开发者ID:SamaGames,项目名称:AntiCheat,代码行数:26,代码来源:KillAuraTask.java

示例6: onRun

import org.bukkit.util.Vector; //导入依赖的package包/类
@Override
public void onRun() {
    Location location = getLocation();
    location.add(0, 0.5, 0);
    for (int i = 0; i < particles; i++) {
        float alpha = ((MathUtils.PI / compilation) / particles) * i;
        double phi = Math.pow(Math.abs(MathUtils.sin(2 * compilation * alpha)) + factorInnerSpike * Math.abs(MathUtils.sin(compilation * alpha)), 1 / compressYFactorTotal);

        Vector vector = new Vector();
        vector.setY(phi * (MathUtils.sin(alpha) + MathUtils.cos(alpha)) * yFactor);
        vector.setZ(phi * (MathUtils.cos(alpha) - MathUtils.sin(alpha)) * zFactor);

        VectorUtils.rotateVector(vector, 0, -location.getYaw() * MathUtils.degreesToRadians + (Math.PI / 2f), 0);
        display(particle, location.add(vector), this.clr);
        location.subtract(vector);
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:18,代码来源:ColoredHeartEffect.java

示例7: EventRuleImpl

import org.bukkit.util.Vector; //导入依赖的package包/类
EventRuleImpl(EventRuleScope scope,
              Region region,
              Filter filter,
              Kit kit,
              boolean lendKit,
              Vector velocity,
              @Nullable BaseComponent message,
              boolean earlyWarning) {
    this.scope = scope;
    this.region = region;
    this.filter = filter;
    this.kit = kit;
    this.lendKit = lendKit;
    this.velocity = velocity;
    this.message = message;
    this.earlyWarning = earlyWarning;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:18,代码来源:EventRule.java

示例8: getVectorsNormal

import org.bukkit.util.Vector; //导入依赖的package包/类
private ArrayList<Vector> getVectorsNormal(LivingEntity e) {
    ArrayList<Vector> vectors = new ArrayList<Vector>();
    Vector v = e.getEyeLocation().getDirection().normalize();
    v.setY(0);
    vectors.add(v);
    double z = v.getZ();
    double x = v.getX();
    double radians = Math.atan(z / x);
    if (x < 0)
        radians += Math.PI;
    for (int k = 1; k < 4; k++) {
        Vector v2 = new Vector();
        v2.setY(v.getY());
        v2.setX(Math.cos(radians + k * Math.PI / 2));
        v2.setZ(Math.sin(radians + k * Math.PI / 2));
        vectors.add(v2.normalize());
    }
    return vectors;
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:20,代码来源:QuadBeamSpell.java

示例9: pullEntityToLocation

import org.bukkit.util.Vector; //导入依赖的package包/类
public void pullEntityToLocation(Entity e, Location loc) {
    Location entityLoc = e.getLocation();
    entityLoc.setY(entityLoc.getY() + 0.5D);
    e.teleport(entityLoc);
    double g = -0.08D;
    if (loc.getWorld() != entityLoc.getWorld())
        return;
    double d = loc.distance(entityLoc);
    double t = d;
    double v_x = (1.0D + 0.07000000000000001D * t) * (loc.getX() - entityLoc.getX()) / t;
    double v_y = (1.0D + 0.03D * t) * (loc.getY() - entityLoc.getY()) / t - 0.5D * g * t;
    double v_z = (1.0D + 0.07000000000000001D * t) * (loc.getZ() - entityLoc.getZ()) / t;
    Vector v = e.getVelocity();
    v.setX(v_x);
    v.setY(v_y);
    v.setZ(v_z);
    e.setVelocity(v);
    e.setFallDistance(0f);
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:20,代码来源:GrappleManager.java

示例10: launchFireworkDisplay

import org.bukkit.util.Vector; //导入依赖的package包/类
public void launchFireworkDisplay(final World w, final Location loc) {
    Firework fw = (Firework) w.spawn(loc.clone().add(new Vector(getRandomNum(5, -5), 1, getRandomNum(5, -5))), Firework.class);
    FireworkMeta meta = fw.getFireworkMeta();
    FireworkEffect effect = SkyWarsReloaded.getNMS().getFireworkEffect(getRandomColor(),getRandomColor(), getRandomColor(), getRandomColor(), getRandomColor(), getRandomType());
    meta.addEffect(effect);
    meta.setPower(getRandomNum(4, 1));
    fw.setFireworkMeta(meta);
    fireworksCount++;
    if (fireworksCount < ((SkyWarsReloaded.getCfg().getTimeAfterGame() - 5)*4)) {
		SkyWarsReloaded.get().getServer().getScheduler().scheduleSyncDelayedTask(SkyWarsReloaded.get(),  new Runnable() {
			public void run() {
				launchFireworkDisplay(w, loc);
			}
		}, 5);
    }
}
 
开发者ID:smessie,项目名称:SkyWarsReloaded,代码行数:17,代码来源:Game.java

示例11: splitTeleportArmorstand

import org.bukkit.util.Vector; //导入依赖的package包/类
/**
 * Teleport a {@link FakeArmorstand} to a specific {@link Location} in certain intervals, which is visible for all Players
 *
 * @param p             the {@link Player} to teleport the {@link FakeArmorstand} for
 * @param to            the {@link Location} where the {@link FakeArmorstand} should be teleported to
 * @param teleportCount the amount of teleportation that should be made
 * @param wait          the amount of time to wait 'till the next teleport starts
 * @param armorstand    the {@link FakeArmorstand} which should be teleported
 */
public static void splitTeleportArmorstand(final Player p, final Location to, final int teleportCount, final long wait, final FakeArmorstand armorstand) {
    final Location currentLocation = armorstand.getCurrentlocation();
    Vector between = to.toVector().subtract(currentLocation.toVector());

    final double toMoveInX = between.getX() / teleportCount;
    final double toMoveInY = between.getY() / teleportCount;
    final double toMoveInZ = between.getZ() / teleportCount;

    SPLIT_MAP.put(p.getName(), new BukkitRunnable() {
        public void run() {
            if (!LocationUtil.isSameLocation(currentLocation, to)) {
                teleportArmorstand(p, currentLocation.add(new Vector(toMoveInX, toMoveInY, toMoveInZ)), armorstand);
            } else
                this.cancel();
        }
    }.runTaskTimer(AlphaLibary.getInstance(), 0, wait));
}
 
开发者ID:AlphaHelixDev,项目名称:AlphaLibary,代码行数:27,代码来源:ArmorstandFakeUtil.java

示例12: run

import org.bukkit.util.Vector; //导入依赖的package包/类
public void run() {
	Vector headMove = null;
	if (this.start == 0l) {
		// start
		headMove = start();
	} else if (!isDone()) {
		// continue;
		headMove = step();
	} else { // done
		throw new RuntimeException("Done this animation");
	}
	
	if (player != null) {
		Location bloc = player.getEyeLocation().clone();
		Location loc = player.getEyeLocation().clone().setDirection(bloc.getDirection().clone().add(headMove));
		((CraftPlayer)player).getHandle().playerConnection.sendPacket(new PacketPlayOutPosition(0.0, 0.0, 0.0, loc.getYaw() - bloc.getYaw(), loc.getPitch() - bloc.getPitch(), flags, 99));
	}
}
 
开发者ID:ProgrammerDan,项目名称:AddGun,代码行数:19,代码来源:Animation.java

示例13: splitTeleportBigItem

import org.bukkit.util.Vector; //导入依赖的package包/类
/**
 * Teleport a {@link FakeBigItem} to a specific {@link Location} in certain intervals, which is visible for all Players
 *
 * @param p             the {@link Player} to teleport the {@link FakeBigItem} for
 * @param to            the {@link Location} where the {@link FakeBigItem} should be teleported to
 * @param teleportCount the amount of teleportation that should be made
 * @param wait          the amount of time to wait 'till the next teleport starts
 * @param item          the {@link FakeBigItem} which should be teleported
 */
public static void splitTeleportBigItem(final Player p, final Location to, final int teleportCount, final long wait, final FakeBigItem item) {
    final Location currentLocation = item.getCurrentlocation();
    Vector between = to.toVector().subtract(currentLocation.toVector());

    final double toMoveInX = between.getX() / teleportCount;
    final double toMoveInY = between.getY() / teleportCount;
    final double toMoveInZ = between.getZ() / teleportCount;

    SPLIT_MAP.put(p.getName(), new BukkitRunnable() {
        public void run() {
            if (!LocationUtil.isSameLocation(currentLocation, to)) {
                teleportBigItem(p, currentLocation.add(new Vector(toMoveInX, toMoveInY, toMoveInZ)), item);
            } else
                this.cancel();
        }
    }.runTaskTimer(AlphaLibary.getInstance(), 0, wait));
}
 
开发者ID:AlphaHelixDev,项目名称:AlphaLibary,代码行数:27,代码来源:BigItemFakeUtil.java

示例14: onRun

import org.bukkit.util.Vector; //导入依赖的package包/类
@Override
public void onRun()
{
    // Prevents an excess of particles
    if (last != null && last.getX() == getEntity().getLocation().getX() && last.getZ() == getEntity().getLocation().getZ())
        return;
    last = getEntity().getLocation();

    Block block = this.getEntity().getLocation().add(0, -0.4, 0).getBlock();
    Material type = block.getType();

    // If the step should be displayed or not
    if (type.isBlock() && type.isSolid() && !type.isTransparent()) {
        Location loc = getEntity().getLocation();
        loc.setY(block.getY());
        loc = loc.add(0, 1 + Math.random() / 100, 0);
        Vector dir = VectorUtils.rotateAroundAxisY(getEntity().getLocation().getDirection().setY(0).normalize(), p ? 90 : -90).multiply(0.25);
        display(ParticleEffect.FOOTSTEP, loc.add(dir.getX(), 0, dir.getZ()), 7, 0);

        p = !p;
    }
}
 
开发者ID:SamaGames,项目名称:Hub,代码行数:23,代码来源:StepEffect.java

示例15: startDungeon

import org.bukkit.util.Vector; //导入依赖的package包/类
/**Dungeon activation function called when a player gives the /start command. Calls the genEntry() function at that players position.
 * @param p		The player that gave the /start command.
 */
private void startDungeon(Player p) {
	// calc starting location in front of player on level ground:
	// also check if ground is solid. if not then paste over the gras etc.
	int initDist = 10; // distance to player
	Vector start = new Vector(p.getLocation().getBlockX(),p.getLocation().getBlockY(),p.getLocation().getBlockZ());
	Direc playerDirec = Helper.getPlayerDirec(p);
	int deltaX = (int)Math.round(-Helper.sind(playerDirec.degree())*initDist);
	int deltaZ = (int)Math.round(+Helper.cosd(playerDirec.degree())*initDist);
	start.add(new Vector(deltaX,0,deltaZ));
	int solidOffset = 0;
	if (world.getHighestBlockAt(start.getBlockX(), start.getBlockZ()).getType().isSolid()) {
		solidOffset = 1;
	}
	start.setY(world.getHighestBlockYAt(start.getBlockX(), start.getBlockZ())+solidOffset);
	
	genEntry(start, playerDirec);
}
 
开发者ID:TheRoot89,项目名称:DungeonGen,代码行数:21,代码来源:DunGen.java


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