org.bukkit.util.Vector#getX ( )源码实例Demo

下面列出了org.bukkit.util.Vector#getX ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: PGM   文件: RegionPointProvider.java
@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;
}
 
源代码2 项目: CardinalPGM   文件: HillObjective.java
private void renderBlocks() {
    if (progress == null) return;
    byte color1 = capturingTeam != null ? MiscUtil.convertChatColorToDyeColor(capturingTeam.getColor()).getWoolData() : -1;
    byte color2 = team != null ? MiscUtil.convertChatColorToDyeColor(team.getColor()).getWoolData() : -1;
    Vector center = progress.getCenterBlock().getVector();
    double x = center.getX();
    double z = center.getZ();
    double percent = Math.toRadians(getPercent() * 3.6);
    for(Block block : progress.getBlocks()) {
        if (!visualMaterials.evaluate(block).equals(FilterState.ALLOW)) continue;
        double dx = block.getX() - x;
        double dz = block.getZ() - z;
        double angle = Math.atan2(dz, dx);
        if(angle < 0) angle += 2 * Math.PI;
        byte color = angle < percent ? color1 : color2;
        if (color == -1) {
            Pair<Material,Byte> oldBlock = oldProgress.getBlockAt(new BlockVector(block.getLocation().position()));
            if (oldBlock.getLeft().equals(block.getType())) color = oldBlock.getRight();
        }
        if (color != -1) block.setData(color);
    }
}
 
源代码3 项目: EntityAPI   文件: ControllablePigZombieEntity.java
@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);
}
 
源代码4 项目: EntityAPI   文件: ControllableVillagerEntity.java
@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);
}
 
源代码5 项目: EntityAPI   文件: ControllableWitherEntity.java
@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);
}
 
源代码6 项目: EntityAPI   文件: ControllableCreeperEntity.java
@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);
}
 
源代码7 项目: CardinalPGM   文件: PlayerBoundingBox.java
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++;
        }
    }
}
 
源代码8 项目: EntityAPI   文件: ControllableEndermanEntity.java
@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);
}
 
源代码9 项目: EntityAPI   文件: ControllableZombieEntity.java
@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);
}
 
源代码10 项目: EntityAPI   文件: ControllablePlayerEntity.java
@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);
}
 
源代码11 项目: EntityAPI   文件: ControllableWolfEntity.java
@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);
}
 
源代码12 项目: EntityAPI   文件: ControllablePigZombieEntity.java
@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);
}
 
源代码13 项目: EntityAPI   文件: ControllableEnderDragonEntity.java
@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);
}
 
源代码14 项目: EntityAPI   文件: ControllableCaveSpiderEntity.java
@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);
}
 
源代码15 项目: EntityAPI   文件: ControllablePigEntity.java
@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);
}
 
