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

PotionSick.java 文件源码 项目:JustJunk 阅读 16 收藏 0 点赞 0 评论 0
public int getStatusIconIndex(){
    ITextureObject texture = Minecraft.getMinecraft().renderEngine.getTexture(icon);
    Minecraft.getMinecraft().renderEngine.bindTexture(icon);
    return super.getStatusIconIndex();
}
ShaderManager.java 文件源码 项目:DecompiledMinecraft 阅读 22 收藏 0 点赞 0 评论 0
public void useShader()
{
    this.isDirty = false;
    staticShaderManager = this;
    this.field_148016_p.func_148109_a();

    if (this.program != currentProgram)
    {
        OpenGlHelper.glUseProgram(this.program);
        currentProgram = this.program;
    }

    if (this.useFaceCulling)
    {
        GlStateManager.enableCull();
    }
    else
    {
        GlStateManager.disableCull();
    }

    for (int i = 0; i < this.shaderSamplerLocations.size(); ++i)
    {
        if (this.shaderSamplers.get(this.samplerNames.get(i)) != null)
        {
            GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit + i);
            GlStateManager.enableTexture2D();
            Object object = this.shaderSamplers.get(this.samplerNames.get(i));
            int j = -1;

            if (object instanceof Framebuffer)
            {
                j = ((Framebuffer)object).framebufferTexture;
            }
            else if (object instanceof ITextureObject)
            {
                j = ((ITextureObject)object).getGlTextureId();
            }
            else if (object instanceof Integer)
            {
                j = ((Integer)object).intValue();
            }

            if (j != -1)
            {
                GlStateManager.bindTexture(j);
                OpenGlHelper.glUniform1i(OpenGlHelper.glGetUniformLocation(this.program, (CharSequence)this.samplerNames.get(i)), i);
            }
        }
    }

    for (ShaderUniform shaderuniform : this.shaderUniforms)
    {
        shaderuniform.upload();
    }
}
SkinManager.java 文件源码 项目:DecompiledMinecraft 阅读 18 收藏 0 点赞 0 评论 0
/**
 * May download the skin if its not in the cache, can be passed a SkinManager#SkinAvailableCallback for handling
 */
