Examples of Rails


Examples of graphics.model.rails.Rails

  private Rails rails;
  private ArrayList<Station> stations;
 
  public Map() {
    data = new char[mapHeight][mapWidth];
    rails = new Rails();
    stations = new ArrayList<>();
   
    //initialize map data
    for(int rows = 0; rows < mapHeight; rows++) {
      for(int cols = 0; cols < mapWidth; cols++) {
View Full Code Here

Examples of org.bukkit.material.Rails

        IntVector3 nextPos = pos.add(railTracker.getLastLogic().getDirection());
        Material type = WorldUtil.getBlockType(world, nextPos.x, nextPos.y, nextPos.z);
        int data = WorldUtil.getBlockData(world, nextPos);
        if (this.isRail(type, data)) {
          // Check that the direction of the rail is correct
          Rails rails = CommonUtil.tryCast(BlockUtil.getData(type, data), Rails.class);
          BlockFace lastDirection = railTracker.getLastLogic().getDirection();
          if (rails != null && rails.isOnSlope() && rails.getDirection() == lastDirection) {
            // We got a winner!
            // Some position and velocity adjustment prior to moving between the types
            CommonMinecart<?> entity = member.getEntity();
            entity.loc.xz.set(nextPos.x + 0.5, nextPos.z + 0.5);
            entity.loc.xz.subtract(lastDirection, 0.49);
            // Y offset
            final double transOffset = 0.01; // How high above the slope to teleport to
            entity.loc.setY(nextPos.y + transOffset);
            // Convert Y-velocity into XZ-velocity
            entity.vel.xz.add(rails.getDirection(), entity.vel.getY());
            entity.vel.y.setZero();
            return nextPos;
          }
        }
      }
View Full Code Here

Examples of org.bukkit.material.Rails

    }
  }

  @Override
  public Block getNextPos(Block currentTrack, BlockFace currentDirection) {
    Rails rail = BlockUtil.getRails(currentTrack);
    if (rail == null) {
      return null;
    }
    return getNextPos(currentTrack, currentDirection, rail.getDirection(), rail.isOnSlope());
  }
View Full Code Here

Examples of org.bukkit.material.Rails

    return getNextPos(currentTrack, currentDirection, rail.getDirection(), rail.isOnSlope());
  }

  @Override
  public BlockFace[] getPossibleDirections(Block trackBlock) {
    Rails rails = BlockUtil.getRails(trackBlock);
    return rails == null ? new BlockFace[0] : getPossibleDirections(rails.getDirection());
  }
View Full Code Here

