Java Code Examples for net.minecraft.util.EnumFacing#toString()

The following examples show how to use net.minecraft.util.EnumFacing#toString() . 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: HeadingUtils.java    From Signals with GNU General Public License v3.0 5 votes vote down vote up
public static EnumHeading fromFacing(EnumFacing facing){
    if(facing == null) return null;
    switch(facing){
        case NORTH:
            return EnumHeading.NORTH;
        case SOUTH:
            return EnumHeading.SOUTH;
        case WEST:
            return EnumHeading.WEST;
        case EAST:
            return EnumHeading.EAST;
        default:
            throw new IllegalArgumentException(facing.toString());
    }
}
 
Example 2
Source File: BlockTextureTransform.java    From OpenModsLib with MIT License 4 votes vote down vote up
public TexCoords worldVecToTextureCoords(EnumFacing side, double x, double y, double z) {
	final double wallX;
	final double wallY;
	final double h;
	// positive h always points "outside" block
	switch (side) {
		case UP:
			wallX = x;
			wallY = z;
			h = y - 1;
			break;
		case DOWN:
			wallX = x;
			wallY = z;
			h = -y;
			break;
		case EAST:
			wallX = z;
			wallY = 1 - y;
			h = x - 1;
			break;
		case WEST:
			wallX = z;
			wallY = 1 - y;
			h = -x;
			break;
		case NORTH:
			wallX = x;
			wallY = 1 - y;
			h = -z;
			break;
		case SOUTH:
			wallX = x;
			wallY = 1 - y;
			h = z - 1;
			break;
		default:
			throw new IllegalArgumentException(side.toString());
	}

	final Matrix2d transformation = transforms.get(side);
	final double u = transformation.transformX(wallX - 0.5, wallY - 0.5) + 0.5;
	final double v = transformation.transformY(wallX - 0.5, wallY - 0.5) + 0.5;
	return new TexCoords(u, v, h);
}
 
Example 3
Source File: BlockTextureTransform.java    From OpenModsLib with MIT License 4 votes vote down vote up
public Vec3d textureCoordsToWorldVec(EnumFacing side, double u, double v, double h) {
	final Matrix2d transformation = inverseTransforms.get(side);
	if (transformation == null) throw new IllegalArgumentException(side.toString());

	final double wallX = transformation.transformX(u - 0.5, v - 0.5) + 0.5;
	final double wallY = transformation.transformY(u - 0.5, v - 0.5) + 0.5;

	final double globalX;
	final double globalY;
	final double globalZ;

	switch (side) {
		case UP:
			globalX = wallX;
			globalY = h + 1;
			globalZ = wallY;
			break;
		case DOWN:
			globalX = wallX;
			globalY = -h;
			globalZ = wallY;
			break;
		case EAST:
			globalX = h + 1;
			globalY = 1 - wallY;
			globalZ = wallX;
			break;
		case WEST:
			globalX = -h;
			globalY = 1 - wallY;
			globalZ = wallX;
			break;
		case NORTH:
			globalX = wallX;
			globalY = 1 - wallY;
			globalZ = -h;
			break;
		case SOUTH:
			globalX = wallX;
			globalY = 1 - wallY;
			globalZ = h + 1;
			break;
		default:
			throw new IllegalArgumentException(side.toString());
	}

	return new Vec3d(globalX, globalY, globalZ);
}