public ResourceLocation loadSkin(final MinecraftProfileTexture profileTexture, final Type p_152789_2_, final SkinManager.SkinAvailableCallback skinAvailableCallback)
{
    final ResourceLocation resourcelocation = new ResourceLocation("skins/" + profileTexture.getHash());
    ITextureObject itextureobject = this.textureManager.getTexture(resourcelocation);

    if (itextureobject != null)
    {
        if (skinAvailableCallback != null)
        {
            skinAvailableCallback.skinAvailable(p_152789_2_, resourcelocation, profileTexture);
        }
    }
    else
    {
        File file1 = new File(this.skinCacheDir, profileTexture.getHash().length() > 2 ? profileTexture.getHash().substring(0, 2) : "xx");
        File file2 = new File(file1, profileTexture.getHash());
        final IImageBuffer iimagebuffer = p_152789_2_ == Type.SKIN ? new ImageBufferDownload() : null;
        ThreadDownloadImageData threaddownloadimagedata = new ThreadDownloadImageData(file2, profileTexture.getUrl(), DefaultPlayerSkin.getDefaultSkinLegacy(), new IImageBuffer()
        {
            public BufferedImage parseUserSkin(BufferedImage image)
            {
                if (iimagebuffer != null)
                {
                    image = iimagebuffer.parseUserSkin(image);
                }

                return image;
            }
            public void skinAvailable()
            {
                if (iimagebuffer != null)
                {
                    iimagebuffer.skinAvailable();
                }

                if (skinAvailableCallback != null)
                {
                    skinAvailableCallback.skinAvailable(p_152789_2_, resourcelocation, profileTexture);
                }
            }
        });
        this.textureManager.loadTexture(resourcelocation, threaddownloadimagedata);
    }

    return resourcelocation;
}
CapeUtils.java 文件源码 项目:BaseClient 阅读 14 收藏 0 点赞 0 评论 0
public static void downloadCape(final AbstractClientPlayer p_downloadCape_0_)
{
    String s = p_downloadCape_0_.getNameClear();

    if (s != null && !s.isEmpty())
    {
        String s1 = "http://s.optifine.net/capes/" + s + ".png";
        String s2 = FilenameUtils.getBaseName(s1);
        final ResourceLocation resourcelocation = new ResourceLocation("capeof/" + s2);
        TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
        ITextureObject itextureobject = texturemanager.getTexture(resourcelocation);

        if (itextureobject != null && itextureobject instanceof ThreadDownloadImageData)
        {
            ThreadDownloadImageData threaddownloadimagedata = (ThreadDownloadImageData)itextureobject;

            if (threaddownloadimagedata.imageFound != null)
            {
                if (threaddownloadimagedata.imageFound.booleanValue())
                {
                    p_downloadCape_0_.setLocationOfCape(resourcelocation);
                }

                return;
            }
        }

        IImageBuffer iimagebuffer = new IImageBuffer()
        {
            ImageBufferDownload ibd = new ImageBufferDownload();
            public BufferedImage parseUserSkin(BufferedImage image)
            {
                return CapeUtils.parseCape(image);
            }
            public void skinAvailable()
            {
                p_downloadCape_0_.setLocationOfCape(resourcelocation);
            }
        };
        ThreadDownloadImageData threaddownloadimagedata1 = new ThreadDownloadImageData((File)null, s1, (ResourceLocation)null, iimagebuffer);
        threaddownloadimagedata1.pipeline = true;
        texturemanager.loadTexture(resourcelocation, threaddownloadimagedata1);
    }
}
TextureAnimation.java 文件源码 项目:BaseClient 阅读 14 收藏 0 点赞 0 评论 0
public boolean updateTexture()
{
    if (this.dstTextId < 0)
    {
        ITextureObject itextureobject = TextureUtils.getTexture(this.dstTexLoc);

        if (itextureobject == null)
        {
            return false;
        }

        this.dstTextId = itextureobject.getGlTextureId();
    }

    if (this.imageData == null)
    {
        this.imageData = GLAllocation.createDirectByteBuffer(this.srcData.length);
        this.imageData.put(this.srcData);
        this.srcData = null;
    }

    if (!this.nextFrame())
    {
        return false;
    }
    else
    {
        int k = this.frameWidth * this.frameHeight * 4;
        int i = this.getActiveFrameIndex();
        int j = k * i;

        if (j + k > this.imageData.capacity())
        {
            return false;
        }
        else
        {
            this.imageData.position(j);
            GlStateManager.bindTexture(this.dstTextId);
            GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, this.dstX, this.dstY, this.frameWidth, this.frameHeight, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer)this.imageData);
            return true;
        }
    }
}
ShaderManager.java 文件源码 项目:BaseClient 阅读 24 收藏 0 点赞 0 评论 0
public void useShader()
{
    this.isDirty = false;
    staticShaderManager = this;
    this.field_148016_p.func_148109_a();

    if (this.program != currentProgram)
    {
        OpenGlHelper.glUseProgram(this.program);
        currentProgram = this.program;
    }

    if (this.useFaceCulling)
    {
        GlStateManager.enableCull();
    }
    else
    {
        GlStateManager.disableCull();
    }

    for (int i = 0; i < this.shaderSamplerLocations.size(); ++i)
    {
        if (this.shaderSamplers.get(this.samplerNames.get(i)) != null)
        {
            GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit + i);
            GlStateManager.enableTexture2D();
            Object object = this.shaderSamplers.get(this.samplerNames.get(i));
            int j = -1;

            if (object instanceof Framebuffer)
            {
                j = ((Framebuffer)object).framebufferTexture;
            }
            else if (object instanceof ITextureObject)
            {
                j = ((ITextureObject)object).getGlTextureId();
            }
            else if (object instanceof Integer)
            {
                j = ((Integer)object).intValue();
            }

            if (j != -1)
            {
                GlStateManager.bindTexture(j);
                OpenGlHelper.glUniform1i(OpenGlHelper.glGetUniformLocation(this.program, (CharSequence)this.samplerNames.get(i)), i);
            }
        }
    }

    for (ShaderUniform shaderuniform : this.shaderUniforms)
    {
        shaderuniform.upload();
    }
}
SkinManager.java 文件源码 项目:BaseClient 阅读 29 收藏 0 点赞 0 评论 0
/**
 * May download the skin if its not in the cache, can be passed a SkinManager#SkinAvailableCallback for handling
 */
