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


Java Vector.setZ方法代码示例

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


在下文中一共展示了Vector.setZ方法的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: 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,代码来源:SentinelBossGenerator.java

示例3: getVectorsFlameWave

import org.bukkit.util.Vector; //导入方法依赖的package包/类
private ArrayList<Vector> getVectorsFlameWave(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 < 24; k++) {
        Vector v2 = new Vector();
        v2.setY(v.getY());
        v2.setX(Math.cos(radians + k * Math.PI / 12));
        v2.setZ(Math.sin(radians + k * Math.PI / 12));
        vectors.add(v2.normalize());
    }
    return vectors;
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:20,代码来源:SentinelBossGenerator.java

示例4: 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), RUtils.randomColor());
        location.subtract(vector);
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:18,代码来源:RainbowHeartEffect.java

示例5: onRun

import org.bukkit.util.Vector; //导入方法依赖的package包/类
@Override
public void onRun() {
    Vector vector = new Vector();
    Location location = getLocation();
    location.add(0, -1, 0);
    for (int i = 0; i < particlesPerIteration; i++) {
        step++;

        float t = (MathUtils.PI / particles) * step;
        float r = MathUtils.sin(t) * size;
        float s = 2 * MathUtils.PI * t;

        vector.setX(xFactor * r * MathUtils.cos(s) + xOffset);
        vector.setZ(zFactor * r * MathUtils.sin(s) + zOffset);
        vector.setY(yFactor * size * MathUtils.cos(t) + yOffset);

        VectorUtils.rotateVector(vector, xRotation, yRotation, zRotation);

        display(particle, location.add(vector));
        location.subtract(vector);
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:23,代码来源:SwirlyEffect.java

示例6: 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 < 12; k++) {
        Vector v2 = new Vector();
        v2.setY(v.getY());
        v2.setX(Math.cos(radians + k * Math.PI / 6));
        v2.setZ(Math.sin(radians + k * Math.PI / 6));
        vectors.add(v2.normalize());
    }
    return vectors;
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:20,代码来源:MelodaIceSpell.java

示例7: getVectors

import org.bukkit.util.Vector; //导入方法依赖的package包/类
public ArrayList<Vector> getVectors(Entity e) {
    ArrayList<Vector> vectors = new ArrayList<Vector>();
    Vector v = e.getLocation().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 < 24; k++) {
        Vector v2 = new Vector();
        v2.setY(v.getY());
        v2.setX(Math.cos(radians + k * Math.PI / 12));
        v2.setZ(Math.sin(radians + k * Math.PI / 12));
        vectors.add(v2.normalize());
    }
    return vectors;
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:20,代码来源:SlimeKingBurstSpell.java

示例8: 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

示例9: onPlayerJump

import org.bukkit.util.Vector; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJump(PlayerMoveEvent event) {
    Player player = event.getPlayer();

    if (!InventoryManager.playerIsLoaded(player)) {
        return;
    }

    Vector velocity = player.getVelocity();
    Modifier jumpModifier = ItemManager.getModifier(player, ItemStat.StatType.JUMP);

    if (jumpModifier.getBonus() == 0 && jumpModifier.getMultiplier() == 1) {
        return;
    }

    // === START: Magic constants ===
    if (velocity.getY() == 0.41999998688697815D) {
        double jump = (1.5 + Math.sqrt(jumpModifier.getBonus())) * jumpModifier.getMultiplier();
        Vector moveDirection = event.getTo().toVector().subtract(event.getFrom().toVector());
        velocity.setX(moveDirection.getX() * jump * player.getWalkSpeed());
        velocity.setY(velocity.getY() * jump / 1.5);
        velocity.setZ(moveDirection.getZ() * jump * player.getWalkSpeed());
        player.setVelocity(velocity);
    }
    // === END: Magic constants ===
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:27,代码来源:ItemListener.java

示例10: getVectors

import org.bukkit.util.Vector; //导入方法依赖的package包/类
public ArrayList<Vector> getVectors(Player p) {
    ArrayList<Vector> vectors = new ArrayList<Vector>();
    Vector v = p.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 < 24; k++) {
        Vector v2 = new Vector();
        v2.setY(v.getY());
        v2.setX(Math.cos(radians + k * Math.PI / 12));
        v2.setZ(Math.sin(radians + k * Math.PI / 12));
        vectors.add(v2.normalize());
    }
    return vectors;
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:20,代码来源:RainbowBurst.java

示例11: 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

示例12: 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

示例13: dropItem

import org.bukkit.util.Vector; //导入方法依赖的package包/类
public void dropItem( ItemStack itemStack ) {
    float yaw = location.getYaw(), pitch = location.getPitch();
    Vector vector = new Vector( -Math.cos( pitch ) * Math.sin( yaw ), 0D, Math.cos( pitch ) * Math.sin( yaw ) ).multiply( 3D );
    vector.setX( Math.min( 2, vector.getX() ) );
    vector.setZ( Math.min( 2, vector.getZ() ) );
    this.getWorld().spawnItem( new Location( getWorld(),location.getX() + vector.getX(), location.getY(), location.getZ() + vector.getZ() ), itemStack );
}
 
开发者ID:lukas81298,项目名称:FlexMC,代码行数:8,代码来源:FlexPlayer.java

示例14: rayIntersection

import org.bukkit.util.Vector; //导入方法依赖的package包/类
public WrappedDirection rayIntersection(Vector ray, Vector rayOrigin, Location pipeBlockLoc) {

		//optimization to decrease division operations
		Vector dirFrac = new Vector(1d / ray.getX(), 1d / ray.getY(), 1d / ray.getZ());

		double t1 = (minx + pipeBlockLoc.getX() - rayOrigin.getX()) * dirFrac.getX();
		double t2 = (maxx + pipeBlockLoc.getX() - rayOrigin.getX()) * dirFrac.getX();
		double t3 = (miny + pipeBlockLoc.getY() - rayOrigin.getY()) * dirFrac.getY();
		double t4 = (maxy + pipeBlockLoc.getY() - rayOrigin.getY()) * dirFrac.getY();
		double t5 = (minz + pipeBlockLoc.getZ() - rayOrigin.getZ()) * dirFrac.getZ();
		double t6 = (maxz + pipeBlockLoc.getZ() - rayOrigin.getZ()) * dirFrac.getZ();

		double tMin = Math.max(Math.max(Math.min(t1, t2), Math.min(t3, t4)), Math.min(t5, t6));
		double tMax = Math.min(Math.min(Math.max(t1, t2), Math.max(t3, t4)), Math.max(t5, t6));

		//AABB is behind player
		if (tMax < 0) {
			return null;
		}

		//don't intersect
		if (tMin > tMax) {
			return null;
		}

		Vector intersectionPoint = rayOrigin.clone().add(ray.clone().multiply(tMin));

		Vector aabbMiddle = getAABBMiddle(pipeBlockLoc);
		Vector faceMiddle = new Vector();

		for (WrappedDirection pd : WrappedDirection.values()) {
			faceMiddle.setX(aabbMiddle.getX() + pd.getX() * (maxx - minx) / 2d);
			faceMiddle.setY(aabbMiddle.getY() + pd.getY() * (maxy - miny) / 2d);
			faceMiddle.setZ(aabbMiddle.getZ() + pd.getZ() * (maxz - minz) / 2d);
			double v = 1d;
			if (pd.getX() != 0) {
				v = Math.abs(intersectionPoint.getX() - faceMiddle.getX());
			}
			if (pd.getY() != 0) {
				v = Math.abs(intersectionPoint.getY() - faceMiddle.getY());
			}
			if (pd.getZ() != 0) {
				v = Math.abs(intersectionPoint.getZ() - faceMiddle.getZ());
			}
			if (v <= 0.001d) {
				return pd;
			}
		}

		return null;
	}
 
开发者ID:RoboTricker,项目名称:Transport-Pipes,代码行数:52,代码来源:AxisAlignedBB.java

示例15: cast

import org.bukkit.util.Vector; //导入方法依赖的package包/类
@Override
public boolean cast(final Player p, final PlayerDataRPG pd, int level) {
    double mult = 0.3;
    switch (level) {
        case 1:
            mult = 0.3;
            break;
        case 2:
            mult = 0.33;
            break;
        case 3:
            mult = 0.36;
            break;
        case 4:
            mult = 0.39;
            break;
        case 5:
            mult = 0.42;
            break;
    }

    final int healAmount = (int) (mult * (pd.baseMaxHP + pd.maxHP)) / 10;
    int selfDmg = (int) (0.2 * (pd.baseMaxHP + pd.maxHP));
    if (pd.hp <= selfDmg) {
        p.sendMessage(ChatColor.RED + "You don't have enough HP to cast Pledge!");
        return false;
    }
    if (selfDmg >= pd.hp)
        selfDmg = pd.hp - 1;
    pd.damageSelfTrue(selfDmg);
    ArrayList<Vector> vectors = new ArrayList<Vector>();
    Vector v = p.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 < 24; k++) {
        Vector v2 = new Vector();
        v2.setY(v.getY());
        v2.setX(Math.cos(radians + k * Math.PI / 12));
        v2.setZ(Math.sin(radians + k * Math.PI / 12));
        vectors.add(v2.normalize());
    }
    Location start = p.getLocation().add(0, 0.5 * p.getEyeHeight(), 0);
    for (Vector vec : vectors)
        RParticles.showWithSpeed(ParticleEffect.REDSTONE, start.clone().add(vec), 0, 1);
    for (int k = 1; k <= 10; k++) {
        RScheduler.schedule(Spell.plugin, new Runnable() {
            public void run() {
                if (pd != null && pd.isValid())
                    pd.heal(healAmount);
            }
        }, k * 20);
    }

    Spell.notify(p, "You pledge your HP in exchange for powerful regeneration.");
    return true;
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:62,代码来源:Pledge.java


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