Examples of org.bukkit.material.Rails

    return rails == null ? new BlockFace[0] : getPossibleDirections(rails.getDirection());
  }

  @Override
  public RailLogic getLogic(MinecartMember<?> member, Block railsBlock) {
    Rails rails = BlockUtil.getRails(railsBlock);
    if (rails == null) {
      return RailLogicGround.INSTANCE;
    }
    BlockFace direction = rails.getDirection();

    // Sloped logic
    if (rails.isOnSlope()) {
      // To vertical
      if (Util.isVerticalAbove(railsBlock, direction)) {
        return RailLogicVerticalSlopeDown.get(direction);
      }
      // Default
View Full Code Here

Examples of org.bukkit.material.Rails

    return RailLogicHorizontal.get(direction);
  }

  @Override
  public BlockFace getDirection(Block railsBlock) {
    Rails rails = BlockUtil.getRails(railsBlock);
    return rails == null ? BlockFace.SELF : rails.getDirection();
  }
View Full Code Here

Examples of org.bukkit.material.Rails

      Block next = currentTrack.getRelative(BlockFace.UP);
      if (!Util.ISTCRAIL.get(next)) {
        // Check for a possible sloped rail leading up from next
        BlockFace dir = Util.getVerticalRailDirection(currentTrack);
        Block possible = next.getRelative(dir);
        Rails rails = BlockUtil.getRails(possible);
        if (rails != null && rails.isOnSlope() && rails.getDirection() == dir) {
          return possible;
        }
      }
      return next;
    } else {
View Full Code Here

Examples of org.bukkit.material.Rails

      if (this.hasRails()) {
        if (FaceUtil.isVertical(this.getRailDirection())) {
          watchedFaces.add(BlockFace.UP);
          watchedFaces.add(BlockFace.DOWN);
        } else {
          Rails rails = BlockUtil.getRails(this.getRails());
          if (rails != null && rails.isOnSlope() && Util.isVerticalAbove(this.getRails(), rails.getDirection())) {
            watchedFaces.add(BlockFace.UP);
            watchedFaces.add(rails.getDirection().getOppositeFace());
          } else if (FaceUtil.isSubCardinal(this.getFacing())) {
            // More advanced corner checks - NE/SE/SW/NW
            // Use rail directions validated against sign facing to
            // find out what directions are watched
            BlockFace[] faces = FaceUtil.getFaces(this.getFacing());
View Full Code Here

Examples of org.bukkit.material.Rails

        } else if (type == heldItem.getType() && MaterialUtil.ISRAILS.get(type) && TrainCarts.allowRailEditing && clickInterval >= MAX_INTERACT_INTERVAL) {
          if (BlockUtil.canBuildBlock(clickedBlock, type)) {
            // Edit the rails to make a connection/face the direction the player clicked
            BlockFace direction = FaceUtil.getDirection(player.getLocation().getDirection(), false);
            BlockFace lastDirection = LogicUtil.fixNull(lastClickedDirection.get(player), direction);
            Rails rails = BlockUtil.getRails(clickedBlock);
            // First check whether we are clicking towards an up-slope block
            if (MaterialUtil.ISSOLID.get(clickedBlock.getRelative(direction))) {
              // Sloped logic
              if (rails.isOnSlope()) {
                if (rails.getDirection() == direction) {
                  // Switch between sloped and flat
                  rails.setDirection(direction, false);
                } else {
                  // Other direction slope
                  rails.setDirection(direction, true);
                }
              } else {
                // Set to slope
                rails.setDirection(direction, true);
              }
            } else if (type == Material.RAILS) {
              // This needs advanced logic for curves and everything!
              BlockFace[] faces = FaceUtil.getFaces(rails.getDirection());
              if (!LogicUtil.contains(direction.getOppositeFace(), faces)) {
                // Try to make a connection towards this point
                // Which of the two faces do we sacrifice?
                BlockFace otherFace = faces[0] == lastDirection.getOppositeFace() ? faces[0] : faces[1];
                rails.setDirection(FaceUtil.combine(otherFace, direction.getOppositeFace()), false);
              }
            } else {
              // Simple switching (straight tracks)
              rails.setDirection(direction, false);
            }
            // Update
            BlockUtil.setData(clickedBlock, rails);
            lastClickedDirection.put(player, direction);
          }
View Full Code Here

Examples of org.bukkit.material.Rails

    }
    // Obtain the vertical rail and the rail below it, if possible
    final Block vertRail = below.getRelative(BlockFace.UP);
    if (Util.ISVERTRAIL.get(vertRail)) {
      // Find and validate rails - only regular types are allowed
      Rails rails = BlockUtil.getRails(below);
      if (rails == null || rails.isCurve() || rails.isOnSlope()) {
        return false;
      }
      BlockFace railDir = rails.getDirection();
      BlockFace dir = Util.getVerticalRailDirection(vertRail);
      // No other directions going on for this rail?
      if (railDir != dir && railDir != dir.getOppositeFace()) {
        if (Util.getRailsBlock(below.getRelative(railDir)) != null) {
          return false;
        }
        if (Util.getRailsBlock(below.getRelative(railDir.getOppositeFace())) != null) {
          return false;
        }
      }

      // Direction we are about to connect is supported?
      if (MaterialUtil.SUFFOCATES.get(below.getRelative(dir))) {
        rails.setDirection(dir, true);
        BlockUtil.setData(below, rails);
      }
      return true;
    }
    return false;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.