org.bukkit.block.BlockFace#NORTH_EAST源码实例Demo

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

源代码1 项目: BedWars   文件: MiscUtils.java
public static BlockFace getCardinalDirection(Location location) {
    double rotation = (location.getYaw() - 90) % 360;
    if (rotation < 0) {
        rotation += 360.0;
    }
    if (0 <= rotation && rotation < 22.5) {
        return BlockFace.NORTH;
    } else if (22.5 <= rotation && rotation < 67.5) {
        return BlockFace.NORTH_EAST;
    } else if (67.5 <= rotation && rotation < 112.5) {
        return BlockFace.EAST;
    } else if (112.5 <= rotation && rotation < 157.5) {
        return BlockFace.SOUTH_EAST;
    } else if (157.5 <= rotation && rotation < 202.5) {
        return BlockFace.SOUTH;
    } else if (202.5 <= rotation && rotation < 247.5) {
        return BlockFace.SOUTH_WEST;
    } else if (247.5 <= rotation && rotation < 292.5) {
        return BlockFace.WEST;
    } else if (292.5 <= rotation && rotation < 337.5) {
        return BlockFace.NORTH_WEST;
    } else if (337.5 <= rotation && rotation < 360.0) {
        return BlockFace.NORTH;
    } else {
        return BlockFace.NORTH;
    }
}
 
源代码2 项目: BedWars   文件: MiscUtils.java
public static BlockFace getCardinalDirection(Location location) {
    double rotation = (location.getYaw() - 90) % 360;
    if (rotation < 0) {
        rotation += 360.0;
    }
    if (0 <= rotation && rotation < 22.5) {
        return BlockFace.NORTH;
    } else if (22.5 <= rotation && rotation < 67.5) {
        return BlockFace.NORTH_EAST;
    } else if (67.5 <= rotation && rotation < 112.5) {
        return BlockFace.EAST;
    } else if (112.5 <= rotation && rotation < 157.5) {
        return BlockFace.SOUTH_EAST;
    } else if (157.5 <= rotation && rotation < 202.5) {
        return BlockFace.SOUTH;
    } else if (202.5 <= rotation && rotation < 247.5) {
        return BlockFace.SOUTH_WEST;
    } else if (247.5 <= rotation && rotation < 292.5) {
        return BlockFace.WEST;
    } else if (292.5 <= rotation && rotation < 337.5) {
        return BlockFace.NORTH_WEST;
    } else if (337.5 <= rotation && rotation < 360.0) {
        return BlockFace.NORTH;
    } else {
        return BlockFace.NORTH;
    }
}
 
源代码3 项目: Kettle   文件: Rails.java
/**
 * @return the direction these tracks are set
 * <p>
 * Note that tracks are bidirectional and that the direction returned
 * is the ascending direction if the track is set on a slope. If it is
 * set as a curve, the corner of the track is returned.
 */
public BlockFace getDirection() {
    byte d = getConvertedData();

    switch (d) {
        case 0x0:
        default:
            return BlockFace.SOUTH;

        case 0x1:
            return BlockFace.EAST;

        case 0x2:
            return BlockFace.EAST;

        case 0x3:
            return BlockFace.WEST;

        case 0x4:
            return BlockFace.NORTH;

        case 0x5:
            return BlockFace.SOUTH;

        case 0x6:
            return BlockFace.NORTH_WEST;

        case 0x7:
            return BlockFace.NORTH_EAST;

        case 0x8:
            return BlockFace.SOUTH_EAST;

        case 0x9:
            return BlockFace.SOUTH_WEST;
    }
}
 
源代码4 项目: Kettle   文件: CraftSkull.java
static BlockFace getBlockFace(byte rotation) {
    switch (rotation) {
        case 0:
            return BlockFace.NORTH;
        case 1:
            return BlockFace.NORTH_NORTH_EAST;
        case 2:
            return BlockFace.NORTH_EAST;
        case 3:
            return BlockFace.EAST_NORTH_EAST;
        case 4:
            return BlockFace.EAST;
        case 5:
            return BlockFace.EAST_SOUTH_EAST;
        case 6:
            return BlockFace.SOUTH_EAST;
        case 7:
            return BlockFace.SOUTH_SOUTH_EAST;
        case 8:
            return BlockFace.SOUTH;
        case 9:
            return BlockFace.SOUTH_SOUTH_WEST;
        case 10:
            return BlockFace.SOUTH_WEST;
        case 11:
            return BlockFace.WEST_SOUTH_WEST;
        case 12:
            return BlockFace.WEST;
        case 13:
            return BlockFace.WEST_NORTH_WEST;
        case 14:
            return BlockFace.NORTH_WEST;
        case 15:
            return BlockFace.NORTH_NORTH_WEST;
        default:
            throw new AssertionError(rotation);
    }
}
 