public ResourceLocation loadSkin(final MinecraftProfileTexture profileTexture, final Type p_152789_2_, final SkinManager.SkinAvailableCallback skinAvailableCallback)
{
    final ResourceLocation resourcelocation = new ResourceLocation("skins/" + profileTexture.getHash());
    ITextureObject itextureobject = this.textureManager.getTexture(resourcelocation);

    if (itextureobject != null)
    {
        if (skinAvailableCallback != null)
        {
            skinAvailableCallback.skinAvailable(p_152789_2_, resourcelocation, profileTexture);
        }
    }
    else
    {
        File file1 = new File(this.skinCacheDir, profileTexture.getHash().length() > 2 ? profileTexture.getHash().substring(0, 2) : "xx");
        File file2 = new File(file1, profileTexture.getHash());
        final IImageBuffer iimagebuffer = p_152789_2_ == Type.SKIN ? new ImageBufferDownload() : null;
        ThreadDownloadImageData threaddownloadimagedata = new ThreadDownloadImageData(file2, profileTexture.getUrl(), DefaultPlayerSkin.getDefaultSkinLegacy(), new IImageBuffer()
        {
            public BufferedImage parseUserSkin(BufferedImage image)
            {
                if (iimagebuffer != null)
                {
                    image = iimagebuffer.parseUserSkin(image);
                }

                return image;
            }
            public void skinAvailable()
            {
                if (iimagebuffer != null)
                {
                    iimagebuffer.skinAvailable();
                }

                if (skinAvailableCallback != null)
                {
                    skinAvailableCallback.skinAvailable(p_152789_2_, resourcelocation, profileTexture);
                }
            }
        });
        this.textureManager.loadTexture(resourcelocation, threaddownloadimagedata);
    }

    return resourcelocation;
}
TextureUtils.java 文件源码 项目:BaseClient 阅读 23 收藏 0 点赞 0 评论 0
public static ITextureObject getTexture(String p_getTexture_0_)
{
    return getTexture(new ResourceLocation(p_getTexture_0_));
}
TextureAnimation.java 文件源码 项目:BaseClient 阅读 15 收藏 0 点赞 0 评论 0
public boolean updateTexture()
{
    if (this.dstTextId < 0)
    {
        ITextureObject itextureobject = TextureUtils.getTexture(this.dstTexLoc);

        if (itextureobject == null)
        {
            return false;
        }

        this.dstTextId = itextureobject.getGlTextureId();
    }

    if (this.imageData == null)
    {
        this.imageData = GLAllocation.createDirectByteBuffer(this.srcData.length);
        this.imageData.put(this.srcData);
        this.srcData = null;
    }

    if (!this.nextFrame())
    {
        return false;
    }
    else
    {
        int k = this.frameWidth * this.frameHeight * 4;
        int i = this.getActiveFrameIndex();
        int j = k * i;

        if (j + k > this.imageData.capacity())
        {
            return false;
        }
        else
        {
            this.imageData.position(j);
            GlStateManager.bindTexture(this.dstTextId);
            GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, this.dstX, this.dstY, this.frameWidth, this.frameHeight, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer)this.imageData);
            return true;
        }
    }
}
AbstractClientPlayer.java 文件源码 项目:BaseClient 阅读 24 收藏 0 点赞 0 评论 0
private void downloadCape(String p_downloadCape_1_)
{
    if (p_downloadCape_1_ != null && !p_downloadCape_1_.isEmpty())
    {
        p_downloadCape_1_ = StringUtils.stripControlCodes(p_downloadCape_1_);
        String s = "http://s.optifine.net/capes/" + p_downloadCape_1_ + ".png";
        String s1 = FilenameUtils.getBaseName(s);
        final ResourceLocation resourcelocation = new ResourceLocation("capeof/" + s1);
        TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
        ITextureObject itextureobject = texturemanager.getTexture(resourcelocation);

        if (itextureobject != null && itextureobject instanceof ThreadDownloadImageData)
        {
            ThreadDownloadImageData threaddownloadimagedata = (ThreadDownloadImageData)itextureobject;

            if (threaddownloadimagedata.imageFound != null)
            {
                if (threaddownloadimagedata.imageFound.booleanValue())
                {
                    this.ofLocationCape = resourcelocation;
                }

                return;
            }
        }

        IImageBuffer iimagebuffer = new IImageBuffer()
        {
            ImageBufferDownload ibd = new ImageBufferDownload();
            public BufferedImage parseUserSkin(BufferedImage image)
            {
                return AbstractClientPlayer.this.parseCape(image);
            }
            public void skinAvailable()
            {
                AbstractClientPlayer.this.ofLocationCape = resourcelocation;
            }
        };
        ThreadDownloadImageData threaddownloadimagedata1 = new ThreadDownloadImageData((File)null, s, (ResourceLocation)null, iimagebuffer);
        texturemanager.loadTexture(resourcelocation, threaddownloadimagedata1);
    }
}


问题


面经


文章

微信
公众号

扫码关注公众号