org.bukkit.Rotation Java Examples

The following examples show how to use org.bukkit.Rotation. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CraftItemFrame.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
Rotation toBukkitRotation(int value) {
    // Translate NMS rotation integer to Bukkit API
    switch (value) {
        case 0:
            return Rotation.NONE;
        case 1:
            return Rotation.CLOCKWISE_45;
        case 2:
            return Rotation.CLOCKWISE;
        case 3:
            return Rotation.CLOCKWISE_135;
        case 4:
            return Rotation.FLIPPED;
        case 5:
            return Rotation.FLIPPED_45;
        case 6:
            return Rotation.COUNTER_CLOCKWISE;
        case 7:
            return Rotation.COUNTER_CLOCKWISE_45;
        default:
            throw new AssertionError("Unknown rotation " + value + " for " + getHandle());
    }
}
 
Example #2
Source File: CraftItemFrame.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
static int toInteger(Rotation rotation) {
    // Translate Bukkit API rotation to NMS integer
    switch (rotation) {
        case NONE:
            return 0;
        case CLOCKWISE_45:
            return 1;
        case CLOCKWISE:
            return 2;
        case CLOCKWISE_135:
            return 3;
        case FLIPPED:
            return 4;
        case FLIPPED_45:
            return 5;
        case COUNTER_CLOCKWISE:
            return 6;
        case COUNTER_CLOCKWISE_45:
            return 7;
        default:
            throw new IllegalArgumentException(rotation + " is not applicable to an ItemFrame");
    }
}
 
Example #3
Source File: CraftItemFrame.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
Rotation toBukkitRotation(int value) {
    // Translate NMS rotation integer to Bukkit API
    switch (value) {
    case 0:
        return Rotation.NONE;
    case 1:
        return Rotation.CLOCKWISE;
    case 2:
        return Rotation.FLIPPED;
    case 3:
        return Rotation.COUNTER_CLOCKWISE;
    default:
        throw new AssertionError("Unknown rotation " + value + " for " + getHandle());
    }
}
 
Example #4
Source File: CraftItemFrame.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
static int toInteger(Rotation rotation) {
    // Translate Bukkit API rotation to NMS integer
    switch (rotation) {
    case NONE:
        return 0;
    case CLOCKWISE:
        return 1;
    case FLIPPED:
        return 2;
    case COUNTER_CLOCKWISE:
        return 3;
    default:
        throw new IllegalArgumentException(rotation + " is not applicable to an ItemFrame");
    }
}
 
Example #5
Source File: BukkitImageViewer.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
private ItemFrame[][] find(Location pos1, Location pos2, BlockFace facing) {
    try {
        Location distance = pos2.clone().subtract(pos1).add(1, 1, 1);
        int width = Math.max(distance.getBlockX(), distance.getBlockZ());
        ItemFrame[][] frames = new ItemFrame[width][distance.getBlockY()];

        World world = pos1.getWorld();

        this.reverse = (facing == BlockFace.NORTH || facing == BlockFace.EAST);
        int v = 0;
        for (double y = pos1.getY(); y <= pos2.getY(); y++, v++) {
            int h = 0;
            for (double z = pos1.getZ(); z <= pos2.getZ(); z++) {
                for (double x = pos1.getX(); x <= pos2.getX(); x++, h++) {
                    Location pos = new Location(world, x, y, z);
                    Collection<Entity> entities = world.getNearbyEntities(pos, 0.1, 0.1, 0.1);
                    boolean contains = false;
                    for (Entity ent : entities) {
                        if (ent instanceof ItemFrame && ((ItemFrame) ent).getFacing() == facing) {
                            ItemFrame itemFrame = (ItemFrame) ent;
                            itemFrame.setRotation(Rotation.NONE);
                            contains = true;
                            frames[reverse ? width - 1 - h : h][v] = (ItemFrame) ent;
                            break;
                        }
                    }
                    if (!contains) return null;
                }
            }
        }
        return frames;
    } catch (Throwable e) {
        e.printStackTrace();
    }
    return null;
}
 
Example #6
Source File: CraftItemFrame.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public Rotation getRotation() {
    return toBukkitRotation(getHandle().getRotation());
}
 
Example #7
Source File: CraftItemFrame.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public void setRotation(Rotation rotation) {
    Validate.notNull(rotation, "Rotation cannot be null");
    getHandle().setItemRotation(toInteger(rotation));
}
 
Example #8
Source File: CraftItemFrame.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public Rotation getRotation() {
    return toBukkitRotation(getHandle().getRotation());
}
 
Example #9
Source File: CraftItemFrame.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public void setRotation(Rotation rotation) {
    Validate.notNull(rotation, "Rotation cannot be null");
    getHandle().setItemRotation(toInteger(rotation));
}
 
Example #10
Source File: ItemFrame.java    From Kettle with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Get the rotation of the frame's item
 *
 * @return the direction
 */
public Rotation getRotation();
 
Example #11
Source File: ItemFrame.java    From Kettle with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Set the rotation of the frame's item
 *
 * @param rotation the new rotation
 * @throws IllegalArgumentException if rotation is null
 */
public void setRotation(Rotation rotation) throws IllegalArgumentException;