源代码5 项目: Thermos   文件: CraftSkull.java
static BlockFace getBlockFace(byte rotation) {
    switch (rotation % 16) {
        case 0:
            return BlockFace.NORTH;
        case 1:
            return BlockFace.NORTH_NORTH_EAST;
        case 2:
            return BlockFace.NORTH_EAST;
        case 3:
            return BlockFace.EAST_NORTH_EAST;
        case 4:
            return BlockFace.EAST;
        case 5:
            return BlockFace.EAST_SOUTH_EAST;
        case 6:
            return BlockFace.SOUTH_EAST;
        case 7:
            return BlockFace.SOUTH_SOUTH_EAST;
        case 8:
            return BlockFace.SOUTH;
        case 9:
            return BlockFace.SOUTH_SOUTH_WEST;
        case 10:
            return BlockFace.SOUTH_WEST;
        case 11:
            return BlockFace.WEST_SOUTH_WEST;
        case 12:
            return BlockFace.WEST;
        case 13:
            return BlockFace.WEST_NORTH_WEST;
        case 14:
            return BlockFace.NORTH_WEST;
        case 15:
            return BlockFace.NORTH_NORTH_WEST;
        default:
            throw new AssertionError(rotation);
    }
}
 
源代码6 项目: BedwarsRel   文件: Utils.java
public static BlockFace getCardinalDirection(Location location) {
  double rotation = (location.getYaw() - 90) % 360;
  if (rotation < 0) {
    rotation += 360.0;
  }
  if (0 <= rotation && rotation < 22.5) {
    return BlockFace.NORTH;
  } else if (22.5 <= rotation && rotation < 67.5) {
    return BlockFace.NORTH_EAST;
  } else if (67.5 <= rotation && rotation < 112.5) {
    return BlockFace.EAST;
  } else if (112.5 <= rotation && rotation < 157.5) {
    return BlockFace.SOUTH_EAST;
  } else if (157.5 <= rotation && rotation < 202.5) {
    return BlockFace.SOUTH;
  } else if (202.5 <= rotation && rotation < 247.5) {
    return BlockFace.SOUTH_WEST;
  } else if (247.5 <= rotation && rotation < 292.5) {
    return BlockFace.WEST;
  } else if (292.5 <= rotation && rotation < 337.5) {
    return BlockFace.NORTH_WEST;
  } else if (337.5 <= rotation && rotation < 360.0) {
    return BlockFace.NORTH;
  } else {
    return BlockFace.NORTH;
  }
}
 
源代码7 项目: CardinalPGM   文件: Flags.java
public static BlockFace yawToFace(float yaw) {
    BlockFace[] RADIAL = {
            BlockFace.NORTH, BlockFace.NORTH_NORTH_EAST, BlockFace.NORTH_EAST, BlockFace.EAST_NORTH_EAST,
            BlockFace.EAST, BlockFace.EAST_SOUTH_EAST, BlockFace.SOUTH_EAST, BlockFace.SOUTH_SOUTH_EAST,
            BlockFace.SOUTH, BlockFace.SOUTH_SOUTH_WEST, BlockFace.SOUTH_WEST, BlockFace.WEST_SOUTH_WEST,
            BlockFace.WEST, BlockFace.WEST_NORTH_WEST, BlockFace.NORTH_WEST, BlockFace.NORTH_NORTH_WEST
    };
    int i = Math.round((yaw + 360f)/ 22.5f);
    return RADIAL[(i + 8)% 16];
}
 
源代码8 项目: Kettle   文件: Banner.java
public BlockFace getFacing() {
    byte data = getData();

    if (!isWallBanner()) {
        switch (data) {
            case 0x0:
                return BlockFace.SOUTH;

            case 0x1:
                return BlockFace.SOUTH_SOUTH_WEST;

            case 0x2:
                return BlockFace.SOUTH_WEST;

            case 0x3:
                return BlockFace.WEST_SOUTH_WEST;

            case 0x4:
                return BlockFace.WEST;

            case 0x5:
                return BlockFace.WEST_NORTH_WEST;

            case 0x6:
                return BlockFace.NORTH_WEST;

            case 0x7:
                return BlockFace.NORTH_NORTH_WEST;

            case 0x8:
                return BlockFace.NORTH;

            case 0x9:
                return BlockFace.NORTH_NORTH_EAST;

            case 0xA:
                return BlockFace.NORTH_EAST;

            case 0xB:
                return BlockFace.EAST_NORTH_EAST;

            case 0xC:
                return BlockFace.EAST;

            case 0xD:
                return BlockFace.EAST_SOUTH_EAST;

            case 0xE:
                return BlockFace.SOUTH_EAST;

            case 0xF:
                return BlockFace.SOUTH_SOUTH_EAST;
        }

        return null;
    } else {
        return getAttachedFace().getOppositeFace();
    }
}
 
