java类net.minecraft.client.renderer.texture.TextureUtil的实例源码

ItemStackUtils.java 文件源码 项目:Industrial-Foregoing 阅读 26 收藏 0 点赞 0 评论 0
private static void renderQuads(BufferBuilder renderer, List<BakedQuad> quads, int color, ItemStack stack) {
    boolean flag = color == -1 && !stack.isEmpty();
    int i = 0;

    for (int j = quads.size(); i < j; ++i) {
        BakedQuad bakedquad = (BakedQuad) quads.get(i);
        int k = color;

        if (flag && bakedquad.hasTintIndex()) {
            k = Minecraft.getMinecraft().getItemColors().colorMultiplier(stack, bakedquad.getTintIndex());
            if (EntityRenderer.anaglyphEnable) {
                k = TextureUtil.anaglyphColor(k);
            }

            k = k | -16777216;
        }

        net.minecraftforge.client.model.pipeline.LightUtil.renderQuadColor(renderer, bakedquad, k);
    }
}
RenderModel.java 文件源码 项目:DankNull 阅读 25 收藏 0 点赞 0 评论 0
public static void renderQuads(VertexBuffer renderer, List<BakedQuad> quads, int color, ItemStack stack) {
    boolean flag = (color == -1) && (!stack.isEmpty());
    int i = 0;
    for (int j = quads.size(); i < j; i++) {
        BakedQuad bakedquad = quads.get(i);
        int k = color;
        if ((flag) && (bakedquad.hasTintIndex())) {
            ItemColors itemColors = Minecraft.getMinecraft().getItemColors();
            k = itemColors.getColorFromItemstack(stack, bakedquad.getTintIndex());
            if (EntityRenderer.anaglyphEnable) {
                k = TextureUtil.anaglyphColor(k);
            }
            k |= 0xFF000000;
        }
        LightUtil.renderQuadColor(renderer, bakedquad, k);
    }
}
RenderItem.java 文件源码 项目:DecompiledMinecraft 阅读 22 收藏 0 点赞 0 评论 0
private void renderQuads(WorldRenderer renderer, List<BakedQuad> quads, int color, ItemStack stack)
{
    boolean flag = color == -1 && stack != null;
    int i = 0;

    for (int j = quads.size(); i < j; ++i)
    {
        BakedQuad bakedquad = (BakedQuad)quads.get(i);
        int k = color;

        if (flag && bakedquad.hasTintIndex())
        {
            k = stack.getItem().getColorFromItemStack(stack, bakedquad.getTintIndex());

            if (EntityRenderer.anaglyphEnable)
            {
                k = TextureUtil.anaglyphColor(k);
            }

            k = k | -16777216;
        }

        this.renderQuad(renderer, bakedquad, k);
    }
}
BlockModelRenderer.java 文件源码 项目:DecompiledMinecraft 阅读 24 收藏 0 点赞 0 评论 0
public void renderModelBrightness(IBakedModel p_178266_1_, IBlockState p_178266_2_, float p_178266_3_, boolean p_178266_4_)
{
    Block block = p_178266_2_.getBlock();
    block.setBlockBoundsForItemRender();
    GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F);
    int i = block.getRenderColor(block.getStateForEntityRender(p_178266_2_));

    if (EntityRenderer.anaglyphEnable)
    {
        i = TextureUtil.anaglyphColor(i);
    }

    float f = (float)(i >> 16 & 255) / 255.0F;
    float f1 = (float)(i >> 8 & 255) / 255.0F;
    float f2 = (float)(i & 255) / 255.0F;

    if (!p_178266_4_)
    {
        GlStateManager.color(p_178266_3_, p_178266_3_, p_178266_3_, 1.0F);
    }

    this.renderModelBrightnessColor(p_178266_1_, p_178266_3_, f, f1, f2);
}
ThreadDownloadImageData.java 文件源码 项目:DecompiledMinecraft 阅读 23 收藏 0 点赞 0 评论 0
private void checkTextureUploaded()
{
    if (!this.textureUploaded)
    {
        if (this.bufferedImage != null)
        {
            if (this.textureLocation != null)
            {
                this.deleteGlTexture();
            }

            TextureUtil.uploadTextureImage(super.getGlTextureId(), this.bufferedImage);
            this.textureUploaded = true;
        }
    }
}
WurstFont.java 文件源码 项目:Wurst-MC-1.12 阅读 22 收藏 0 点赞 0 评论 0
public void drawString(final String text, double x, double y,
    final Color color, final boolean shadow)
{
    x *= 2;
    y = y * 2 - 2;
    glPushMatrix();
    // glHint(GL11.GL_POLYGON_SMOOTH_HINT, GL11.GL_NICEST);
    glScaled(0.25D, 0.25D, 0.25D);
    // glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    TextureUtil.bindTexture(texID);
    glColor(shadow ? new Color(0.05F, 0.05F, 0.05F, color.getAlpha() / 255F)
        : color);
    final int size = text.length();
    for(int indexInString = 0; indexInString < size; indexInString++)
    {
        final char character = text.charAt(indexInString);
        if(character < chars.length && character >= 0)
        {
            drawChar(character, (float)x, (float)y);
            x += chars[character].width - charOffset;
        }
    }
    glPopMatrix();
}
ShadersTex.java 文件源码 项目:BaseClient 阅读 49 收藏 0 点赞 0 评论 0
public static void initDynamicTexture(int texID, int width, int height, DynamicTexture tex)
{
    MultiTexID multitexid = tex.getMultiTexID();
    int[] aint = tex.getTextureData();
    int i = width * height;
    Arrays.fill(aint, i, i * 2, -8421377);
    Arrays.fill((int[])aint, i * 2, i * 3, (int)0);
    TextureUtil.allocateTexture(multitexid.base, width, height);
    TextureUtil.setTextureBlurMipmap(false, false);
    TextureUtil.setTextureClamped(false);
    TextureUtil.allocateTexture(multitexid.norm, width, height);
    TextureUtil.setTextureBlurMipmap(false, false);
    TextureUtil.setTextureClamped(false);
    TextureUtil.allocateTexture(multitexid.spec, width, height);
    TextureUtil.setTextureBlurMipmap(false, false);
    TextureUtil.setTextureClamped(false);
    GlStateManager.bindTexture(multitexid.base);
}
ShadersTex.java 文件源码 项目:BaseClient 阅读 29 收藏 0 点赞 0 评论 0
public static void allocateTextureMap(int texID, int mipmapLevels, int width, int height, Stitcher stitcher, TextureMap tex)
{
    SMCLog.info("allocateTextureMap " + mipmapLevels + " " + width + " " + height + " ");
    updatingTextureMap = tex;
    tex.atlasWidth = width;
    tex.atlasHeight = height;
    MultiTexID multitexid = getMultiTexID(tex);
    updatingTex = multitexid;
    TextureUtil.allocateTextureImpl(multitexid.base, mipmapLevels, width, height);

    if (Shaders.configNormalMap)
    {
        TextureUtil.allocateTextureImpl(multitexid.norm, mipmapLevels, width, height);
    }

    if (Shaders.configSpecularMap)
    {
        TextureUtil.allocateTextureImpl(multitexid.spec, mipmapLevels, width, height);
    }

    GlStateManager.bindTexture(texID);
}
ShadersTex.java 文件源码 项目:BaseClient 阅读 27 收藏 0 点赞 0 评论 0
public static void uploadTexSubForLoadAtlas(int[][] data, int width, int height, int xoffset, int yoffset, boolean linear, boolean clamp)
{
    TextureUtil.uploadTextureMipmap(data, width, height, xoffset, yoffset, linear, clamp);
    boolean flag = false;

    if (Shaders.configNormalMap)
    {
        int[][] aint = readImageAndMipmaps(iconName + "_n", width, height, data.length, flag, -8421377);
        GlStateManager.bindTexture(updatingTex.norm);
        TextureUtil.uploadTextureMipmap(aint, width, height, xoffset, yoffset, linear, clamp);
    }

    if (Shaders.configSpecularMap)
    {
        int[][] aint1 = readImageAndMipmaps(iconName + "_s", width, height, data.length, flag, 0);
        GlStateManager.bindTexture(updatingTex.spec);
        TextureUtil.uploadTextureMipmap(aint1, width, height, xoffset, yoffset, linear, clamp);
    }

    GlStateManager.bindTexture(updatingTex.base);
}
ShadersTex.java 文件源码 项目:BaseClient 阅读 29 收藏 0 点赞 0 评论 0
public static void uploadTexSub(int[][] data, int width, int height, int xoffset, int yoffset, boolean linear, boolean clamp)
{
    TextureUtil.uploadTextureMipmap(data, width, height, xoffset, yoffset, linear, clamp);

    if (Shaders.configNormalMap || Shaders.configSpecularMap)
    {
        if (Shaders.configNormalMap)
        {
            GlStateManager.bindTexture(updatingTex.norm);
            uploadTexSub1(data, width, height, xoffset, yoffset, 1);
        }

        if (Shaders.configSpecularMap)
        {
            GlStateManager.bindTexture(updatingTex.spec);
            uploadTexSub1(data, width, height, xoffset, yoffset, 2);
        }

        GlStateManager.bindTexture(updatingTex.base);
    }
}
BlockModelRenderer.java 文件源码 项目:BaseClient 阅读 24 收藏 0 点赞 0 评论 0
public void renderModelBrightness(IBakedModel p_178266_1_, IBlockState p_178266_2_, float p_178266_3_, boolean p_178266_4_)
{
    Block block = p_178266_2_.getBlock();
    block.setBlockBoundsForItemRender();
    GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F);
    int i = block.getRenderColor(block.getStateForEntityRender(p_178266_2_));

    if (EntityRenderer.anaglyphEnable)
    {
        i = TextureUtil.anaglyphColor(i);
    }

    float f = (float)(i >> 16 & 255) / 255.0F;
    float f1 = (float)(i >> 8 & 255) / 255.0F;
    float f2 = (float)(i & 255) / 255.0F;

    if (!p_178266_4_)
    {
        GlStateManager.color(p_178266_3_, p_178266_3_, p_178266_3_, 1.0F);
    }

    this.renderModelBrightnessColor(p_178266_1_, p_178266_3_, f, f1, f2);
}
RenderItem.java 文件源码 项目:BaseClient 阅读 24 收藏 0 点赞 0 评论 0
private void renderQuads(WorldRenderer renderer, List<BakedQuad> quads, int color, ItemStack stack)
{
    boolean flag = color == -1 && stack != null;
    int i = 0;

    for (int j = quads.size(); i < j; ++i)
    {
        BakedQuad bakedquad = (BakedQuad)quads.get(i);
        int k = color;

        if (flag && bakedquad.hasTintIndex())
        {
            k = stack.getItem().getColorFromItemStack(stack, bakedquad.getTintIndex());

            if (EntityRenderer.anaglyphEnable)
            {
                k = TextureUtil.anaglyphColor(k);
            }

            k = k | -16777216;
        }

        this.renderQuad(renderer, bakedquad, k);
    }
}
BlockModelRenderer.java 文件源码 项目:BaseClient 阅读 23 收藏 0 点赞 0 评论 0
public void renderModelBrightness(IBakedModel p_178266_1_, IBlockState p_178266_2_, float p_178266_3_, boolean p_178266_4_)
{
    Block block = p_178266_2_.getBlock();
    block.setBlockBoundsForItemRender();
    GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F);
    int i = block.getRenderColor(block.getStateForEntityRender(p_178266_2_));

    if (EntityRenderer.anaglyphEnable)
    {
        i = TextureUtil.anaglyphColor(i);
    }

    float f = (float)(i >> 16 & 255) / 255.0F;
    float f1 = (float)(i >> 8 & 255) / 255.0F;
    float f2 = (float)(i & 255) / 255.0F;

    if (!p_178266_4_)
    {
        GlStateManager.color(p_178266_3_, p_178266_3_, p_178266_3_, 1.0F);
    }

    this.renderModelBrightnessColor(p_178266_1_, p_178266_3_, f, f1, f2);
}
IFont.java 文件源码 项目:EMC 阅读 21 收藏 0 点赞 0 评论 0
public void drawString(final String text, double x, double y, final Color color, final boolean shadow) {
    x *= 2;
    y = y * 2 - 2;
    glPushMatrix();
    // glHint(GL11.GL_POLYGON_SMOOTH_HINT, GL11.GL_NICEST);
    glScaled(0.25D, 0.25D, 0.25D);
    // glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    TextureUtil.bindTexture(texID);
    glColor(shadow ? new Color(0.05F, 0.05F, 0.05F, color.getAlpha() / 255F) : color);
    final int size = text.length();
    for (int indexInString = 0; indexInString < size; indexInString++) {
        final char character = text.charAt(indexInString);
        if (character < chars.length && character >= 0) {
            drawChar(character, (float) x, (float) y);
            x += chars[character].width - charOffset;
        }
    }
    glPopMatrix();
}
ShadersTex.java 文件源码 项目:Backmemed 阅读 36 收藏 0 点赞 0 评论 0
public static void initDynamicTexture(int texID, int width, int height, DynamicTexture tex)
{
    MultiTexID multitexid = tex.getMultiTexID();
    int[] aint = tex.getTextureData();
    int i = width * height;
    Arrays.fill(aint, i, i * 2, -8421377);
    Arrays.fill((int[])aint, i * 2, i * 3, (int)0);
    TextureUtil.allocateTexture(multitexid.base, width, height);
    TextureUtil.setTextureBlurMipmap(false, false);
    TextureUtil.setTextureClamped(false);
    TextureUtil.allocateTexture(multitexid.norm, width, height);
    TextureUtil.setTextureBlurMipmap(false, false);
    TextureUtil.setTextureClamped(false);
    TextureUtil.allocateTexture(multitexid.spec, width, height);
    TextureUtil.setTextureBlurMipmap(false, false);
    TextureUtil.setTextureClamped(false);
    GlStateManager.bindTexture(multitexid.base);
}
ShadersTex.java 文件源码 项目:Backmemed 阅读 21 收藏 0 点赞 0 评论 0
public static void allocateTextureMap(int texID, int mipmapLevels, int width, int height, Stitcher stitcher, TextureMap tex)
{
    SMCLog.info("allocateTextureMap " + mipmapLevels + " " + width + " " + height + " ");
    updatingTextureMap = tex;
    tex.atlasWidth = width;
    tex.atlasHeight = height;
    MultiTexID multitexid = getMultiTexID(tex);
    updatingTex = multitexid;
    TextureUtil.allocateTextureImpl(multitexid.base, mipmapLevels, width, height);

    if (Shaders.configNormalMap)
    {
        TextureUtil.allocateTextureImpl(multitexid.norm, mipmapLevels, width, height);
    }

    if (Shaders.configSpecularMap)
    {
        TextureUtil.allocateTextureImpl(multitexid.spec, mipmapLevels, width, height);
    }

    GlStateManager.bindTexture(texID);
}
ShadersTex.java 文件源码 项目:Backmemed 阅读 23 收藏 0 点赞 0 评论 0
public static void uploadTexSubForLoadAtlas(int[][] data, int width, int height, int xoffset, int yoffset, boolean linear, boolean clamp)
{
    TextureUtil.uploadTextureMipmap(data, width, height, xoffset, yoffset, linear, clamp);
    boolean flag = false;

    if (Shaders.configNormalMap)
    {
        int[][] aint = readImageAndMipmaps(iconName + "_n", width, height, data.length, flag, -8421377);
        GlStateManager.bindTexture(updatingTex.norm);
        TextureUtil.uploadTextureMipmap(aint, width, height, xoffset, yoffset, linear, clamp);
    }

    if (Shaders.configSpecularMap)
    {
        int[][] aint1 = readImageAndMipmaps(iconName + "_s", width, height, data.length, flag, 0);
        GlStateManager.bindTexture(updatingTex.spec);
        TextureUtil.uploadTextureMipmap(aint1, width, height, xoffset, yoffset, linear, clamp);
    }

    GlStateManager.bindTexture(updatingTex.base);
}
ShadersTex.java 文件源码 项目:Backmemed 阅读 24 收藏 0 点赞 0 评论 0
public static void uploadTexSub(int[][] data, int width, int height, int xoffset, int yoffset, boolean linear, boolean clamp)
{
    TextureUtil.uploadTextureMipmap(data, width, height, xoffset, yoffset, linear, clamp);

    if (Shaders.configNormalMap || Shaders.configSpecularMap)
    {
        if (Shaders.configNormalMap)
        {
            GlStateManager.bindTexture(updatingTex.norm);
            uploadTexSub1(data, width, height, xoffset, yoffset, 1);
        }

        if (Shaders.configSpecularMap)
        {
            GlStateManager.bindTexture(updatingTex.spec);
            uploadTexSub1(data, width, height, xoffset, yoffset, 2);
        }

        GlStateManager.bindTexture(updatingTex.base);
    }
}
SimpleShaderTexture.java 文件源码 项目:Backmemed 阅读 30 收藏 0 点赞 0 评论 0
public void loadTexture(IResourceManager resourceManager) throws IOException
{
    this.deleteGlTexture();
    InputStream inputstream = Shaders.getShaderPackResourceStream(this.texturePath);

    if (inputstream == null)
    {
        throw new FileNotFoundException("Shader texture not found: " + this.texturePath);
    }
    else
    {
        try
        {
            BufferedImage bufferedimage = TextureUtil.readBufferedImage(inputstream);
            TextureMetadataSection texturemetadatasection = this.loadTextureMetadataSection();
            TextureUtil.uploadTextureImageAllocate(this.getGlTextureId(), bufferedimage, texturemetadatasection.getTextureBlur(), texturemetadatasection.getTextureClamp());
        }
        finally
        {
            IOUtils.closeQuietly(inputstream);
        }
    }
}
XFont.java 文件源码 项目:Backmemed 阅读 26 收藏 0 点赞 0 评论 0
public void drawString(final String text, double x, double y,
    final Color color, final boolean shadow)
{
    x *= 2;
    y = y * 2 - 2;
    glPushMatrix();
    glScaled(0.25D, 0.25D, 0.25D);
    TextureUtil.bindTexture(texID);
    glColor(shadow ? new Color(0.05F, 0.05F, 0.05F, color.getAlpha() / 255F)
        : color);
    final int size = text.length();
    for(int indexInString = 0; indexInString < size; indexInString++)
    {
        final char character = text.charAt(indexInString);
        if(character < chars.length && character >= 0)
        {
            drawChar(character, (float)x, (float)y);
            x += chars[character].width - charOffset;
        }
    }
    glPopMatrix();
}
BlockModelRenderer.java 文件源码 项目:Backmemed 阅读 27 收藏 0 点赞 0 评论 0
public void renderModelBrightness(IBakedModel model, IBlockState state, float brightness, boolean p_178266_4_)
{
    Block block = state.getBlock();
    GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F);
    int i = this.blockColors.colorMultiplier(state, (IBlockAccess)null, (BlockPos)null, 0);

    if (EntityRenderer.anaglyphEnable)
    {
        i = TextureUtil.anaglyphColor(i);
    }

    float f = (float)(i >> 16 & 255) / 255.0F;
    float f1 = (float)(i >> 8 & 255) / 255.0F;
    float f2 = (float)(i & 255) / 255.0F;

    if (!p_178266_4_)
    {
        GlStateManager.color(brightness, brightness, brightness, 1.0F);
    }

    this.renderModelBrightnessColor(state, model, brightness, f, f1, f2);
}
BlockModelRenderer.java 文件源码 项目:CustomWorldGen 阅读 22 收藏 0 点赞 0 评论 0
public void renderModelBrightness(IBakedModel model, IBlockState state, float brightness, boolean p_178266_4_)
{
    Block block = state.getBlock();
    GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F);
    int i = this.blockColors.colorMultiplier(state, (IBlockAccess)null, (BlockPos)null, 0);

    if (EntityRenderer.anaglyphEnable)
    {
        i = TextureUtil.anaglyphColor(i);
    }

    float f = (float)(i >> 16 & 255) / 255.0F;
    float f1 = (float)(i >> 8 & 255) / 255.0F;
    float f2 = (float)(i & 255) / 255.0F;

    if (!p_178266_4_)
    {
        GlStateManager.color(brightness, brightness, brightness, 1.0F);
    }

    this.renderModelBrightnessColor(state, model, brightness, f, f1, f2);
}
RenderItem.java 文件源码 项目:CustomWorldGen 阅读 23 收藏 0 点赞 0 评论 0
private void renderQuads(VertexBuffer renderer, List<BakedQuad> quads, int color, @Nullable ItemStack stack)
{
    boolean flag = color == -1 && stack != null;
    int i = 0;

    for (int j = quads.size(); i < j; ++i)
    {
        BakedQuad bakedquad = (BakedQuad)quads.get(i);
        int k = color;

        if (flag && bakedquad.hasTintIndex())
        {
            k = this.itemColors.getColorFromItemstack(stack, bakedquad.getTintIndex());

            if (EntityRenderer.anaglyphEnable)
            {
                k = TextureUtil.anaglyphColor(k);
            }

            k = k | -16777216;
        }

        net.minecraftforge.client.model.pipeline.LightUtil.renderQuadColor(renderer, bakedquad, k);
    }
}
ThreadDownloadImageData.java 文件源码 项目:CustomWorldGen 阅读 34 收藏 0 点赞 0 评论 0
private void checkTextureUploaded()
{
    if (!this.textureUploaded)
    {
        if (this.bufferedImage != null)
        {
            if (this.textureLocation != null)
            {
                this.deleteGlTexture();
            }

            TextureUtil.uploadTextureImage(super.getGlTextureId(), this.bufferedImage);
            this.textureUploaded = true;
        }
    }
}
FriendEntry.java 文件源码 项目:RewiMod 阅读 21 收藏 0 点赞 0 评论 0
public FriendEntry(String username, String status, String rank) {
    this.username = username;
    this.status = status;
    this.rank = rank;
    this.headLocation = new ResourceLocation("rewimod/" + username + "/head");

    try {
        URL obj = new URL("https://minotar.net/helm/" + username + "/32.png");
        HttpURLConnection con = (HttpURLConnection) obj.openConnection();

        // optional default is GET
        con.setRequestMethod("GET");

        //add request header
        con.setRequestProperty("User-Agent", "Minecraft");

        InputStream stream = con.getInputStream();
        this.headImage = TextureUtil.readBufferedImage(stream);
    } catch (Exception ex) {
    }
}
GuiRenderItemHelper.java 文件源码 项目:BrokkGUI 阅读 23 收藏 0 点赞 0 评论 0
private void renderQuads(BufferBuilder renderer, List<BakedQuad> quads, int color, ItemStack stack)
{
    boolean flag = color == -1 && !stack.isEmpty();
    int i = 0;

    for (int j = quads.size(); i < j; ++i)
    {
        BakedQuad bakedquad = quads.get(i);
        int k = color;

        if (flag && bakedquad.hasTintIndex())
        {
            k = this.mc.getItemColors().getColorFromItemstack(stack, bakedquad.getTintIndex());

            if (EntityRenderer.anaglyphEnable)
                k = TextureUtil.anaglyphColor(k);
            k = k | -16777216;
        }
        LightUtil.renderQuadColor(renderer, bakedquad, k);
    }
}
ThreadDownloadImageDataGC.java 文件源码 项目:4Space-5 阅读 29 收藏 0 点赞 0 评论 0
private void checkTextureUploaded()
{
    if (!this.textureUploaded)
    {
        if (this.bufferedImage != null)
        {
            if (this.textureLocation != null)
            {
                this.deleteGlTexture();
            }

            TextureUtil.uploadTextureImage(super.getGlTextureId(), this.bufferedImage);
            this.textureUploaded = true;
        }
    }
}
DynamicImageTexture.java 文件源码 项目:SignPicture 阅读 53 收藏 0 点赞 0 评论 0
@Override
public @Nonnull DynamicImageTexture loadDirect() {
    final int[][] mipdata = this.mipdata;
    if (mipdata!=null&&mipdata.length>=1) {
        final int id = getId();
        if (this.miplevel>=1) {
            TextureUtil.allocateTextureImpl(id, this.miplevel, this.width, this.height, Client.mc.gameSettings.anisotropicFiltering);
            TextureUtil.uploadTextureMipmap(mipdata, this.width, this.height, 0, 0, false, false);
        } else {
            TextureUtil.allocateTexture(id, this.width, this.height);
            TextureUtil.uploadTexture(id, mipdata[0], this.width, this.height);
        }
        this.mipdata = null;
    }
    return this;
}
RenderChameleonCreeper.java 文件源码 项目:ChameleonCreepersMod 阅读 35 收藏 0 点赞 0 评论 0
public static void convertTextureToGrayScale() throws IOException
{
    IResourceManager resourceManager = Minecraft.getMinecraft().getResourceManager();
    try
    {
        BufferedImage vanillaCreeperTextureData = TextureUtil.readBufferedImage(resourceManager.getResource(vanillaCreeperTexture).getInputStream());

        // Do the conversion to grayscale
        BufferedImage creeperTextureData = new BufferedImage(vanillaCreeperTextureData.getWidth(), vanillaCreeperTextureData.getHeight(), BufferedImage.TYPE_USHORT_GRAY);
        Graphics g = creeperTextureData.getGraphics();
        g.drawImage(vanillaCreeperTextureData, 0, 0, null);
        g.dispose();

        DynamicTexture dynamicGrayscaleCreeperTexture = new DynamicTexture(creeperTextureData);

        grayscaleCreeperTexture = new ResourceLocation(ChameleonCreepersMod.MODID, "textures/entity/creeper/chameleoncreeper.png");
        Minecraft.getMinecraft().getTextureManager().loadTexture(grayscaleCreeperTexture, dynamicGrayscaleCreeperTexture);
    }
    catch (IOException e)
    {
        e.printStackTrace();
    }
}
ManifestModInfo.java 文件源码 项目:OpenModLoader 阅读 21 收藏 0 点赞 0 评论 0
@Override
public ResourceLocation getLogoTexture() {
    if (logoTexture == null) {
        if (logoBytes != null || logo != null) {
            try {
                InputStream in;
                if (logoBytes == null) {
                    in = new URL(getModFile().toURI().toURL().toString() + '/' + logo).openStream();
                } else {
                    in = new ByteArrayInputStream(logoBytes);
                }
                BufferedImage image = TextureUtil.readBufferedImage(in);
                DynamicTexture texture = new DynamicTexture(image);
                this.logoTexture = Minecraft.getMinecraft().getTextureManager().getDynamicTextureLocation("mods/" + getModID(), texture);
                in.close();
                logoBytes = null;
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        } else {
            logoTexture = new ResourceLocation("textures/misc/unknown_server.png");
        }
    }
    return logoTexture;
}


问题


面经


文章

微信
公众号

扫码关注公众号