Package org.spout.api.material.block

Examples of org.spout.api.material.block.BlockFace


   * @param bedBlock the top or bottom bed block
   * @param head whether to get the top block, if false, gets the bottom block
   * @return the requested bed half block
   */
  private Block getCorrectHalf(Block bedBlock, boolean head) {
    BlockFace facing = getFacing(bedBlock);
    if (bedBlock.isDataBitSet(0x8)) {
      if (!head) {
        bedBlock = bedBlock.translate(facing.getOpposite());
      }
    } else {
      if (head) {
        bedBlock = bedBlock.translate(facing);
      }
View Full Code Here


  }

  @Override
  public void onDynamicUpdate(Block block, long updateTime, int data) {
    if (this.isToggled(block)) {
      BlockFace direction = getAttachedFace(block).getOpposite();
      this.setToggled(block, false);
      block = VanillaMaterials.TRIPWIRE.findHook(block, direction);
      if (block != null) {
        this.setToggled(block, false);
      }
View Full Code Here

  }

  @Override
  public void onPlacement(Block block, short data, BlockFace against, Vector3f clickedPos, boolean isClickedBlock, Cause<?> cause) {
    super.onPlacement(block, data, against, clickedPos, isClickedBlock, cause);
    BlockFace facing;
    if (cause instanceof EntityCause) {
      facing = PlayerUtil.getFacing(cause).getOpposite();
    } else {
      facing = BlockFace.EAST;
      for (BlockFace face : BlockFaces.EWNS) {
        if (block.translate(face).getMaterial().isOpaque()
            && !block.translate(face.getOpposite()).getMaterial().isOpaque()) {
          facing = face.getOpposite();
        }
      }
    }
    // search for neighbor and align
    Block neigh;
    for (BlockFace face : BlockFaces.NESW) {
      if ((neigh = block.translate(face)).getMaterial().equals(this)) {
        if (face == facing || face == facing.getOpposite()) {
          if (facing == BlockFace.NORTH || facing == BlockFace.SOUTH) {
            facing = BlockFace.WEST;
          } else {
            facing = BlockFace.SOUTH;
          }
View Full Code Here

   */
  private Block getOrigin(Block frameBlock) {
    if (!frameBlock.isMaterial(VanillaMaterials.END_PORTAL_FRAME)) {
      return null;
    }
    BlockFace facing = VanillaMaterials.END_PORTAL_FRAME.getFacing(frameBlock);
    // Rotates the facing 90 degrees to the left
    BlockFace lookDirection = BlockFaces.NESW.previous(facing);
    // Get the corner piece
    Block corner = frameBlock;
    for (int i = 0; i < 4 && isEndFrame(corner, facing, false); i++) {
      corner = corner.translate(lookDirection);
    }
View Full Code Here

  }

  private boolean findFrame(Block origin, boolean withEnderEye) {
    for (BlockFace face : BlockFaces.NESW) {
      Block frame = origin.translate(face, 2);
      BlockFace facing = face.getOpposite();
      if (!isEndFrame(frame, facing, withEnderEye)) {
        return false;
      }
      if (!isEndFrame(frame.translate(BlockFaces.NESW.previous(face)), facing, withEnderEye)) {
        return false;
View Full Code Here

    Block origin = w.getBlock(x, y, z);

    // Generate the frames
    for (BlockFace face : BlockFaces.NESW) {
      Block frame = origin.translate(face, 2);
      BlockFace facing = face.getOpposite();
      // Place the three pieces
      placeFrame(frame, facing);
      placeFrame(frame.translate(BlockFaces.NESW.previous(face)), facing);
      placeFrame(frame.translate(BlockFaces.NESW.next(face)), facing);
    }
View Full Code Here

    }

    int opacity = m.getOpacity() + 1;

    for (int i = 0; i < 6; i++) {
      BlockFace face = allFaces[i];
      int faceLight = getIncomingLight(light, material, x, y, z, occlusionSet, face) - opacity;
      neighborLight = Math.max(neighborLight, faceLight);
    }

    return neighborLight;
View Full Code Here

    final byte lenght = (byte) (grow ? 5 : 1);
    for (BlockFace face : BlockFaces.NSEW) {
      if (random.nextInt(faceOdd) != 0) {
        continue;
      }
      final BlockFace facing = face.getOpposite();
      for (byte yy = 0; yy < lenght; yy++) {
        final Block block = w.getBlock(face.getOffset().add(x, y - yy, z));
        if (block.isMaterial(VanillaMaterials.AIR)) {
          block.setMaterial(VanillaMaterials.VINES);
          VanillaMaterials.VINES.setFaceAttached(block, facing, true);
View Full Code Here

    for (PointBase group : groups) {
      final int baseY = group.getBase();
      if (baseY - y >= totalHeight * 0.2) {
        final Point base = new Point(world, x, baseY, z);
        final Vector3f angles = Quaternionf.fromRotationTo(Vector3f.FORWARD, group.sub(base)).getAxesAngleDeg();
        final BlockFace facing;
        if (angles.getX() < 135) {
          facing = BlockFace.fromYaw(angles.getY());
        } else {
          facing = BlockFace.TOP;
        }
View Full Code Here

  }

  public boolean execute(int x, int y, int z, boolean neighbours) {
    // Spout.getLogger().info("Resolving lower for " + x + ", " + y + ", " + z);
    for (int f = 0; f < allFaces.length; f++) {
      BlockFace face = allFaces[f];
      IntVector3 offset = face.getIntOffset();
      int nx = x + offset.getX();
      int ny = y + offset.getY();
      int nz = z + offset.getZ();

      short nId = material.getId(nx, ny, nz);
      if (nId == BlockMaterial.UNGENERATED.getId()) {
        continue;
      }
      int neighborLight = manager.getLightLevel(light, nx, ny, nz, true);

      short nData = material.getData(nx, ny, nz);
      BlockMaterial nMaterial = BlockMaterial.get(nId, nData);

      ByteBitSet occlusionSet = nMaterial.getOcclusion(nData);
      if (occlusionSet.get(face.getOpposite())) {
        continue;
      }

      int newLight = previousLevel - nMaterial.getOpacity() - 1;
View Full Code Here

TOP

Related Classes of org.spout.api.material.block.BlockFace

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.