Package org.bukkit.util

Examples of org.bukkit.util.Vector


    RailLogic logic = member.getRailTracker().getLastLogic();
    IntVector3 lastRailPos = new IntVector3(member.getRailTracker().getLastBlock());

    // Get from and to rail-fixed positions
    Vector startVector = logic.getFixedPosition(entity, entity.last, lastRailPos);
    Vector endVector = getFixedPosition(entity, entity.loc, member.getBlockPos());

    // Update fixed Y-position
    entity.setPosition(entity.loc.getX(), endVector.getY(), entity.loc.getZ());

    // Apply velocity factors from going up/down the slope
    if (member.getGroup().getProperties().isSlowingDown()) {
      final double motLength = entity.vel.xz.length();
      if (motLength > 0) {
        entity.vel.xz.multiply((startVector.getY() - endVector.getY()) * 0.05 / motLength + 1.0);
      }
    }
  }
View Full Code Here


    }
  }

  @Override
  public Vector getFixedPosition(CommonMinecart<?> entity, double x, double y, double z, IntVector3 railPos) {
    Vector pos = super.getFixedPosition(entity, x, y, z, railPos);
    // Adjust the Y-position to match this rail
    double stage = 0.0;
    if (alongZ) {
      stage = z - (double) railPos.z;
    } else if (alongX) {
      stage = x - (double) railPos.x;
    }
    pos.setY(railPos.midY() + startY + dy * stage);
    return pos;
  }
View Full Code Here

      double factor = 2.0 * (this.dx * (entity.loc.getX() - newLocX) + this.dz * (entity.loc.getZ() - newLocZ));
      newLocX += factor * this.dx;
      newLocZ += factor * this.dz;
    }
    // Calculate the Y-position
    return new Vector(newLocX, newLocY, newLocZ);
  }
View Full Code Here

    if (member.isMovementControlled()) {
      // Be sure to use the direction, we are being controlled!
      super.setForwardVelocity(member, force);
    } else {
      // Simply set vector length
      Vector vel = member.getEntity().vel.vector();
      MathUtil.setVectorLength(vel, force);
      member.getEntity().vel.set(vel);
    }
  }
View Full Code Here

    return true;
  }

  @Override
  public Vector getFixedPosition(CommonMinecart<?> entity, double x, double y, double z, IntVector3 railPos) {
    return new Vector(x, y, z);
  }
View Full Code Here

    return true;
  }

  @Override
  public Vector getFixedPosition(CommonMinecart<?> entity, double x, double y, double z, IntVector3 railPos) {
    return new Vector(x, y, z);
  }
View Full Code Here

        // Spawn new item for this item stack
        Random random = WorldUtil.getRandom(this.location.getWorld());
        Location spawnLoc = this.location.clone().add(-0.45, -0.45, -0.45);
        spawnLoc = spawnLoc.add(0.9f * random.nextFloat(), 0.9f * random.nextFloat(), 0.9f * random.nextFloat());
        Item item = location.getWorld().dropItem(spawnLoc, stack);
        item.setVelocity(new Vector(0, 0, 0));
        this.items.add(item);
      }
    } else {
      // Set item stack, if null, kill the item
      Item item = this.items.get(index);
View Full Code Here

    if (this.isUnloaded()) {
      max = entity.getMaxSpeed();
    } else {
      max = this.getGroup().getProperties().getSpeedLimit();
    }
    return new Vector(entity.vel.x.getClamped(max), entity.vel.y.getClamped(max), entity.vel.z.getClamped(max));
  }
View Full Code Here

    float lookat = MathUtil.getLookAtYaw(this.entity.getEntity(), entity) - yaw;
    lookat = MathUtil.wrapAngle(lookat);
    if (lookat > 0) {
      yaw -= 180;
    }
    Vector vel = MathUtil.getDirection(yaw, 0).multiply(force);
    entity.setVelocity(vel);
  }
View Full Code Here

    }
    Vector vel = MathUtil.getDirection(yaw, 0).multiply(force);
    entity.setVelocity(vel);
  }
  public void push(org.bukkit.entity.Entity entity, double force) {
    Vector offset = this.entity.loc.offsetTo(entity);
    MathUtil.setVectorLength(offset, force);
    entity.setVelocity(entity.getVelocity().add(offset));
  }
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.