cn.nukkit.utils.Rail.Orientation Java Examples

The following examples show how to use cn.nukkit.utils.Rail.Orientation. 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: BlockRail.java    From Jupiter with GNU General Public License v3.0 6 votes vote down vote up
private Orientation connect(BlockRail rail1, BlockFace face1, BlockRail rail2, BlockFace face2) {
    this.connect(rail1, face1);
    this.connect(rail2, face2);

    if (face1.getOpposite() == face2) {
        int delta1 = (int) (this.y - rail1.y);
        int delta2 = (int) (this.y - rail2.y);

        if (delta1 == -1) {
            return Orientation.ascending(face1);
        } else if (delta2 == -1) {
            return Orientation.ascending(face2);
        }
    }
    return straightOrCurved(face1, face2);
}
 
Example #2
Source File: BlockRail.java    From Jupiter with GNU General Public License v3.0 6 votes vote down vote up
private Orientation connect(BlockRail other, BlockFace face) {
    int delta = (int) (this.y - other.y);
    Map<BlockRail, BlockFace> rails = other.checkRailsConnected();
    if (rails.isEmpty()) { //Only one
        other.setOrientation(delta == 1 ? ascending(face.getOpposite()) : straight(face));
        return delta == -1 ? ascending(face) : straight(face);
    } else if (rails.size() == 1) { //Already connected
        BlockFace faceConnected = rails.values().iterator().next();

        if (other.isAbstract() && faceConnected != face) { //Curve!
            other.setOrientation(curved(face.getOpposite(), faceConnected));
            return delta == -1 ? ascending(face) : straight(face);
        } else if (faceConnected == face) { //Turn!
            if (!other.getOrientation().isAscending()) {
                other.setOrientation(delta == 1 ? ascending(face.getOpposite()) : straight(face));
            }
            return delta == -1 ? ascending(face) : straight(face);
        } else if (other.getOrientation().hasConnectingDirections(NORTH, SOUTH)) { //North-south
            other.setOrientation(delta == 1 ? ascending(face.getOpposite()) : straight(face));
            return delta == -1 ? ascending(face) : straight(face);
        }
    }
    return STRAIGHT_NORTH_SOUTH;
}
 
Example #3
Source File: BlockRail.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
private Orientation connect(BlockRail rail1, BlockFace face1, BlockRail rail2, BlockFace face2) {
    this.connect(rail1, face1);
    this.connect(rail2, face2);

    if (face1.getOpposite() == face2) {
        int delta1 = (int) (this.y - rail1.y);
        int delta2 = (int) (this.y - rail2.y);

        if (delta1 == -1) {
            return Orientation.ascending(face1);
        } else if (delta2 == -1) {
            return Orientation.ascending(face2);
        }
    }
    return straightOrCurved(face1, face2);
}
 
Example #4
Source File: BlockRail.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
private Orientation connect(BlockRail other, BlockFace face) {
    int delta = (int) (this.y - other.y);
    Map<BlockRail, BlockFace> rails = other.checkRailsConnected();
    if (rails.isEmpty()) { //Only one
        other.setOrientation(delta == 1 ? ascending(face.getOpposite()) : straight(face));
        return delta == -1 ? ascending(face) : straight(face);
    } else if (rails.size() == 1) { //Already connected
        BlockFace faceConnected = rails.values().iterator().next();

        if (other.isAbstract() && faceConnected != face) { //Curve!
            other.setOrientation(curved(face.getOpposite(), faceConnected));
            return delta == -1 ? ascending(face) : straight(face);
        } else if (faceConnected == face) { //Turn!
            if (!other.getOrientation().isAscending()) {
                other.setOrientation(delta == 1 ? ascending(face.getOpposite()) : straight(face));
            }
            return delta == -1 ? ascending(face) : straight(face);
        } else if (other.getOrientation().hasConnectingDirections(NORTH, SOUTH)) { //North-south
            other.setOrientation(delta == 1 ? ascending(face.getOpposite()) : straight(face));
            return delta == -1 ? ascending(face) : straight(face);
        }
    }
    return STRAIGHT_NORTH_SOUTH;
}
 
Example #5
Source File: BlockRail.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
private Orientation connect(BlockRail rail1, BlockFace face1, BlockRail rail2, BlockFace face2) {
    this.connect(rail1, face1);
    this.connect(rail2, face2);

    if (face1.getOpposite() == face2) {
        int delta1 = (int) (this.y - rail1.y);
        int delta2 = (int) (this.y - rail2.y);

        if (delta1 == -1) {
            return Orientation.ascending(face1);
        } else if (delta2 == -1) {
            return Orientation.ascending(face2);
        }
    }
    return straightOrCurved(face1, face2);
}
 
Example #6
Source File: BlockRail.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
private Orientation connect(BlockRail other, BlockFace face) {
    int delta = (int) (this.y - other.y);
    Map<BlockRail, BlockFace> rails = other.checkRailsConnected();
    if (rails.isEmpty()) { //Only one
        other.setOrientation(delta == 1 ? ascending(face.getOpposite()) : straight(face));
        return delta == -1 ? ascending(face) : straight(face);
    } else if (rails.size() == 1) { //Already connected
        BlockFace faceConnected = rails.values().iterator().next();

        if (other.isAbstract() && faceConnected != face) { //Curve!
            other.setOrientation(curved(face.getOpposite(), faceConnected));
            return delta == -1 ? ascending(face) : straight(face);
        } else if (faceConnected == face) { //Turn!
            if (!other.getOrientation().isAscending()) {
                other.setOrientation(delta == 1 ? ascending(face.getOpposite()) : straight(face));
            }
            return delta == -1 ? ascending(face) : straight(face);
        } else if (other.getOrientation().hasConnectingDirections(NORTH, SOUTH)) { //North-south
            other.setOrientation(delta == 1 ? ascending(face.getOpposite()) : straight(face));
            return delta == -1 ? ascending(face) : straight(face);
        }
    }
    return STRAIGHT_NORTH_SOUTH;
}
 
Example #7
Source File: BlockRail.java    From Jupiter with GNU General Public License v3.0 4 votes vote down vote up
public Orientation getOrientation() {
    return byMetadata(this.getRealMeta());
}
 
Example #8
Source File: BlockRail.java    From Jupiter with GNU General Public License v3.0 4 votes vote down vote up
public void setOrientation(Orientation o) {
    if (o.metadata() != this.getRealMeta()) {
        this.setDamage(o.metadata());
        this.level.setBlock(this, this, true, true);
    }
}
 
Example #9
Source File: BlockRail.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
public Orientation getOrientation() {
    return byMetadata(this.getRealMeta());
}
 
Example #10
Source File: BlockRail.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
public void setOrientation(Orientation o) {
    if (o.metadata() != this.getRealMeta()) {
        this.setDamage(o.metadata());
        this.level.setBlock(this, this, false, true);
    }
}
 
Example #11
Source File: BlockRail.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
public Orientation getOrientation() {
    return byMetadata(this.getRealMeta());
}
 
Example #12
Source File: BlockRail.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
public void setOrientation(Orientation o) {
    if (o.metadata() != this.getRealMeta()) {
        this.setDamage(o.metadata());
        this.level.setBlock(this, this, false, true);
    }
}