use of net.minecraft.client.renderer.texture.TextureAtlasSprite in project Railcraft by Railcraft.
the class TESRSignals method doRenderAspect.
protected void doRenderAspect(double x, double y, double z) {
Tessellator tessellator = Tessellator.getInstance();
VertexBuffer vertexBuffer = tessellator.getBuffer();
final float depth = 1.95F * RenderTools.PIXEL;
OpenGL.glPushMatrix();
// no idea why this is necessary, but without it the texture brightness varies depending on what is on screen
GL11.glNormal3f(0.0F, 0.0F, 1.0F);
OpenGL.glEnable(GL11.GL_LIGHTING);
OpenGL.glColor3f(1, 1, 1);
OpenGL.glTranslated(x, y, z);
Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
if (lampInfo.glow)
RenderTools.setBrightness(0.875F);
vertexBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
if (lampInfo.sides[2].render) {
TextureAtlasSprite texture = lampInfo.sides[2].texture;
vertexBuffer.pos(0, 0, depth).tex(texture.getInterpolatedU(16), texture.getInterpolatedV(16)).endVertex();
vertexBuffer.pos(0, 1, depth).tex(texture.getInterpolatedU(16), texture.getInterpolatedV(0)).endVertex();
vertexBuffer.pos(1, 1, depth).tex(texture.getInterpolatedU(0), texture.getInterpolatedV(0)).endVertex();
vertexBuffer.pos(1, 0, depth).tex(texture.getInterpolatedU(0), texture.getInterpolatedV(16)).endVertex();
}
if (lampInfo.sides[3].render) {
TextureAtlasSprite texture = lampInfo.sides[3].texture;
vertexBuffer.pos(0, 0, 1 - depth).tex(texture.getInterpolatedU(0), texture.getInterpolatedV(16)).endVertex();
vertexBuffer.pos(1, 0, 1 - depth).tex(texture.getInterpolatedU(16), texture.getInterpolatedV(16)).endVertex();
vertexBuffer.pos(1, 1, 1 - depth).tex(texture.getInterpolatedU(16), texture.getInterpolatedV(0)).endVertex();
vertexBuffer.pos(0, 1, 1 - depth).tex(texture.getInterpolatedU(0), texture.getInterpolatedV(0)).endVertex();
}
if (lampInfo.sides[4].render) {
TextureAtlasSprite texture = lampInfo.sides[4].texture;
vertexBuffer.pos(depth, 0, 0).tex(texture.getInterpolatedU(0), texture.getInterpolatedV(16)).endVertex();
vertexBuffer.pos(depth, 0, 1).tex(texture.getInterpolatedU(16), texture.getInterpolatedV(16)).endVertex();
vertexBuffer.pos(depth, 1, 1).tex(texture.getInterpolatedU(16), texture.getInterpolatedV(0)).endVertex();
vertexBuffer.pos(depth, 1, 0).tex(texture.getInterpolatedU(0), texture.getInterpolatedV(0)).endVertex();
}
if (lampInfo.sides[5].render) {
TextureAtlasSprite texture = lampInfo.sides[5].texture;
vertexBuffer.pos(1 - depth, 0, 0).tex(texture.getInterpolatedU(16), texture.getInterpolatedV(16)).endVertex();
vertexBuffer.pos(1 - depth, 1, 0).tex(texture.getInterpolatedU(16), texture.getInterpolatedV(0)).endVertex();
vertexBuffer.pos(1 - depth, 1, 1).tex(texture.getInterpolatedU(0), texture.getInterpolatedV(0)).endVertex();
vertexBuffer.pos(1 - depth, 0, 1).tex(texture.getInterpolatedU(0), texture.getInterpolatedV(16)).endVertex();
}
tessellator.draw();
if (lampInfo.glow)
RenderTools.resetBrightness();
lampInfo.resetSidesAndLight();
OpenGL.glPopMatrix();
}
use of net.minecraft.client.renderer.texture.TextureAtlasSprite in project Railcraft by Railcraft.
the class TESRSignalBox method renderTileEntityAt.
@Override
public void renderTileEntityAt(TileBoxBase tile, double x, double y, double z, float partialTicks, int destroyStage) {
super.renderTileEntityAt(tile, x, y, z, partialTicks, destroyStage);
// Aspect
for (EnumFacing side : EnumFacing.HORIZONTALS) {
SignalAspect aspect = tile.getBoxSignalAspect(side).getDisplayAspect();
TextureAtlasSprite texture = RenderTools.getTexture(BlockMachineSignalBox.lampTextures[aspect.getTextureIndex()]);
lampInfo.setTexture(side, texture);
lampInfo.glow = !aspect.isOffState();
lampInfo.setRenderSide(side, !tile.isConnected(side));
}
doRenderAspect(x, y, z);
}
use of net.minecraft.client.renderer.texture.TextureAtlasSprite in project CodeChickenLib by Chicken-Bones.
the class TextureUtils method getBlankIcon.
public static TextureAtlasSprite getBlankIcon(int size, TextureMap textureMap) {
String s = "blank_" + size;
TextureAtlasSprite icon = textureMap.getTextureExtry(s);
if (icon == null)
textureMap.setTextureEntry(s, icon = new TextureSpecial(s).blank(size));
return icon;
}
use of net.minecraft.client.renderer.texture.TextureAtlasSprite in project CodeChickenLib by Chicken-Bones.
the class MultiIconTransformation method apply.
@Override
public void apply(UV uv) {
TextureAtlasSprite icon = icons[uv.tex % icons.length];
uv.u = icon.getInterpolatedU(uv.u * 16);
uv.v = icon.getInterpolatedV(uv.v * 16);
}
use of net.minecraft.client.renderer.texture.TextureAtlasSprite in project Overloaded by CJ-MC-Mods.
the class ModelUtils method loadBakedModel.
public static IBakedModel loadBakedModel(ResourceLocation modelLocation) {
if (!bakedModelCache.containsKey(modelLocation)) {
try {
IModel model = ModelLoaderRegistry.getModel(modelLocation);
IBakedModel bakedModel = model.bake(TRSRTransformation.identity(), DefaultVertexFormats.ITEM, new Function<ResourceLocation, TextureAtlasSprite>() {
@Nullable
@Override
public TextureAtlasSprite apply(ResourceLocation input) {
return Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(input.toString());
}
});
bakedModelCache.put(modelLocation, bakedModel);
} catch (Exception e) {
System.err.println("Error at ModelUtils.loadBakedModel, Resource: " + modelLocation.toString());
throw new RuntimeException(e);
}
}
return bakedModelCache.get(modelLocation);
}
Aggregations