Package org.bukkit.util

Examples of org.bukkit.util.Vector


        if (zone == null) {
          return;
        }
        Location tntPlace = new Location(loc.getWorld(), loc.getX(), Warzone.getZoneByLocation(loc).getVolume().getMaxY(), loc.getZ());
        loc.getWorld().spawnEntity(tntPlace, EntityType.PRIMED_TNT);
        loc.getWorld().spawnEntity(tntPlace.clone().add(new Vector(2, 0, 0)), EntityType.PRIMED_TNT);
        loc.getWorld().spawnEntity(tntPlace.clone().add(new Vector(-2, 0, 0)), EntityType.PRIMED_TNT);
        loc.getWorld().spawnEntity(tntPlace.clone().add(new Vector(0, 0, 2)), EntityType.PRIMED_TNT);
        loc.getWorld().spawnEntity(tntPlace.clone().add(new Vector(0, 0, -2)), EntityType.PRIMED_TNT);
      }
    }
  }
View Full Code Here


      if (BuildParameters.debugLevel > 0){
        try{
          // TODO: Check backwards compatibility (1.4.2). Remove try-catch
          builder.append("\n(walkspeed=" + player.getWalkSpeed() + " flyspeed=" + player.getFlySpeed() + ")");
        } catch (Throwable t){}
        final Vector v = player.getVelocity();
        builder.append("(svel=" + v.getX() + "," + v.getY() + "," + v.getZ() + ")");
        if (player.isSprinting()){
          builder.append("(sprinting)");
        }
        if (player.isSneaking()){
          builder.append("(sneaking)");
View Full Code Here

        final double dY = dRef.getY();
        if (pY <= dY); // Keep the foot level y.
        else if (pY >= dY + height) dRef.setY(dY + height); // Highest ref y.
        else dRef.setY(pY); // Level with damaged.
       
        final Vector pRel = dRef.toVector().subtract(pLoc.toVector().setY(pY)); // TODO: Run calculations on numbers only :p.
       
        // Distance is calculated from eye location to center of targeted. If the player is further away from their target
        // than allowed, the difference will be assigned to "distance".
        final double lenpRel = pRel.length();
       
        double violation = lenpRel - distanceLimit;
       
        final double reachMod = data.reachMod;
View Full Code Here

        final int tick = TickTask.getTick();
        data.removeInvalidVelocity(tick  - cc.velocityActivationTicks);


        final Vector velocity = event.getVelocity();

        if (cc.debug) {
            System.out.println(event.getPlayer().getName() + " new velocity: " + velocity);
        }

        double newVal = velocity.getY();
        boolean used = false;
        if (newVal >= 0D) { // TODO: Just >, not >=.
            used = true;
            if (data.verticalFreedom <= 0.001 && data.verticalVelocityCounter >= 0) {
                data.verticalVelocity = 0;
            }
            data.verticalVelocity += newVal;
            data.verticalFreedom += data.verticalVelocity;
            data.verticalVelocityCounter = Math.min(100, Math.max(data.verticalVelocityCounter, cc.velocityGraceTicks ) + 1 + (int) Math.round(newVal * 10.0)); // 50;
            data.verticalVelocityUsed = 0;
        }

        newVal = Math.sqrt(velocity.getX() * velocity.getX() + velocity.getZ() * velocity.getZ());
        if (newVal > 0D) {
            used = true;
            final Velocity vel = new Velocity(tick, newVal, cc.velocityActivationCounter, Math.max(201 + (int) Math.round(newVal * 10.0)));
            data.addHorizontalVelocity(vel);
            //            data.horizontalFreedom += newVal;
View Full Code Here

        boolean cancel = false;

        // How far "off" is the player with their aim. We calculate from the players eye location and view direction to
        // the center of the target block. If the line of sight is more too far off, "off" will be bigger than 0.
        final Location loc = player.getLocation(useLoc);
        final Vector direction = loc.getDirection();
        double off = TrigUtil.directionCheck(loc, player.getEyeHeight(), direction, against, TrigUtil.DIRECTION_PRECISION);

        // Now check if the player is looking at the block from the correct side.
        double off2 = 0.0D;

        // Find out against which face the player tried to build, and if they
        // stood on the correct side of it
        if (placed.getX() > against.getX())
            off2 = against.getX() + 0.5D - loc.getX();
        else if (placed.getX() < against.getX())
            off2 = -(against.getX() + 0.5D - loc.getX());
        else if (placed.getY() > against.getY())
            off2 = against.getY() + 0.5D - loc.getY() - player.getEyeHeight();
        else if (placed.getY() < against.getY())
            off2 = -(against.getY() + 0.5D - loc.getY() - player.getEyeHeight());
        else if (placed.getZ() > against.getZ())
            off2 = against.getZ() + 0.5D - loc.getZ();
        else if (placed.getZ() < against.getZ())
            off2 = -(against.getZ() + 0.5D - loc.getZ());

        // If they weren't on the correct side, add that to the "off" value
        if (off2 > 0.0D)
            off += off2;

        if (off > 0.1D) {
            // Player failed the check. Let's try to guess how far they were from looking directly to the block...
            final Vector blockEyes = new Vector(0.5 + placed.getX() - loc.getX(), 0.5 + placed.getY() - loc.getY() - player.getEyeHeight(), 0.5 + placed.getZ() - loc.getZ());
            final double distance = blockEyes.crossProduct(direction).length() / direction.length();

            // Add the overall violation level of the check.
            data.directionVL += distance;

            // Execute whatever actions are associated with this check and the violation level and find out if we should
View Full Code Here

  public float getPitch() {
    return pitch;
  }

  public Vector getVector() {
    return new Vector(x, y, z);
  }
View Full Code Here

  /**
   * Convert this instance to an equivalent real 3D vector.
   * @return Real 3D vector.
   */
  public Vector toVector() {
    return new Vector(x, y, z);
  }
View Full Code Here

        // Horizontal velocity components
        double vx = vh * dirx;
        double vz = vh * dirz;

        return new Vector(vx, vy, vz);
    }
View Full Code Here

        return dx * dx + dz * dz;
    }

    public static Vector spread(Vector from, double yaw, double pitch) {
        Vector vec = from.clone();

        float cosyaw = (float)Math.cos(yaw);
        float cospitch = (float)Math.cos(pitch);
        float sinyaw = (float)Math.sin(yaw);
        float sinpitch = (float)Math.sin(pitch);
        float bX = (float) (vec.getY() * sinpitch + vec.getX() * cospitch);
        float bY = (float) (vec.getY() * cospitch - vec.getX() * sinpitch);
        return new Vector(bX * cosyaw - vec.getZ() * sinyaw, bY, bX * sinyaw + vec.getZ() * cosyaw);
    }
View Full Code Here

        this.compound.setInt("XpTotal", input);
        if(this.autosave) savePlayerData();
    }
    public Vector getVelocity() {
        NBTTagList list = this.compound.getList("Motion", 6);
        return new Vector(list.d(0), list.d(1), list.d(2));
    }
View Full Code Here

TOP

Related Classes of org.bukkit.util.Vector

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.