本文整理汇总了Java中org.bukkit.util.Vector.getZ方法的典型用法代码示例。如果您正苦于以下问题:Java Vector.getZ方法的具体用法?Java Vector.getZ怎么用?Java Vector.getZ使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.util.Vector
的用法示例。
在下文中一共展示了Vector.getZ方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: splitTeleportMob
import org.bukkit.util.Vector; //导入方法依赖的package包/类
/**
* Teleport a {@link FakeMob} to a specific {@link Location} in certain intervals, which is visible for all Players
*
* @param p the {@link Player} to teleport the {@link FakeMob} for
* @param to the {@link Location} where the {@link FakeMob} 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 mob the {@link FakeMob} which should be teleported
*/
public static void splitTeleportMob(final Player p, final Location to, final int teleportCount, final long wait, final FakeMob mob) {
final Location currentLocation = mob.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)) {
teleportMob(p, currentLocation.add(new Vector(toMoveInX, toMoveInY, toMoveInZ)), mob);
} else
this.cancel();
}
}.runTaskTimer(AlphaLibary.getInstance(), 0, wait));
}
示例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;
}
示例3: 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;
}
示例4: 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));
}
示例5: 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));
}
示例6: cloneWith
import org.bukkit.util.Vector; //导入方法依赖的package包/类
public static Location cloneWith(Location original, Vector position) {
return new Location(original.getWorld(),
position.getX(),
position.getY(),
position.getZ(),
original.getYaw(),
original.getPitch());
}
示例7: run
import org.bukkit.util.Vector; //导入方法依赖的package包/类
/**
* This method needs to be called very often
*/
@Override
public void run() {
// ** Virus Cells **//
for (VirusCell virus : AgarMC.get().getGame().getVirus()) {
if (virus.isInvinsible()) continue;
for (StaticCell cell : AgarMC.get().getGame().getStaticCells()) {
if (cell.getMass() > 1 && virus.getMass() > cell.getMass() && Math.sqrt(Math.pow(virus.getX() - cell.getX(), 2) + Math.pow(virus.getY() - cell.getY(), 2)) < virus.getRadius() - cell.getRadius()) {
virus.increaseMass(cell.getMass());
AgarMC.get().getGame().removeStaticCell(cell);
if (virus.getMass() > 60) {
virus.setMass(27);
Vector vector = cell.getVelocity().normalize().multiply(3);
if (vector.getX() < 0.001F && vector.getZ() < 0.001F) {
vector = Utils.getDirection(cell.getX(), cell.getY(), virus.getX(), virus.getY()).multiply(3);
}
final VirusCell newVirus = new VirusCell(virus.getX(), virus.getY());
newVirus.setInvinsible(true);
AgarMC.get().getServer().getScheduler().runTaskLater(AgarMC.get(), () -> newVirus.setInvinsible(false), 10L);
newVirus.setVelocity(vector);
AgarMC.get().getGame().addVirus(newVirus);
}
}
}
}
}
示例8: rotateAroundAxisY
import org.bukkit.util.Vector; //导入方法依赖的package包/类
public static Vector rotateAroundAxisY(Vector v, double angle)
{
double x, z, cos, sin;
cos = Math.cos(angle);
sin = Math.sin(angle);
x = v.getX() * cos + v.getZ() * sin;
z = v.getX() * -sin + v.getZ() * cos;
return v.setX(x).setZ(z);
}
示例9: 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;
}
示例10: onLive
import org.bukkit.util.Vector; //导入方法依赖的package包/类
public void onLive(){
if(this.pet == null){
this.remove(false);
return;
}
if(this.getPlayerOwner() == null || !this.getPlayerOwner().isOnline()){
EchoPet.getManager().removePet(this.getPet(), true);
return;
}
if(pet.isOwnerRiding() && this.passengers.size() == 0 && !pet.isOwnerInMountingProcess()){
pet.ownerRidePet(false);
}
if(((CraftPlayer) this.getPlayerOwner()).getHandle().isInvisible() != this.isInvisible() && !this.shouldVanish){
this.setInvisible(!this.isInvisible());
}
if(((CraftPlayer) this.getPlayerOwner()).getHandle().isSneaking() != this.isSneaking()){
this.setSneaking(!this.isSneaking());
}
if(((CraftPlayer) this.getPlayerOwner()).getHandle().isSprinting() != this.isSprinting()){
this.setSprinting(!this.isSprinting());
}
if(this.getPet().isHat()){
this.lastYaw = this.yaw = (this.getPet().getPetType() == PetType.ENDERDRAGON ? this.getPlayerOwner().getLocation().getYaw() - 180 : this.getPlayerOwner().getLocation().getYaw());
}
if(this.getPlayerOwner().isFlying() && EchoPet.getOptions().canFly(this.getPet().getPetType())){
// if(this.getEntityPetType() == PetType.VEX && !((IVexPet) this.getPet()).isPowered()) return;
Location petLoc = this.getLocation();
Location ownerLoc = this.getPlayerOwner().getLocation();
Vector v = ownerLoc.toVector().subtract(petLoc.toVector());
double x = v.getX();
double y = v.getY();
double z = v.getZ();
Vector vo = this.getPlayerOwner().getLocation().getDirection();
if(vo.getX() > 0){
x -= 1.5;
}else if(vo.getX() < 0){
x += 1.5;
}
if(vo.getZ() > 0){
z -= 1.5;
}else if(vo.getZ() < 0){
z += 1.5;
}
this.setVelocity(new Vector(x, y, z).normalize().multiply(0.3F));
}
}
示例11: getCenter
import org.bukkit.util.Vector; //导入方法依赖的package包/类
@Override
public Location getCenter() {
Vector v = getMin().toVector().getMidpoint(getMax().toVector());
return new Location(world, v.getX(), v.getY(), v.getZ());
}
示例12: 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;
}
示例13: forChunk
import org.bukkit.util.Vector; //导入方法依赖的package包/类
public static Region forChunk(Chunk chunk) {
Vector min = new Vector(chunk.getX() * 16, 0, chunk.getZ() * 16);
return new CuboidRegion(min, new Vector(min.getX() + 16, 256, min.getZ() + 16));
}
示例14: 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();
return (float) Math.toDegrees(Math.atan2(-dx, dz));
}
示例15: addVelocity
import org.bukkit.util.Vector; //导入方法依赖的package包/类
public void addVelocity(Vector vector) {
Vector vector2 = armorStand.getVelocity().add(vector);
((CraftArmorStand)armorStand).getHandle().motX = vector2.getX();
((CraftArmorStand)armorStand).getHandle().motY = vector2.getY();
((CraftArmorStand)armorStand).getHandle().motZ = vector2.getZ();
}