Java Code Examples for net.minecraft.client.renderer.texture.TextureMap#getAtlasSprite()

The following examples show how to use net.minecraft.client.renderer.texture.TextureMap#getAtlasSprite() . 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: MetaTileEntityRenderer.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean renderBlock(IBlockAccess world, BlockPos pos, IBlockState state, BufferBuilder buffer) {
    MetaTileEntity metaTileEntity = BlockMachine.getMetaTileEntity(world, pos);
    if (metaTileEntity == null) {
        return false;
    }
    CCRenderState renderState = CCRenderState.instance();
    renderState.reset();
    renderState.bind(buffer);
    Matrix4 translation = new Matrix4().translate(pos.getX(), pos.getY(), pos.getZ());
    BlockRenderLayer renderLayer = MinecraftForgeClient.getRenderLayer();
    if (metaTileEntity.canRenderInLayer(renderLayer)) {
        renderState.lightMatrix.locate(world, pos);
        IVertexOperation[] pipeline = new IVertexOperation[]{renderState.lightMatrix};
        metaTileEntity.renderMetaTileEntity(renderState, translation.copy(), pipeline);
    }
    Matrix4 coverTranslation = new Matrix4().translate(pos.getX(), pos.getY(), pos.getZ());
    metaTileEntity.renderCovers(renderState, coverTranslation, renderLayer);

    if (metaTileEntity.isFragile() && renderLayer == BlockRenderLayer.CUTOUT) {
        TextureMap textureMap = Minecraft.getMinecraft().getTextureMapBlocks();
        Random posRand = new Random(MathHelper.getPositionRandom(pos));
        int destroyStage = posRand.nextInt(10);
        TextureAtlasSprite atlasSprite = textureMap.getAtlasSprite("minecraft:blocks/destroy_stage_" + destroyStage);
        for (EnumFacing face : EnumFacing.VALUES) {
            Textures.renderFace(renderState, translation, new IVertexOperation[0], face, Cuboid6.full, atlasSprite);
        }
    }
    return true;
}
 
Example 2
Source File: ToolRenderHandler.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void updateDestroyBlockIcons() {
    Minecraft mc = Minecraft.getMinecraft();
    TextureMap texturemap = mc.getTextureMapBlocks();

    for (int i = 0; i < destroyBlockIcons.length; ++i) {
        this.destroyBlockIcons[i] = texturemap.getAtlasSprite("minecraft:blocks/destroy_stage_" + i);
    }
}