Search in sources :

Example 11 with TextureAtlasSprite

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();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) VertexBuffer(net.minecraft.client.renderer.VertexBuffer) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite)

Example 12 with TextureAtlasSprite

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);
}
Also used : SignalAspect(mods.railcraft.api.signals.SignalAspect) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) EnumFacing(net.minecraft.util.EnumFacing)

Example 13 with TextureAtlasSprite

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;
}
Also used : TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite)

Example 14 with TextureAtlasSprite

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);
}
Also used : TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite)

Example 15 with TextureAtlasSprite

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);
}
Also used : IModel(net.minecraftforge.client.model.IModel) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) ResourceLocation(net.minecraft.util.ResourceLocation) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) Nullable(jline.internal.Nullable)

Aggregations

TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)44 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)7 EnumFacing (net.minecraft.util.EnumFacing)7 ResourceLocation (net.minecraft.util.ResourceLocation)6 Matrix4 (blusunrize.immersiveengineering.common.util.chickenbones.Matrix4)5 IBlockState (net.minecraft.block.state.IBlockState)5 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)5 TileEntity (net.minecraft.tileentity.TileEntity)5 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)5 Tessellator (net.minecraft.client.renderer.Tessellator)4 IExtendedBlockState (net.minecraftforge.common.property.IExtendedBlockState)4 FluidStack (net.minecraftforge.fluids.FluidStack)4 Vector3f (org.lwjgl.util.vector.Vector3f)4 HashMap (java.util.HashMap)3 Block (net.minecraft.block.Block)3 TextureManager (net.minecraft.client.renderer.texture.TextureManager)3 ConveyorDirection (blusunrize.immersiveengineering.api.tool.ConveyorHandler.ConveyorDirection)2 Utils (blusunrize.immersiveengineering.common.util.Utils)2 ImmutableList (com.google.common.collect.ImmutableList)2 Map (java.util.Map)2