下面列出了org.bukkit.util.Vector#getY ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void move(Vector to) {
checkNotNull(to, "The Vector object in HologramImpl#move(Vector) is null");
this.defX = to.getX();
this.defY = to.getY();
this.defZ = to.getZ();
if (!this.isSimple()) {
HoloAPI.getManager().saveToFile(this);
}
for (String ident : this.getPlayerViews().keySet()) {
Player p = IdentUtil.getPlayerOf(ident);
if (p != null) {
this.move(p, to);
}
}
}
@Override
public void g(double x, double y, double z) {
if (this.controllableEntity != null) {
Vector velocity = this.controllableEntity.getMind().getAttribute(PushAttribute.class).call(this.controllableEntity, new Vector(x, y, z)).getPushVelocity();
x = velocity.getX();
y = velocity.getY();
z = velocity.getZ();
}
super.g(x, y, z);
}
@Override
public void g(double x, double y, double z) {
if (this.controllableEntity != null) {
Vector velocity = this.controllableEntity.getMind().getAttribute(PushAttribute.class).call(this.controllableEntity, new Vector(x, y, z)).getPushVelocity();
x = velocity.getX();
y = velocity.getY();
z = velocity.getZ();
}
super.g(x, y, z);
}
@Override
public void g(double x, double y, double z) {
if (this.controllableEntity != null) {
Vector velocity = this.controllableEntity.getMind().getAttribute(PushAttribute.class).call(this.controllableEntity, new Vector(x, y, z)).getPushVelocity();
x = velocity.getX();
y = velocity.getY();
z = velocity.getZ();
}
super.g(x, y, z);
}
static boolean isInside(Vector point, Location blockLocation) {
return blockLocation.getX() <= point.getX()
&& point.getX() <= blockLocation.getX() + 1
&& blockLocation.getY() <= point.getY()
&& point.getY() <= blockLocation.getY() + 1
&& blockLocation.getZ() <= point.getZ()
&& point.getZ() <= blockLocation.getZ() + 1;
}
@Override
public void g(double x, double y, double z) {
if (this.controllableEntity != null) {
Vector velocity = this.controllableEntity.getMind().getAttribute(PushAttribute.class).call(this.controllableEntity, new Vector(x, y, z)).getPushVelocity();
x = velocity.getX();
y = velocity.getY();
z = velocity.getZ();
}
super.g(x, y, z);
}
@Override
public void g(double x, double y, double z) {
if (this.controllableEntity != null) {
Vector velocity = this.controllableEntity.getMind().getAttribute(PushAttribute.class).call(this.controllableEntity, new Vector(x, y, z)).getPushVelocity();
x = velocity.getX();
y = velocity.getY();
z = velocity.getZ();
}
super.g(x, y, z);
}
@Override
public void g(double x, double y, double z) {
if (this.controllableEntity != null) {
Vector velocity = this.controllableEntity.getMind().getAttribute(PushAttribute.class).call(this.controllableEntity, new Vector(x, y, z)).getPushVelocity();
x = velocity.getX();
y = velocity.getY();
z = velocity.getZ();
}
super.g(x, y, z);
}
@Override
public void onRun() {
Location location = getLocation();
if (world == null) {
world = location.getWorld();
} else if (!location.getWorld().equals(world)) {
cancel(true);
return;
}
synchronized(wayPoints)
{
if (wayPoints.size() >= maxWayPoints) {
wayPoints.remove(0);
}
}
wayPoints.add(location.toVector());
step++;
if (step % refresh != 0) {
return;
}
synchronized(wayPoints)
{
for (Vector position : wayPoints) {
Location particleLocation = new Location(world, position.getX(), position.getY(), position.getZ());
display(particle, particleLocation);
}
}
}
public static Vector rotateAroundXAxis(Vector vector, double angle) {
double cos = cos(angle);
double sin = sin(angle);
double y = vector.getY() * cos - vector.getZ() * sin;
double z = vector.getY() * sin + vector.getZ() * cos;
return vector.setY(y).setZ(z);
}
@Override
public void g(double x, double y, double z) {
if (this.controllableEntity != null) {
Vector velocity = this.controllableEntity.getMind().getAttribute(PushAttribute.class).call(this.controllableEntity, new Vector(x, y, z)).getPushVelocity();
x = velocity.getX();
y = velocity.getY();
z = velocity.getZ();
}
super.g(x, y, z);
}
@Override
public void g(double x, double y, double z) {
if (this.controllableEntity != null) {
Vector velocity = this.controllableEntity.getMind().getAttribute(PushAttribute.class).call(this.controllableEntity, new Vector(x, y, z)).getPushVelocity();
x = velocity.getX();
y = velocity.getY();
z = velocity.getZ();
}
super.g(x, y, z);
}
@Override
public void g(double x, double y, double z) {
if (this.controllableEntity != null) {
Vector velocity = this.controllableEntity.getMind().getAttribute(PushAttribute.class).call(this.controllableEntity, new Vector(x, y, z)).getPushVelocity();
x = velocity.getX();
y = velocity.getY();
z = velocity.getZ();
}
super.g(x, y, z);
}
public void setDirection(Vector direction) {
Validate.notNull(direction, "Direction can not be null");
double x = direction.getX();
double y = direction.getY();
double z = direction.getZ();
double magnitude = (double) MathHelper.sqrt_double(x * x + y * y + z * z);
getHandle().accelerationX = x / magnitude;
getHandle().accelerationY = y / magnitude;
getHandle().accelerationZ = z / magnitude;
}
public void setVelocity(Vector vel) {
this.motX = vel.getX();
this.motY = vel.getY();
this.motZ = vel.getZ();
this.velocityChanged = true;
}
public void onLive() {
if (this.pet == null) {
this.remove(false);
return;
}
if (this.getPlayerOwner() == null || !this.getPlayerOwner().isOnline() || Bukkit.getPlayerExact(this.getPlayerOwner().getName()) == null) {
EchoPet.getManager().removePet(this.getPet(), true);
return;
}
if (pet.isOwnerRiding() && this.passenger == null && !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())) {
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));
}
}
public void onLive() {
if (this.getPet() == null) {
this.remove(false);
return;
}
if (this.getPlayerOwner() == null || !this.getPlayerOwner().isOnline()) {
EchoPet.getManager().removePet(this.getPet(), true);
return;
}
if (getPet().isOwnerRiding() && getEntity().getPassengers().isEmpty() && !getPet().isOwnerInMountingProcess()) {
getPet().ownerRidePet(false);
}
if (getPlayerEntity().isInvisible() != getEntity().isInvisible() && !shouldVanish) {
getEntity().setInvisible(!getEntity().isInvisible());
}
if (getPlayerEntity().isSneaking() != getEntity().isSneaking()) {
getEntity().setSneaking(!getEntity().isSneaking());
}
if (getPlayerEntity().isSprinting() != getEntity().isSprinting()) {
getEntity().setSprinting(!getEntity().isSprinting());
}
if (this.getPet().isHat()) {
getEntity().setYaw(this.getPet().getPetType() == PetType.ENDERDRAGON ? this.getPlayerOwner().getLocation().getYaw() - 180 : this.getPlayerOwner().getLocation().getYaw());
}
if (this.getPlayerOwner().isFlying() && EchoPet.getOptions().canFly(this.getPet().getPetType())) {
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;
}
getBukkitEntity().setVelocity(new Vector(x, y, z).normalize().multiply(0.3F));
}
ImmutableSet<NMSEntity> passengers = ImmutableSet.copyOf(getEntity().getPassengers());
if (passengers.isEmpty()) {
petGoalSelector.updateGoals();
}
// Check for mounts
for (NMSEntity passenger : passengers) {
if (!knownMountedEntities.contains(passenger)) {
onMounted(passenger);
knownMountedEntities.add(passenger);
}
}
// Check for dismounts
knownMountedEntities.removeIf((entity) -> {
if (!passengers.contains(entity)) {
onDismounted(entity);
return true;
}
return false;
});
}
@Override
public Number convert(Vector v) {
return axis == 0 ? v.getX() : (axis == 1 ? v.getY() : v.getZ());
}
/**
* Calculates the time needed to place one block.
*/
private static double calculateDelay(Integer jumpBoostLevel, Integer levitationLevel)
{
if (levitationLevel != null) {
// 0.9 Blocks per second per levitation level.
return 900 / ((levitationLevel + 1D) * TOWER_LENIENCY * LEVITATION_LENIENCY);
}
// No JUMP_BOOST
if (jumpBoostLevel == null) {
return AMPLIFIER_CACHE.get(0);
}
// Player has JUMP_BOOST
if (jumpBoostLevel < 0) {
// Negative JUMP_BOOST -> Not allowed to place blocks -> Very high delay
return 1500;
}
if (jumpBoostLevel + 1 < AMPLIFIER_CACHE.size()) {
return AMPLIFIER_CACHE.get(jumpBoostLevel + 1);
}
// The velocity in the beginning
Vector currentVelocity = new Vector(0, Jumping.getJumpYMotion(jumpBoostLevel), 0);
// The first tick (1) happens here
double currentBlockValue = currentVelocity.getY();
// Start the tick-loop at 2 due to the one tick outside.
for (short ticks = 2; ticks < 160; ticks++) {
currentVelocity = Gravitation.applyGravitationAndAirResistance(currentVelocity, Gravitation.PLAYER);
// Break as the player has already reached the max height (no more blocks to place below).
if (currentVelocity.getY() <= 0) {
// If the result is lower here, the detection is more lenient.
// * 50 : Convert ticks to milliseconds
// 0.925 is additional leniency
// Deliberately ignore the "falling" phase above the last block to increase leniency and code simplicity
return ((ticks * 50) / Math.floor(currentBlockValue)) * 0.925 * TOWER_LENIENCY;
}
currentBlockValue += currentVelocity.getY();
}
// Too high movement; no checking
return 0;
}
/**
* Check if the given Vector lies within this Bounding Box
*
* @param vector the vector which may or may not be in this Bounding Box
*
* @return true when the vector is inside this Bounding Box, false when not
*/
public boolean isVectorInside(Vector vector)
{
return !(vector.getX() <= this.minX || vector.getX() >= this.maxX) &&
!(vector.getY() <= this.minY || vector.getY() >= this.maxY) &&
(vector.getZ() > this.minZ || vector.getZ() < this.maxZ);
}