use of net.minecraft.client.renderer.texture.TextureAtlasSprite in project ImmersiveEngineering by BluSunrize.
the class ModelConveyor method getBaseConveyor.
public static Set<BakedQuad> getBaseConveyor(EnumFacing facing, float length, Matrix4 matrix, ConveyorDirection conDir, TextureAtlasSprite tex_conveyor, boolean[] walls, boolean[] corners, TextureAtlasSprite tex_conveyor_colour, int stripeColour) {
Set<BakedQuad> quads = new LinkedHashSet<BakedQuad>();
Vector3f[] vertices = { new Vector3f(.0625f, 0, 1 - length), new Vector3f(.0625f, 0, 1), new Vector3f(.9375f, 0, 1), new Vector3f(.9375f, 0, 1 - length) };
TextureAtlasSprite tex_casing0 = ClientUtils.getSprite(rl_casing[0]);
TextureAtlasSprite tex_casing1 = ClientUtils.getSprite(rl_casing[1]);
TextureAtlasSprite tex_casing2 = ClientUtils.getSprite(rl_casing[2]);
float[] colour = { 1, 1, 1, 1 };
float[] colourStripes = { (stripeColour >> 16 & 255) / 255f, (stripeColour >> 8 & 255) / 255f, (stripeColour & 255) / 255f, 1 };
//Shift if up/down
for (int i = 0; i < 4; i++) if ((i == 0 || i == 3) ? conDir == ConveyorDirection.UP : conDir == ConveyorDirection.DOWN)
vertices[i].translate(0, length, 0);
//Draw bottom
quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.DOWN, facing), tex_conveyor, new double[] { 1, 0, 15, length * 16 }, colour, true));
//Expand verts to side
for (Vector3f v : vertices) v.setX(v.getX() < .5f ? 0 : 1);
//Draw bottom casing
quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.DOWN, facing), tex_casing2, new double[] { 0, 0, 16, length * 16 }, colour, true));
//Shift verts to top
for (Vector3f v : vertices) v.translate(0, .125f, 0);
//Draw top
quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.UP, facing), tex_conveyor, new double[] { 0, length * 16, 16, 0 }, colour, false));
if (corners[0]) {
vertices = new Vector3f[] { new Vector3f(0, .1875f, .9375f), new Vector3f(0, .1875f, 1), new Vector3f(1, .1875f, 1), new Vector3f(1, .1875f, .9375f) };
//Shift if up/down
for (int i = 0; i < 4; i++) vertices[i].translate(0, i == 0 || i == 3 ? (conDir == ConveyorDirection.UP ? .0625f : conDir == ConveyorDirection.DOWN ? length - .0625f : 0) : (conDir == ConveyorDirection.DOWN ? length : 0), 0);
//Draw top casing back
quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.UP, facing), tex_casing0, new double[] { 0, 1, 16, 0 }, colour, false));
}
if (corners[1]) {
vertices = new Vector3f[] { new Vector3f(0, .1875f, 1 - length), new Vector3f(0, .1875f, 1.0625f - length), new Vector3f(1, .1875f, 1.0625f - length), new Vector3f(1, .1875f, 1 - length) };
//Shift if up/down
for (int i = 0; i < 4; i++) vertices[i].translate(0, i == 1 || i == 2 ? (conDir == ConveyorDirection.UP ? length - .0625f : conDir == ConveyorDirection.DOWN ? .0625f : 0) : (conDir == ConveyorDirection.UP ? length : 0), 0);
//Draw top casing front
quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.UP, facing), tex_casing0, new double[] { 0, 1, 16, 0 }, colour, false));
}
/**
* Sides
*/
vertices = new Vector3f[] { new Vector3f(0, 0, 1 - length), new Vector3f(0, 0, 1), new Vector3f(0, .125f, 1), new Vector3f(0, .125f, 1 - length) };
for (int i = 0; i < 4; i++) if ((i == 0 || i == 3) ? conDir == ConveyorDirection.UP : conDir == ConveyorDirection.DOWN)
vertices[i].translate(0, length, 0);
//Draw left side
quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.WEST, facing), tex_casing1, new double[] { 0, 0, 2, length * 16 }, colour, false));
//Shift upwards
for (int i = 0; i < 4; i++) vertices[i].setY(vertices[i].getY() + ((i == 0 || i == 1) ? .125f : .0625f));
//Shift back down and to the other side
for (int i = 0; i < 4; i++) vertices[i].set(1, vertices[i].getY() - ((i == 0 || i == 1) ? .125f : .0625f));
//Draw right side
quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.EAST, facing), tex_casing1, new double[] { 0, 0, 2, length * 16 }, colour, true));
//Shift upwards
for (int i = 0; i < 4; i++) vertices[i].setY(vertices[i].getY() + ((i == 0 || i == 1) ? .125f : .0625f));
/**
* Corners
*/
if (corners[0]) {
vertices = new Vector3f[] { new Vector3f(0, .125f, .9375f), new Vector3f(0, .125f, 1), new Vector3f(0, .1875f, 1), new Vector3f(0, .1875f, .9375f) };
if (conDir != ConveyorDirection.HORIZONTAL)
for (int i = 0; i < 4; i++) vertices[i].translate(0, i == 0 || i == 3 ? (conDir == ConveyorDirection.UP ? .0625f : conDir == ConveyorDirection.DOWN ? length - .0625f : 0) : (conDir == ConveyorDirection.DOWN ? length : 0), 0);
//Back left
quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.WEST, facing), tex_casing0, new double[] { 0, 0, 1, 1 }, colour, false));
for (Vector3f v : vertices) v.translate(.0625f, 0, 0);
quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.EAST, facing), tex_casing0, new double[] { 0, 0, 1, 1 }, colour, true));
//Shift right
for (Vector3f v : vertices) v.setX(1);
//Back right
quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.EAST, facing), tex_casing0, new double[] { 0, 0, 1, 1 }, colour, true));
for (Vector3f v : vertices) v.translate(-.0625f, 0, 0);
quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.WEST, facing), tex_casing0, new double[] { 0, 0, 1, 1 }, colour, false));
}
if (corners[1]) {
vertices = new Vector3f[] { new Vector3f(0, .125f, 1 - length), new Vector3f(0, .125f, 1.0625f - length), new Vector3f(0, .1875f, 1.0625f - length), new Vector3f(0, .1875f, 1 - length) };
if (conDir != ConveyorDirection.HORIZONTAL)
for (int i = 0; i < 4; i++) vertices[i].translate(0, i == 1 || i == 2 ? (conDir == ConveyorDirection.UP ? length - .0625f : conDir == ConveyorDirection.DOWN ? .0625f : 0) : (conDir == ConveyorDirection.UP ? length : 0), 0);
//Front left
quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.WEST, facing), tex_casing0, new double[] { 0, 15, 1, 16 }, colour, false));
for (Vector3f v : vertices) v.translate(.0625f, 0, 0);
quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.EAST, facing), tex_casing0, new double[] { 0, 15, 1, 16 }, colour, true));
//Shift right
for (Vector3f v : vertices) v.setX(1);
//Front right
quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.EAST, facing), tex_casing0, new double[] { 0, 15, 1, 16 }, colour, true));
for (Vector3f v : vertices) v.translate(-.0625f, 0, 0);
quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.WEST, facing), tex_casing0, new double[] { 0, 15, 1, 16 }, colour, false));
}
/**
* Front & Back
*/
vertices = new Vector3f[] { new Vector3f(.0625f, 0, 1 - length), new Vector3f(.0625f, .125f, 1 - length), new Vector3f(.9375f, .125f, 1 - length), new Vector3f(.9375f, 0, 1 - length) };
//Shift if up/down
if (conDir == ConveyorDirection.UP)
for (Vector3f v : vertices) v.translate(0, length, 0);
//Draw front
double frontUMax = (1 - length) * 16;
quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), facing, tex_conveyor, new double[] { 1, frontUMax + 2, 15, frontUMax }, colour, false));
//Expand to side and up
for (int i = 0; i < 4; i++) vertices[i].set(vertices[i].getX() < .5f ? 0 : 1, vertices[i].getY() + (i == 1 || i == 2 ? .0625f : 0));
//Draw front casing
quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), facing, tex_casing2, new double[] { 0, 3, 16, 0 }, colour, false));
for (Vector3f v : vertices) v.translate(0, (conDir == ConveyorDirection.UP ? -.0625f : conDir == ConveyorDirection.DOWN ? .0625f : 0), .0625f);
quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), facing, tex_casing2, new double[] { 0, 3, 16, 0 }, colour, true));
//Undo expand, shift if up/down, shift to back
for (int i = 0; i < 4; i++) {
Vector3f v = vertices[i];
v.setX(v.getX() < .5f ? .0625f : .9375f);
v.setY(v.getY() - (i == 1 || i == 2 ? .0625f : 0));
if (conDir == ConveyorDirection.UP)
v.translate(0, -(length - .0625f), 0);
if (conDir == ConveyorDirection.DOWN)
v.translate(0, (length - .0625f), 0);
v.translate(0, 0, length - .0625f);
}
//Draw back
quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), facing.getOpposite(), tex_conveyor, new double[] { 1, 0, 15, 2 }, colour, true));
//Expand to side and up
for (int i = 0; i < 4; i++) vertices[i].set(vertices[i].getX() < .5f ? 0 : 1, vertices[i].getY() + (i == 1 || i == 2 ? .0625f : 0));
//Draw back casing
quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), facing.getOpposite(), tex_casing2, new double[] { 0, 0, 16, 3 }, colour, true));
for (Vector3f v : vertices) v.translate(0, conDir == ConveyorDirection.UP ? .0625f : conDir == ConveyorDirection.DOWN ? -.0625f : 0, -.0625f);
quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), facing.getOpposite(), tex_casing2, new double[] { 0, 0, 16, 3 }, colour, false));
/**
* Walls
*/
float wallLength = length - .125f;
vertices = new Vector3f[] { new Vector3f(0, .1875f, .9375f - wallLength), new Vector3f(0, .1875f, .9375f), new Vector3f(.0625f, .1875f, .9375f), new Vector3f(.0625f, .1875f, .9375f - wallLength) };
Vector3f[] vertices2 = new Vector3f[] { new Vector3f(0, .125f, .9375f - wallLength), new Vector3f(0, .125f, .9375f), new Vector3f(0, .1875f, .9375f), new Vector3f(0, .1875f, .9375f - wallLength) };
Vector3f[] vertices3 = new Vector3f[] { new Vector3f(.0625f, .125f, .9375f - wallLength), new Vector3f(.0625f, .125f, .9375f), new Vector3f(.0625f, .1875f, .9375f), new Vector3f(.0625f, .1875f, .9375f - wallLength) };
Vector3f[] verticesColour = new Vector3f[] { new Vector3f(0, .1876f, corners[1] ? (1 - length) : (.9375f - wallLength)), new Vector3f(0, .1876f, corners[0] ? 1 : .9375f), new Vector3f(.0625f, .1876f, corners[0] ? 1 : .9375f), new Vector3f(.0625f, .1876f, corners[1] ? (1 - length) : (.9375f - wallLength)) };
for (int i = 0; i < 4; i++) if (conDir != ConveyorDirection.HORIZONTAL) {
float f = (i == 0 || i == 3) ? (conDir == ConveyorDirection.UP ? length - .0625f : .0625f) : (conDir == ConveyorDirection.UP ? .0625f : length - .0625f);
vertices[i].translate(0, f, 0);
vertices2[i].translate(0, f, 0);
vertices3[i].translate(0, f, 0);
verticesColour[i].translate(0, f, 0);
}
//Draw left walls
if (walls[0]) {
quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.UP, facing), tex_casing2, new double[] { 0, wallLength * 16, 1, 1 }, colour, false));
if (tex_conveyor_colour != null && stripeColour >= 0)
quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, verticesColour), Utils.rotateFacingTowardsDir(EnumFacing.UP, facing), tex_conveyor_colour, new double[] { 0, wallLength * 16, 1, 1 }, colourStripes, false));
quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices2), Utils.rotateFacingTowardsDir(EnumFacing.WEST, facing), tex_casing1, new double[] { 2, wallLength * 16, 3, 1 }, colour, false));
quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices3), Utils.rotateFacingTowardsDir(EnumFacing.EAST, facing), tex_casing1, new double[] { 2, wallLength * 16, 3, 1 }, colour, true));
}
for (int i = 0; i < 4; i++) {
vertices[i].translate(.9375f, 0, 0);
vertices2[i].translate(.9375f, 0, 0);
vertices3[i].translate(.9375f, 0, 0);
verticesColour[i].translate(.9375f, 0, 0);
}
//Draw right walls
if (walls[1]) {
quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices), Utils.rotateFacingTowardsDir(EnumFacing.UP, facing), tex_casing2, new double[] { 15, wallLength * 16, 16, 1 }, colour, false));
if (tex_conveyor_colour != null && stripeColour >= 0)
quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, verticesColour), Utils.rotateFacingTowardsDir(EnumFacing.UP, facing), tex_conveyor_colour, new double[] { 15, wallLength * 16, 16, 1 }, colourStripes, false));
quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices2), Utils.rotateFacingTowardsDir(EnumFacing.WEST, facing), tex_casing1, new double[] { 2, wallLength * 16, 3, 1 }, colour, false));
quads.add(ClientUtils.createBakedQuad(DefaultVertexFormats.ITEM, ClientUtils.applyMatrixToVertices(matrix, vertices3), Utils.rotateFacingTowardsDir(EnumFacing.EAST, facing), tex_casing1, new double[] { 2, wallLength * 16, 3, 1 }, colour, true));
}
return quads;
}
use of net.minecraft.client.renderer.texture.TextureAtlasSprite in project ImmersiveEngineering by BluSunrize.
the class ModelCoresample method getQuads.
// @Override
// public List<BakedQuad> getFaceQuads(EnumFacing p_177551_1_)
// {
// return emptyQuads;
// }
@Override
public List<BakedQuad> getQuads(@Nullable IBlockState blockState, @Nullable EnumFacing side, long rand) {
if (bakedQuads == null) {
try {
bakedQuads = Collections.synchronizedSet(new LinkedHashSet<BakedQuad>());
float width = .25f;
float depth = .25f;
float wOff = (1 - width) / 2;
float dOff = (1 - depth) / 2;
int pixelLength = 0;
HashMap<TextureAtlasSprite, Integer> textureOre = new HashMap();
if (mineral != null && mineral.oreOutput != null) {
for (int i = 0; i < mineral.oreOutput.length; i++) if (mineral.oreOutput[i] != null) {
int weight = Math.max(2, Math.round(16 * mineral.recalculatedChances[i]));
Block b = Block.getBlockFromItem(mineral.oreOutput[i].getItem());
IBlockState state = b != null ? b.getStateFromMeta(mineral.oreOutput[i].getMetadata()) : Blocks.STONE.getDefaultState();
IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelForState(state);
if (model != null && model.getParticleTexture() != null)
textureOre.put(model.getParticleTexture(), weight);
pixelLength += weight;
}
} else
pixelLength = 16;
TextureAtlasSprite textureStone = ClientUtils.getSprite(new ResourceLocation("blocks/stone"));
Vector2f[] stoneUVs = { new Vector2f(textureStone.getInterpolatedU(16 * wOff), textureStone.getInterpolatedV(16 * dOff)), new Vector2f(textureStone.getInterpolatedU(16 * wOff), textureStone.getInterpolatedV(16 * (dOff + depth))), new Vector2f(textureStone.getInterpolatedU(16 * (wOff + width)), textureStone.getInterpolatedV(16 * (dOff + depth))), new Vector2f(textureStone.getInterpolatedU(16 * (wOff + width)), textureStone.getInterpolatedV(16 * dOff)) };
putVertexData(new Vector3f(0, -1, 0), new Vector3f[] { new Vector3f(wOff, 0, dOff), new Vector3f(wOff + width, 0, dOff), new Vector3f(wOff + width, 0, dOff + depth), new Vector3f(wOff, 0, dOff + depth) }, stoneUVs, textureStone);
putVertexData(new Vector3f(0, 1, 0), new Vector3f[] { new Vector3f(wOff, 1, dOff), new Vector3f(wOff, 1, dOff + depth), new Vector3f(wOff + width, 1, dOff + depth), new Vector3f(wOff + width, 1, dOff) }, stoneUVs, textureStone);
if (textureOre.isEmpty()) {
Vector2f[][] uvs = new Vector2f[4][];
for (int j = 0; j < 4; j++) uvs[j] = new Vector2f[] { new Vector2f(textureStone.getInterpolatedU(j * 4), textureStone.getInterpolatedV(0)), new Vector2f(textureStone.getInterpolatedU(j * 4), textureStone.getInterpolatedV(16)), new Vector2f(textureStone.getInterpolatedU((j + 1) * 4), textureStone.getInterpolatedV(16)), new Vector2f(textureStone.getInterpolatedU((j + 1) * 4), textureStone.getInterpolatedV(0)) };
putVertexData(new Vector3f(0, 0, -1), new Vector3f[] { new Vector3f(wOff, 0, dOff), new Vector3f(wOff, 1, dOff), new Vector3f(wOff + width, 1, dOff), new Vector3f(wOff + width, 0, dOff) }, uvs[0], textureStone);
putVertexData(new Vector3f(0, 0, 1), new Vector3f[] { new Vector3f(wOff + width, 0, dOff + depth), new Vector3f(wOff + width, 1, dOff + depth), new Vector3f(wOff, 1, dOff + depth), new Vector3f(wOff, 0, dOff + depth) }, uvs[2], textureStone);
putVertexData(new Vector3f(-1, 0, 0), new Vector3f[] { new Vector3f(wOff, 0, dOff + depth), new Vector3f(wOff, 1, dOff + depth), new Vector3f(wOff, 1, dOff), new Vector3f(wOff, 0, dOff) }, uvs[3], textureStone);
putVertexData(new Vector3f(1, 0, 0), new Vector3f[] { new Vector3f(wOff + width, 0, dOff), new Vector3f(wOff + width, 1, dOff), new Vector3f(wOff + width, 1, dOff + depth), new Vector3f(wOff + width, 0, dOff + depth) }, uvs[1], textureStone);
} else {
float h = 0;
for (TextureAtlasSprite sprite : textureOre.keySet()) {
int weight = textureOre.get(sprite);
int v = weight > 8 ? 16 - weight : 8;
Vector2f[][] uvs = new Vector2f[4][];
for (int j = 0; j < 4; j++) uvs[j] = new Vector2f[] { new Vector2f(sprite.getInterpolatedU(j * 4), sprite.getInterpolatedV(v)), new Vector2f(sprite.getInterpolatedU(j * 4), sprite.getInterpolatedV(v + weight)), new Vector2f(sprite.getInterpolatedU((j + 1) * 4), sprite.getInterpolatedV(v + weight)), new Vector2f(sprite.getInterpolatedU((j + 1) * 4), sprite.getInterpolatedV(v)) };
float h1 = weight / (float) pixelLength;
putVertexData(new Vector3f(0, 0, -1), new Vector3f[] { new Vector3f(wOff, h, dOff), new Vector3f(wOff, h + h1, dOff), new Vector3f(wOff + width, h + h1, dOff), new Vector3f(wOff + width, h, dOff) }, uvs[0], sprite);
putVertexData(new Vector3f(0, 0, 1), new Vector3f[] { new Vector3f(wOff + width, h, dOff + depth), new Vector3f(wOff + width, h + h1, dOff + depth), new Vector3f(wOff, h + h1, dOff + depth), new Vector3f(wOff, h, dOff + depth) }, uvs[2], sprite);
putVertexData(new Vector3f(-1, 0, 0), new Vector3f[] { new Vector3f(wOff, h, dOff + depth), new Vector3f(wOff, h + h1, dOff + depth), new Vector3f(wOff, h + h1, dOff), new Vector3f(wOff, h, dOff) }, uvs[3], sprite);
putVertexData(new Vector3f(1, 0, 0), new Vector3f[] { new Vector3f(wOff + width, h, dOff), new Vector3f(wOff + width, h + h1, dOff), new Vector3f(wOff + width, h + h1, dOff + depth), new Vector3f(wOff + width, h, dOff + depth) }, uvs[1], sprite);
h += h1;
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
if (bakedQuads != null && !bakedQuads.isEmpty()) {
List<BakedQuad> quadList = Collections.synchronizedList(Lists.newArrayList(bakedQuads));
return quadList;
}
return emptyQuads;
}
use of net.minecraft.client.renderer.texture.TextureAtlasSprite in project ImmersiveEngineering by BluSunrize.
the class EntityRenderChemthrowerShot method doRender.
@Override
public void doRender(Entity entity, double x, double y, double z, float f0, float f1) {
FluidStack f = ((EntityChemthrowerShot) entity).getFluid();
if (f == null) {
f = ((EntityChemthrowerShot) entity).getFluidSynced();
if (f == null)
return;
}
GlStateManager.pushMatrix();
GlStateManager.translate(x, y, z);
GlStateManager.enableRescaleNormal();
Tessellator tessellator = ClientUtils.tes();
GlStateManager.disableCull();
GlStateManager.rotate(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
GlStateManager.rotate(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
TextureAtlasSprite sprite = ClientUtils.mc().getTextureMapBlocks().getAtlasSprite(f.getFluid().getStill(f).toString());
if (sprite != null) {
int colour = f.getFluid().getColor(f);
float a = (colour >> 24 & 255) / 255f;
float r = (colour >> 16 & 255) / 255f;
float g = (colour >> 8 & 255) / 255f;
float b = (colour & 255) / 255f;
ClientUtils.bindAtlas();
GlStateManager.scale(.25f, .25f, .25f);
VertexBuffer worldrenderer = ClientUtils.tes().getBuffer();
worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
worldrenderer.pos(-.25, -.25, 0).tex(sprite.getInterpolatedU(4), sprite.getInterpolatedV(4)).color(r, g, b, a).endVertex();
worldrenderer.pos(.25, -.25, 0).tex(sprite.getInterpolatedU(0), sprite.getInterpolatedV(4)).color(r, g, b, a).endVertex();
worldrenderer.pos(.25, .25, 0).tex(sprite.getInterpolatedU(0), sprite.getInterpolatedV(0)).color(r, g, b, a).endVertex();
worldrenderer.pos(-.25, .25, 0).tex(sprite.getInterpolatedU(4), sprite.getInterpolatedV(0)).color(r, g, b, a).endVertex();
tessellator.draw();
}
GlStateManager.enableCull();
GlStateManager.disableRescaleNormal();
GlStateManager.popMatrix();
}
use of net.minecraft.client.renderer.texture.TextureAtlasSprite in project Railcraft by Railcraft.
the class LiquidSlot method draw.
@Override
public void draw(Renderer renderer, int recipeX, int recipeY, Object[] data, int dataIndex, boolean isMouseOver) {
int x = recipeX + this.x;
int y = recipeY + this.y;
if (data[dataIndex] instanceof FluidStack) {
FluidStack liquid = (FluidStack) data[dataIndex];
TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();
Fluid fluid = liquid.getFluid();
TextureAtlasSprite icon = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(fluid.getStill(liquid).toString());
if (icon != null) {
textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
double u = icon.getInterpolatedU(3.0);
double u2 = icon.getInterpolatedU(13.0);
double v = icon.getInterpolatedV(1.0);
double v2 = icon.getInterpolatedV(15.0);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
GL11.glBegin(GL11.GL_QUADS);
GL11.glTexCoord2d(u, v);
GL11.glVertex2i(x + 3, y + 1);
GL11.glTexCoord2d(u, v2);
GL11.glVertex2i(x + 3, y + 15);
GL11.glTexCoord2d(u2, v2);
GL11.glVertex2i(x + 13, y + 15);
GL11.glTexCoord2d(u2, v);
GL11.glVertex2i(x + 13, y + 1);
GL11.glEnd();
}
}
renderer.renderRect(x - 1, y - 1, 18, 18, containerTexture);
}
use of net.minecraft.client.renderer.texture.TextureAtlasSprite in project Railcraft by Railcraft.
the class FluidGaugeWidget method draw.
//TODO: test render
@Override
public void draw(GuiContainerRailcraft gui, int guiX, int guiY, int mouseX, int mouseY) {
if (tank == null)
return;
FluidStack fluidStack = tank.getFluid();
if (fluidStack == null || fluidStack.amount <= 0)
return;
TextureAtlasSprite fluidIcon = FluidRenderer.getFluidTexture(fluidStack, FluidRenderer.FlowState.STILL);
if (fluidIcon == null)
return;
float scale = Math.min(fluidStack.amount, tank.getCapacity()) / (float) tank.getCapacity();
gui.bindTexture(FluidRenderer.getFluidSheet(fluidStack));
FluidRenderer.setColorForFluid(fluidStack);
for (int col = 0; col < w / 16; col++) {
for (int row = 0; row <= h / 16; row++) {
gui.drawTexturedModalRect(guiX + x + col * 16, guiY + y + row * 16 - 1, fluidIcon, 16, 16);
}
}
OpenGL.glColor4f(1, 1, 1, 1);
gui.bindTexture(gui.texture);
gui.drawTexturedModalRect(guiX + x, guiY + y - 1, x, y - 1, w, h - (int) Math.floor(h * scale) + 1);
gui.drawTexturedModalRect(guiX + x, guiY + y, u, v, w, h);
}
Aggregations