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


Java Vector.getX方法代码示例

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


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

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

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

示例3: 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,代码来源:HyperBody.java

示例4: rotateAroundPoint

import org.bukkit.util.Vector; //导入方法依赖的package包/类
public Vector rotateAroundPoint(Vector toRotate, Vector point) {
    double x = toRotate.getX() - point.getX();
    double y = toRotate.getY() - point.getY();
    double z = toRotate.getZ() - point.getZ();

    double nX = x * angleCos - y * angleSin - z * angleSin;
    double nY = y * angleCos - x * angleSin - z * angleSin;
    double nZ = z * angleCos - x * angleSin - y * angleSin;

    return new Vector(nX, nY, nZ);
}
 
开发者ID:AlphaHelixDev,项目名称:AlphaLibary,代码行数:12,代码来源:VectorRotator.java

示例5: intersects

import org.bukkit.util.Vector; //导入方法依赖的package包/类
public static boolean intersects(Vector position, Vector min, Vector max) {
    if (position.getX() < min.getX() || position.getX() > max.getX()) {
        return false;
    } else if (position.getY() < min.getY() || position.getY() > max.getY()) {
        return false;
    } else if (position.getZ() < min.getZ() || position.getZ() > max.getZ()) {
        return false;
    }
    return true;
}
 
开发者ID:upperlevel,项目名称:uppercore,代码行数:11,代码来源:RayTrace.java

示例6: movePlayer

import org.bukkit.util.Vector; //导入方法依赖的package包/类
public void movePlayer(Entity p, int dx, int dy, int dz) {
	NavyCraft.instance.DebugMessage("Moving player", 4);
	int mccraftspeed = craft.speed;
	if (mccraftspeed > 2) {
		mccraftspeed = 2;
	}

	Vector pVel = p.getVelocity();

	if (dx > 0) {
		dx = craft.speed;
	} else {
		dx = craft.speed * -1;
	}
	if (dy > 0) {
		dy = craft.speed;
	} else {
		dy = craft.speed * -1;
	}
	if (dz > 0) {
		dz = craft.speed;
	} else {
		dz = craft.speed * -1;
	}
	pVel = pVel.add(new Vector(dx, dy, dz));


	if ((pVel.getX() > 10) || (pVel.getZ() > 10) || (pVel.getY() > 10)) {

		System.out.println("Velocity is too high, have to teleport " + p.getEntityId());
		Location pLoc = p.getLocation();
		pLoc.setX(pLoc.getX() + pVel.getX());
		pLoc.setY(pLoc.getY() + pVel.getY() + .05);
		pLoc.setZ(pLoc.getZ() + pVel.getZ());
		p.teleport(pLoc);
	} else {
		p.setVelocity(pVel);
	}
}
 
开发者ID:Maximuspayne,项目名称:NavyCraft2-Lite,代码行数:40,代码来源:CraftMover.java

示例7: getAngle