源代码16 项目: Hawk   文件: MoveEvent.java
private Vector handlePendingVelocities() {
    List<Pair<Vector, Long>> kbs = pp.getPendingVelocities();
    if (kbs.size() > 0) {
        double epsilon = 0.003;
        int kbIndex;
        int expiredKbs = 0;
        long currTime = System.currentTimeMillis();
        Vector currVelocity = new Vector(getTo().getX() - getFrom().getX(), getTo().getY() - getFrom().getY(), getTo().getZ() - getFrom().getZ());
        boolean jump = pp.isOnGround() && Math.abs(0.42 - currVelocity.getY()) < 0.00001;
        double speedPotMultiplier = 1;
        for (PotionEffect effect : p.getActivePotionEffects()) {
            if (!effect.getType().equals(PotionEffectType.SPEED))
                continue;
            speedPotMultiplier = 1 + (effect.getAmplifier() + 1 * 0.2);
        }
        boolean flying          = pp.isFlying();
        double sprintMultiplier = flying ? (pp.isSprinting() ? 2 : 1) : (pp.isSprinting() ? 1.3 : 1);
        double weirdConstant    = (jump && pp.isSprinting() ? 0.2518462 : (pp.isSwimming() ? 0.0196 : 0.098)); //(pp.isOnGround() ? 0.098 : (flying ? 0.049 : 0.0196));
        double baseMultiplier   = flying ? (10 * p.getFlySpeed()) : (5 * p.getWalkSpeed() * speedPotMultiplier);
        double maxDiscrepancy   = weirdConstant * baseMultiplier * sprintMultiplier + epsilon;

        //pending knockbacks must be in order; get the first entry in the list.
        //if the first entry doesn't work (probably because they were fired on the same tick),
        //then work down the list until we find something
        for (kbIndex = 0; kbIndex < kbs.size(); kbIndex++) {
            Pair<Vector, Long> kb = kbs.get(kbIndex);

            //replace the following if-statement with this sometime? You'll have to worry about the else-statement, though.
            //int timeDiff = (int)(currTime - kb.getValue());
            //int ping = ServerUtils.getPing(p);
            //int lowerBound = 100;
            //int upperBound = 300;
            //if (timeDiff >= ping - lowerBound && timeDiff <= ping + upperBound) { //400ms window to allow for network jitter

            if (currTime - kb.getValue() <= ServerUtils.getPing(p) + 200) { //add 200 just in case the player's ping jumps a bit

                Vector kbVelocity = kb.getKey();
                double x = hitSlowdown ? 0.6 * kbVelocity.getX() : kbVelocity.getX();
                double y = kbVelocity.getY();
                double z = hitSlowdown ? 0.6 * kbVelocity.getZ() : kbVelocity.getZ();

                //check Y component
                //skip to next kb if...
                if (!((boxSidesTouchingBlocks.contains(Direction.TOP) && y > 0) || (boxSidesTouchingBlocks.contains(Direction.BOTTOM) && y < 0)) && /*...player isn't colliding...*/
                        Math.abs(y - currVelocity.getY()) > 0.01 && /*...and velocity is nowhere close to kb velocity...*/
                        !jump && !pp.isSwimming() && !step /*...and did not jump and is not swimming and did not "step"*/) {
                    continue;
                }

                double minThresX = x - maxDiscrepancy;
                double maxThresX = x + maxDiscrepancy;
                double minThresZ = z - maxDiscrepancy;
                double maxThresZ = z + maxDiscrepancy;

                //check X component
                //skip to next kb if...
                if (!((boxSidesTouchingBlocks.contains(Direction.EAST) && x > 0) || (boxSidesTouchingBlocks.contains(Direction.WEST) && x < 0)) && /*...player isn't colliding...*/
                        !(currVelocity.getX() <= maxThresX && currVelocity.getX() >= minThresX)) { /*...and velocity is nowhere close to kb velocity...*/
                    continue;
                }
                //check Z component
                //skip to next kb if...
                if (!((boxSidesTouchingBlocks.contains(Direction.SOUTH) && z > 0) || (boxSidesTouchingBlocks.contains(Direction.NORTH) && z < 0)) && /*...player isn't colliding...*/
                        !(currVelocity.getZ() <= maxThresZ && currVelocity.getZ() >= minThresZ)) { /*...and velocity is nowhere close to kb velocity...*/
                    continue;
                }
                kbs.subList(0, kbIndex + 1).clear();
                return kbVelocity;
            }
            else {
                failedKnockback = true;
                expiredKbs++;
            }
        }
        kbs.subList(0, expiredKbs).clear();
    }
    return null;
}
 
源代码17 项目: PGM   文件: Portal.java
protected Location cloneWith(Location original, Vector position, float yaw, float pitch) {
  return new Location(
      original.getWorld(), position.getX(), position.getY(), position.getZ(), yaw, pitch);
}
 
源代码18 项目: EchoPet   文件: EntityPet.java
public void setVelocity(Vector vel) {
    this.motX = vel.getX();
    this.motY = vel.getY();
    this.motZ = vel.getZ();
    this.velocityChanged = true;
}
 
源代码19 项目: SonarPet   文件: EntityInsentientPet.java
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;
    });
}
 
源代码20 项目: Kettle   文件: Location.java
/**
 * Subtracts the location by a vector.
 *
 * @param vec The vector to use
 * @return the same location
 * @see Vector
 */
public Location subtract(Vector vec) {
    this.x -= vec.getX();
    this.y -= vec.getY();
    this.z -= vec.getZ();
    return this;
}