package client.renderer.blockmodel;

public class BlockFaceUV {
	public float[] uvs;
	public final int rotation;

	public BlockFaceUV(float[] uvs, int rot) {
		this.uvs = uvs;
		this.rotation = rot;
	}

	public float getU(int rot) {
		int i = this.getUIndex(rot);
		return i != 0 && i != 1 ? this.uvs[2] : this.uvs[0];
	}

	public float getV(int rot) {
		int i = this.getUIndex(rot);
		return i != 0 && i != 3 ? this.uvs[3] : this.uvs[1];
	}

	private int getUIndex(int rot) {
		return (rot + this.rotation / 90) % 4;
	}

	public int getVIndex(int rot) {
		return (rot + (4 - this.rotation / 90)) % 4;
	}
}