import org.bukkit.util.Vector; //导入方法依赖的package包/类
@Override
public float getAngle(Vector from) {
    double dx = this.target.getX() - from.getX();
    double dz = this.target.getZ() - from.getZ();
    double distance = Math.sqrt(dx * dx + dz * dz);
    double dy = this.target.getY() - (from.getY() + 1.62); // add eye height so player actually looks at point
    return (float) Math.toDegrees(Math.atan2(-dy, distance));
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:9,代码来源:DirectedPitchProvider.java

示例8: ballInteractEvent

import org.bukkit.util.Vector; //导入方法依赖的package包/类
/**
 * Gets called when a player interacts with a ball
 *
 * @param event event
 */
@EventHandler
public void ballInteractEvent(BallInteractEvent event) {
    final Game game;
    if ((game = this.controller.getGameFromBall(event.getBall())) != null) {
        final GameEntity entity = (GameEntity) game;
        if (entity.ballPreviousCacheLocation != null && entity.ballPreviousCacheLocation.distance(event.getBall().getLocation().toVector()) < 2) {
            entity.ballCornerBumper++;
        } else {
            entity.ballCornerBumper = 0;
        }
        if (entity.ballCornerBumper >= 3) {
            final Vector direction = entity.arena.getBallSpawnLocation().toVector().subtract(event.getBall().getLocation().toVector());
            int x = 1;
            int z = 1;
            if (direction.getX() < 0)
                x = -1;
            if (direction.getZ() < 0)
                z = -1;
            event.getBall().teleport(new Location(event.getBall().getLocation().getWorld(), event.getBall().getLocation().getX() + x, event.getBall().getLocation().getY(), event.getBall().getLocation().getZ() + z));
            entity.ballCornerBumper = 0;
        }
        entity.ballPreviousCacheLocation = event.getBall().getLocation().toVector();
        if (entity.blueTeam.contains(event.getPlayer())) {
            entity.lastHitTeam = Team.BLUE;
        } else {
            entity.lastHitTeam = Team.RED;
        }
        entity.lastHit = event.getPlayer();
    }
}
 
开发者ID:Shynixn,项目名称:BlockBall,代码行数:36,代码来源:GameListener.java

示例9: cloneWith

import org.bukkit.util.Vector; //导入方法依赖的package包/类
public static Location cloneWith(Location original, Vector position, float yaw, float pitch) {
    return new Location(original.getWorld(),
                        position.getX(),
                        position.getY(),
                        position.getZ(),
                        yaw,
                        pitch);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:9,代码来源:Locations.java

示例10: setVelocity

import org.bukkit.util.Vector; //导入方法依赖的package包/类
public void setVelocity(Vector vector) {
    ((CraftArmorStand)armorStand).getHandle().motX = vector.getX();
    ((CraftArmorStand)armorStand).getHandle().motY = vector.getY();
    ((CraftArmorStand)armorStand).getHandle().motZ = vector.getZ();
}
 
开发者ID:SamaGames,项目名称:AgarMC,代码行数:6,代码来源:Cell.java

示例11: setVelocity

import org.bukkit.util.Vector; //导入方法依赖的package包/类
public void setVelocity(Vector vel) {
    this.motX = vel.getX();
    this.motY = vel.getY();
    this.motZ = vel.getZ();
    this.velocityChanged = true;
}
 
开发者ID:Borlea,项目名称:EchoPet,代码行数:7,代码来源:EntityPet.java

示例12: fakeDelta

import org.bukkit.util.Vector; //导入方法依赖的package包/类
public static void fakeDelta(Player observer, Player victim, Vector delta) {
    Packet packet = new PacketPlayOutEntity.PacketPlayOutRelEntityMove(((CraftPlayer) victim).getHandle().getId(), (byte) (delta.getX() * 32), (byte) (delta.getY() * 32), (byte) (delta.getZ() * 32), false /* on ground */);

    sendPacket((CraftPlayer) observer, packet);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:6,代码来源:RocketUtils.java

示例13: doBlockDrops

import org.bukkit.util.Vector; //导入方法依赖的package包/类
/**
 * This is not an event handler. It is called explicitly by BlockTransformListener
 * after all event handlers have been called.
 */
@SuppressWarnings("deprecation")
public void doBlockDrops(final BlockTransformEvent event) {
    if(!causesDrops(event.getCause())) {
        return;
    }

    final BlockDrops drops = event.getDrops();
    if(drops != null) {
        event.setCancelled(true);
        final BlockState oldState = event.getOldState();
        final BlockState newState = event.getNewState();
        final Block block = event.getOldState().getBlock();
        final int newTypeId = newState.getTypeId();
        final byte newData = newState.getRawData();

        block.setTypeIdAndData(newTypeId, newData, true);

        boolean explosion = false;
        MatchPlayer player = ParticipantBlockTransformEvent.getParticipant(event);

        if(event.getCause() instanceof EntityExplodeEvent) {
            EntityExplodeEvent explodeEvent = (EntityExplodeEvent) event.getCause();
            explosion = true;

            if(drops.fallChance != null &&
               oldState.getType().isBlock() &&
               oldState.getType() != Material.AIR &&
               this.getMatch().getRandom().nextFloat() < drops.fallChance) {

                FallingBlock fallingBlock = event.getOldState().spawnFallingBlock();
                fallingBlock.setDropItem(false);

                if(drops.landChance != null && this.getMatch().getRandom().nextFloat() >= drops.landChance) {
                    this.fallingBlocksThatWillNotLand.add(fallingBlock);
                }

                Vector v = fallingBlock.getLocation().subtract(explodeEvent.getLocation()).toVector();
                double distance = v.length();
                v.normalize().multiply(BASE_FALL_SPEED * drops.fallSpeed / Math.max(1d, distance));

                // A very simple deflection model. Check for a solid
                // neighbor block and "bounce" the velocity off of it.
                Block west = block.getRelative(BlockFace.WEST);
                Block east = block.getRelative(BlockFace.EAST);
                Block down = block.getRelative(BlockFace.DOWN);
                Block up = block.getRelative(BlockFace.UP);
                Block north = block.getRelative(BlockFace.NORTH);
                Block south = block.getRelative(BlockFace.SOUTH);

                if((v.getX() < 0 && west != null && Materials.isColliding(west.getType())) ||
                    v.getX() > 0 && east != null && Materials.isColliding(east.getType())) {
                    v.setX(-v.getX());
                }

                if((v.getY() < 0 && down != null && Materials.isColliding(down.getType())) ||
                    v.getY() > 0 && up != null && Materials.isColliding(up.getType())) {
                    v.setY(-v.getY());
                }

                if((v.getZ() < 0 && north != null && Materials.isColliding(north.getType())) ||
                    v.getZ() > 0 && south != null && Materials.isColliding(south.getType())) {
                    v.setZ(-v.getZ());
                }

                fallingBlock.setVelocity(v);
            }
        }

        dropObjects(drops, player, newState.getLocation(), 1d, explosion);

    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:77,代码来源:BlockDropsMatchModule.java

示例14: fromVector

import org.bukkit.util.Vector; //导入方法依赖的package包/类
public static Vector3d fromVector(Vector vector)
{
	return new Vector3d(vector.getX(), vector.getY(), vector.getZ());
}
 
开发者ID:timtomtim7,项目名称:SparseBukkitAPI,代码行数:5,代码来源:BukkitUtils.java

示例15: launchProjectile

import org.bukkit.util.Vector; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public <T extends Projectile> T launchProjectile(Class<? extends T> projectile, Vector velocity) {
    net.minecraft.world.World world = ((CraftWorld) getWorld()).getHandle();
    net.minecraft.entity.Entity launch = null;

    if (Snowball.class.isAssignableFrom(projectile)) {
        launch = new net.minecraft.entity.projectile.EntitySnowball(world, getHandle());
    } else if (Egg.class.isAssignableFrom(projectile)) {
        launch = new net.minecraft.entity.projectile.EntityEgg(world, getHandle());
    } else if (EnderPearl.class.isAssignableFrom(projectile)) {
        launch = new net.minecraft.entity.item.EntityEnderPearl(world, getHandle());
    } else if (Arrow.class.isAssignableFrom(projectile)) {
        launch = new net.minecraft.entity.projectile.EntityArrow(world, getHandle(), 1);
    } else if (ThrownPotion.class.isAssignableFrom(projectile)) {
        launch = new net.minecraft.entity.projectile.EntityPotion(world, getHandle(), CraftItemStack.asNMSCopy(new ItemStack(Material.POTION, 1)));
    } else if (ThrownExpBottle.class.isAssignableFrom(projectile)) {
        launch = new net.minecraft.entity.item.EntityExpBottle(world, getHandle());
    } else if (Fish.class.isAssignableFrom(projectile) && getHandle() instanceof net.minecraft.entity.player.EntityPlayer) {
        launch = new net.minecraft.entity.projectile.EntityFishHook(world, (net.minecraft.entity.player.EntityPlayer) getHandle());
    } else if (Fireball.class.isAssignableFrom(projectile)) {
        Location location = getEyeLocation();
        Vector direction = location.getDirection().multiply(10);

        if (SmallFireball.class.isAssignableFrom(projectile)) {
            launch = new net.minecraft.entity.projectile.EntitySmallFireball(world, getHandle(), direction.getX(), direction.getY(), direction.getZ());
        } else if (WitherSkull.class.isAssignableFrom(projectile)) {
            launch = new net.minecraft.entity.projectile.EntityWitherSkull(world, getHandle(), direction.getX(), direction.getY(), direction.getZ());
        } else {
            launch = new net.minecraft.entity.projectile.EntityLargeFireball(world, getHandle(), direction.getX(), direction.getY(), direction.getZ());
        }

        ((net.minecraft.entity.projectile.EntityFireball) launch).projectileSource = this;
        launch.setLocationAndAngles(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
    }

    Validate.notNull(launch, "Projectile not supported");

    if (velocity != null) {
        ((T) launch.getBukkitEntity()).setVelocity(velocity);
    }

    world.spawnEntityInWorld(launch);
    return (T) launch.getBukkitEntity();
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:45,代码来源:CraftLivingEntity.java


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