源代码9 项目: Kettle   文件: Sign.java
/**
 * Gets the direction that this sign is currently facing
 *
 * @return BlockFace indicating where this sign is facing
 */
public BlockFace getFacing() {
    byte data = getData();

    if (!isWallSign()) {
        switch (data) {
            case 0x0:
                return BlockFace.SOUTH;

            case 0x1:
                return BlockFace.SOUTH_SOUTH_WEST;

            case 0x2:
                return BlockFace.SOUTH_WEST;

            case 0x3:
                return BlockFace.WEST_SOUTH_WEST;

            case 0x4:
                return BlockFace.WEST;

            case 0x5:
                return BlockFace.WEST_NORTH_WEST;

            case 0x6:
                return BlockFace.NORTH_WEST;

            case 0x7:
                return BlockFace.NORTH_NORTH_WEST;

            case 0x8:
                return BlockFace.NORTH;

            case 0x9:
                return BlockFace.NORTH_NORTH_EAST;

            case 0xA:
                return BlockFace.NORTH_EAST;

            case 0xB:
                return BlockFace.EAST_NORTH_EAST;

            case 0xC:
                return BlockFace.EAST;

            case 0xD:
                return BlockFace.EAST_SOUTH_EAST;

            case 0xE:
                return BlockFace.SOUTH_EAST;

            case 0xF:
                return BlockFace.SOUTH_SOUTH_EAST;
        }

        return null;
    } else {
        return getAttachedFace().getOppositeFace();
    }
}
 
源代码10 项目: ExoticGarden   文件: Schematic.java
public static void pasteSchematic(Location loc, Tree tree) {
    Schematic schematic;

    try {
        schematic = tree.getSchematic();
    }
    catch (IOException e) {
        ExoticGarden.instance.getLogger().log(Level.WARNING, "Could not paste Schematic for Tree: " + tree.getFruitID() + "_TREE (" + e.getClass().getSimpleName() + ')', e);
        return;
    }

    BlockFace[] faces = { BlockFace.NORTH, BlockFace.NORTH_EAST, BlockFace.EAST, BlockFace.SOUTH_EAST, BlockFace.SOUTH, BlockFace.SOUTH_WEST, BlockFace.WEST, BlockFace.NORTH_WEST };
    short[] blocks = schematic.getBlocks();
    byte[] blockData = schematic.getData();

    short length = schematic.getLength();
    short width = schematic.getWidth();
    short height = schematic.getHeight();

    for (int x = 0; x < width; ++x) {
        for (int y = 0; y < height; ++y) {
            for (int z = 0; z < length; ++z) {
                int index = y * width * length + z * width + x;

                int blockX = x + loc.getBlockX() - length / 2;
                int blockY = y + loc.getBlockY();
                int blockZ = z + loc.getBlockZ() - width / 2;
                Block block = new Location(loc.getWorld(), blockX, blockY, blockZ).getBlock();

                if ((!block.getType().isSolid() && !block.getType().isInteractable() && !MaterialCollections.getAllUnbreakableBlocks().contains(block.getType())) || block.getType() == Material.AIR || block.getType() == Material.CAVE_AIR || org.bukkit.Tag.SAPLINGS.isTagged(block.getType())) {
                    Material material = parseId(blocks[index], blockData[index]);

                    if (material != null) {
                        if (blocks[index] != 0) {
                            block.setType(material);
                        }

                        if (org.bukkit.Tag.LEAVES.isTagged(material)) {
                            if (ThreadLocalRandom.current().nextInt(100) < 25) {
                                BlockStorage.store(block, tree.getItem());
                            }
                        }
                        else if (material == Material.PLAYER_HEAD) {
                            Rotatable s = (Rotatable) block.getBlockData();
                            s.setRotation(faces[ThreadLocalRandom.current().nextInt(faces.length)]);
                            block.setBlockData(s);

                            SkullBlock.setFromHash(block, tree.getTexture());
                            BlockStorage.store(block, tree.getFruit());
                        }
                    }
                }
            }
        }
    }
}