下面列出了org.bukkit.util.Vector#getZ ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public Vector translateAndCollide(Vector vector, World world, int gameVersion) {
AABB preBox = this.clone();
preBox.expand(-0.0001, -0.0001, -0.0001);
List<AABB> collidedBlocksBefore = preBox.getBlockAABBs(world, gameVersion, Material.WEB);
double pdX = vector.getX();
double pdY = vector.getY();
double pdZ = vector.getZ();
AABB testBox = this.clone();
testBox.expand(-0.00000001, -0.00000001, -0.00000001);
pdX = moveOnAxis(testBox, pdX, 0, world, gameVersion, collidedBlocksBefore);
pdY = moveOnAxis(testBox, pdY, 1, world, gameVersion, collidedBlocksBefore);
pdZ = moveOnAxis(testBox, pdZ, 2, world, gameVersion, collidedBlocksBefore);
Vector move = new Vector(pdX, pdY, pdZ);
translate(move);
return move;
}
@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 Location getPoint(Match match, @Nullable Entity entity) {
Vector pos = this.region.getRandom(match.getRandom());
PointProviderLocation location =
new PointProviderLocation(match.getWorld(), pos.getX(), pos.getY(), pos.getZ());
if (attributes.getYawProvider() != null) {
location.setYaw(attributes.getYawProvider().getAngle(pos));
location.setHasYaw(true);
}
if (attributes.getPitchProvider() != null) {
location.setPitch(attributes.getPitchProvider().getAngle(pos));
location.setHasPitch(true);
}
location = makeSafe(location);
return location;
}
@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 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 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 teleportBoundingBox(Vector to, boolean onGround) {
int i = 0;
for (int x = -1; x < 2; x += 2) {
for (int z = -1; z < 2; z += 2) {
Packet teleportPacket = new PacketPlayOutEntityTeleport(zombieID.get(i),
to.getX() + (x * DamageIndicator.OFFSET), to.getY() , to.getZ() + (z * DamageIndicator.OFFSET),
(byte) 2, (byte) 0, onGround);
PacketUtils.broadcastPacketByUUID(teleportPacket, viewers);
i++;
}
}
}
public static Object particlesPacket(String name, boolean longRange, Vector pos, Vector offset, float data, int count, int... extra) {
return new PacketPlayOutWorldParticles(EnumParticle.valueOf(EnumParticle.class, name),
longRange,
(float) pos.getX(), (float) pos.getY(), (float) pos.getZ(),
(float) offset.getX(), (float) offset.getY(), (float) offset.getZ(),
data,
count,
extra);
}
@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 setVelocity(Vector vel) {
this.motX = vel.getX();
this.motY = vel.getY();
this.motZ = vel.getZ();
this.velocityChanged = true;
}
private void processDirection(InteractEntityEvent e, float yaw, float pitch) {
Entity entity = e.getEntity();
if (!(entity instanceof Player) && !CHECK_OTHER_ENTITIES)
return;
Player attacker = e.getPlayer();
int ping = ServerUtils.getPing(attacker);
if (ping > PING_LIMIT && PING_LIMIT != -1)
return;
HawkPlayer att = e.getHawkPlayer();
Location attackerEyeLocation = att.getPosition().clone().add(new Vector(0, 1.62, 0)).toLocation(att.getWorld());
Vector attackerDirection = MathPlus.getDirection(yaw, pitch);
double maxReach = MAX_REACH;
if (attacker.getGameMode() == GameMode.CREATIVE)
maxReach += 1.9;
Vector victimLocation;
if (LAG_COMPENSATION)
//No need to add 50ms; the move and attack are already chronologically so close together
victimLocation = hawk.getLagCompensator().getHistoryLocation(ping, e.getEntity()).toVector();
else
victimLocation = e.getEntity().getLocation().toVector();
Vector eyePos = new Vector(attackerEyeLocation.getX(), attacker.isSneaking() ? attackerEyeLocation.getY() - 0.08 : attackerEyeLocation.getY(), attackerEyeLocation.getZ());
Vector direction = new Vector(attackerDirection.getX(), attackerDirection.getY(), attackerDirection.getZ());
Ray attackerRay = new Ray(eyePos, direction);
AABB victimAABB;
victimAABB = WrappedEntity.getWrappedEntity(entity).getHitbox(victimLocation);
victimAABB.expand(BOX_EPSILON, BOX_EPSILON, BOX_EPSILON);
Vector intersectVec3d = victimAABB.intersectsRay(attackerRay, 0, Float.MAX_VALUE);
if (DEBUG_HITBOX) {
victimAABB.highlight(hawk, attacker.getWorld(), 0.29);
}
if (DEBUG_RAY) {
attackerRay.highlight(hawk, attacker.getWorld(), maxReach, 0.1);
}
if (intersectVec3d != null) {
Location intersect = new Location(attacker.getWorld(), intersectVec3d.getX(), intersectVec3d.getY(), intersectVec3d.getZ());
double interDistance = intersect.distance(attackerEyeLocation);
if (interDistance > maxReach) {
punish(att, 1, true, e, new Placeholder("type", "Reach: " + MathPlus.round(interDistance, 2) + "m"));
return;
}
if (CHECK_OCCLUSION && interDistance > 1D) {
BlockIterator iter = new BlockIterator(attacker.getWorld(), eyePos, attackerDirection, 0, (int) interDistance + 1);
while (iter.hasNext()) {
Block bukkitBlock = iter.next();
if (bukkitBlock.getType() == Material.AIR || bukkitBlock.isLiquid())
continue;
WrappedBlock b = WrappedBlock.getWrappedBlock(bukkitBlock, att.getClientVersion());
Vector intersection = b.getHitBox().intersectsRay(new Ray(attackerEyeLocation.toVector(), attackerDirection), 0, Float.MAX_VALUE);
if (intersection != null) {
if (intersection.distance(eyePos) < interDistance) {
punish(att, 1, true, e, new Placeholder("type", "Interacted through " + b.getBukkitBlock().getType()));
return;
}
}
}
}
} else if (CHECK_BOX_INTERSECTION) {
punish(att, 1, true, e, new Placeholder("type", "Did not hit hitbox."));
return;
}
reward(att); //reward player
}
public PointRegion(String name, Vector vector) {
this(name, vector.getX(), vector.getY(), vector.getZ());
}
public BlockVector blockAlign(Vector vector) {
return new BlockVector((int) vector.getX() + 0.5d, (int) vector.getY() + 0.5d, (int) vector.getZ() + 0.5d);
}
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.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.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));
}
}
/**
* Adds the location by a vector.
*
* @param vec Vector to use
* @return the same location
* @see Vector
*/
public Location add(Vector vec) {
this.x += vec.getX();
this.y += vec.getY();
this.z += vec.getZ();
return this;
}