public static void bindTexture(ITextureObject tex) { int i = tex.getGlTextureId(); if (tex instanceof TextureMap) { Shaders.atlasSizeX = ((TextureMap)tex).atlasWidth; Shaders.atlasSizeY = ((TextureMap)tex).atlasHeight; bindTextures(tex.getMultiTexID()); } else { Shaders.atlasSizeX = 0; Shaders.atlasSizeY = 0; bindTextures(tex.getMultiTexID()); } }
static void updateTextureMinMagFilter() { TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); ITextureObject itextureobject = texturemanager.getTexture(TextureMap.locationBlocksTexture); if (itextureobject != null) { MultiTexID multitexid = itextureobject.getMultiTexID(); GlStateManager.bindTexture(multitexid.base); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, Shaders.texMinFilValue[Shaders.configTexMinFilB]); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, Shaders.texMagFilValue[Shaders.configTexMagFilB]); GlStateManager.bindTexture(multitexid.norm); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, Shaders.texMinFilValue[Shaders.configTexMinFilN]); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, Shaders.texMagFilValue[Shaders.configTexMagFilN]); GlStateManager.bindTexture(multitexid.spec); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, Shaders.texMinFilValue[Shaders.configTexMinFilS]); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, Shaders.texMagFilValue[Shaders.configTexMagFilS]); GlStateManager.bindTexture(0); } }
public float getTextureWidth(TextureManager p_getTextureWidth_1_) { if (this.textureWidth <= 0) { if (this.textureLocation != null) { ITextureObject itextureobject = p_getTextureWidth_1_.getTexture(this.textureLocation); int i = itextureobject.getGlTextureId(); int j = GlStateManager.getBoundTexture(); GlStateManager.bindTexture(i); this.textureWidth = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, 0, GL11.GL_TEXTURE_WIDTH); GlStateManager.bindTexture(j); } if (this.textureWidth <= 0) { this.textureWidth = 16; } } return (float)this.textureWidth; }
public float getTextureHeight(TextureManager p_getTextureHeight_1_) { if (this.textureHeight <= 0) { if (this.textureLocation != null) { ITextureObject itextureobject = p_getTextureHeight_1_.getTexture(this.textureLocation); int i = itextureobject.getGlTextureId(); int j = GlStateManager.getBoundTexture(); GlStateManager.bindTexture(i); this.textureHeight = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, 0, GL11.GL_TEXTURE_HEIGHT); GlStateManager.bindTexture(j); } if (this.textureHeight <= 0) { this.textureHeight = 16; } } return (float)this.textureHeight; }
public static ITextureObject getTexture(ResourceLocation p_getTexture_0_) { ITextureObject itextureobject = Config.getTextureManager().getTexture(p_getTexture_0_); if (itextureobject != null) { return itextureobject; } else if (!Config.hasResource(p_getTexture_0_)) { return null; } else { SimpleTexture simpletexture = new SimpleTexture(p_getTexture_0_); Config.getTextureManager().loadTexture(p_getTexture_0_, simpletexture); return simpletexture; } }
static void updateTextureMinMagFilter() { TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); ITextureObject itextureobject = texturemanager.getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); if (itextureobject != null) { MultiTexID multitexid = itextureobject.getMultiTexID(); GlStateManager.bindTexture(multitexid.base); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, Shaders.texMinFilValue[Shaders.configTexMinFilB]); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, Shaders.texMagFilValue[Shaders.configTexMagFilB]); GlStateManager.bindTexture(multitexid.norm); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, Shaders.texMinFilValue[Shaders.configTexMinFilN]); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, Shaders.texMagFilValue[Shaders.configTexMagFilN]); GlStateManager.bindTexture(multitexid.spec); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, Shaders.texMinFilValue[Shaders.configTexMinFilS]); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, Shaders.texMagFilValue[Shaders.configTexMagFilS]); GlStateManager.bindTexture(0); } }
@Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { TextureManager manager = Minecraft.getMinecraft().renderEngine; Map<ResourceLocation, ITextureObject> map = getTextures(manager); if (map != null) { Iterator<Map.Entry<ResourceLocation, ITextureObject>> it = map.entrySet().iterator(); while (it.hasNext()) { Map.Entry<ResourceLocation, ITextureObject> entry = it.next(); if (entry.getKey().getResourceDomain().equals("blockbuster.actors") && entry.getValue() instanceof DynamicTexture) { TextureUtil.deleteTexture(entry.getValue().getGlTextureId()); it.remove(); } } } }
/** * Get texture map from texture manager using reflection API */ @SuppressWarnings("unchecked") public static Map<ResourceLocation, ITextureObject> getTextures(TextureManager manager) { if (TEXTURE_MAP == null) { setupTextureMapField(manager); } try { return (Map<ResourceLocation, ITextureObject>) TEXTURE_MAP.get(manager); } catch (Exception e) { return null; } }
public static ITextureObject getTexture(ResourceLocation loc) { ITextureObject tex = Config.getTextureManager().getTexture(loc); if (tex != null) { return tex; } else if (!Config.hasResource(loc)) { return null; } else { SimpleTexture tex1 = new SimpleTexture(loc); Config.getTextureManager().loadTexture(loc, tex1); return tex1; } }
private ResourceLocation findResourceLocation(String name) { Map<ResourceLocation, ITextureObject> mapTextureObjects = FastReflection.Fields.TextureManager_mapTextureObjects.get(MC.getTextureManager()); return mapTextureObjects.keySet() .stream() .filter(k -> k.getResourcePath().contains(name)) .findFirst() .orElse(null); }
private void updateHeldMapTexture(String url) { if (MC.player == null || !(MC.player.getHeldItemMainhand().getItem() instanceof ItemMap)) return; MC.addScheduledTask(() -> { // allows DynamicTexture to work ItemMap map = (ItemMap) MC.player.getHeldItemMainhand().getItem(); MapData heldMapData = map.getMapData(MC.player.getHeldItemMainhand(), MC.world); try { BufferedImage image = getImageFromUrl(url); DynamicTexture dynamicTexture = new DynamicTexture(image); dynamicTexture.loadTexture(MC.getResourceManager()); Map<ResourceLocation, ITextureObject> mapTextureObjects = FastReflection.Fields.TextureManager_mapTextureObjects.get(MC.getTextureManager()); ResourceLocation textureLocation = mapTextureObjects.keySet() .stream() .filter(k -> k.getResourcePath().contains(heldMapData.mapName)) .findFirst() .orElse(null); mapTextureObjects.put(textureLocation, dynamicTexture); // overwrite old texture with our custom one } catch (Exception e) { e.printStackTrace(); } }); }
public static ITextureObject createDefaultTexture() { DynamicTexture dynamictexture = new DynamicTexture(1, 1); dynamictexture.getTextureData()[0] = -1; dynamictexture.updateDynamicTexture(); return dynamictexture; }
@Override public ResourceLocation func_152789_a(final MinecraftProfileTexture texture, final Type type, final SkinManager.SkinAvailableCallback callBack) { if (type != Type.SKIN) return super.func_152789_a(texture, type, callBack); final boolean isSpecialCallBack = callBack instanceof ISkinDownloadCallback; final ResourceLocation resLocationOld = new ResourceLocation("skins/" + texture.getHash()); final ResourceLocation resLocation = new ResourceLocation(Reference.MOD_ID, resLocationOld.getResourcePath()); ITextureObject itextureobject = textureManager.getTexture(resLocation); if (itextureobject != null) { if (callBack != null) callBack.func_152121_a(type, resLocation); } else { File file1 = new File(skinFolder, texture.getHash().substring(0, 2)); File file2 = new File(file1, texture.getHash()); final NewImageBufferDownload imgDownload = new NewImageBufferDownload(); ITextureObject imgData = new NewThreadDownloadImageData(file2, texture.getUrl(), field_152793_a, imgDownload, resLocationOld, new IImageBuffer() { @Override public BufferedImage parseUserSkin(BufferedImage buffImg) { if (buffImg != null) PlayerModelManager.analyseTexture(buffImg, resLocation); return imgDownload.parseUserSkin(buffImg); } @Override public void func_152634_a() { imgDownload.func_152634_a(); if (callBack != null) callBack.func_152121_a(type, isSpecialCallBack ? resLocation : resLocationOld); } }); textureManager.loadTexture(resLocation, imgData); textureManager.loadTexture(resLocationOld, imgData); // Avoid thrown exception if the image is requested before the download is done } return isSpecialCallBack ? resLocation : resLocationOld; }
private static void bindCustomTextures(CustomTexture[] cts) { if (cts != null) { for (int i = 0; i < cts.length; ++i) { CustomTexture customtexture = cts[i]; GlStateManager.setActiveTexture(33984 + customtexture.getTextureUnit()); ITextureObject itextureobject = customtexture.getTexture(); GlStateManager.bindTexture(itextureobject.getGlTextureId()); } } }
private static void deleteCustomTextures(CustomTexture[] cts) { if (cts != null) { for (int i = 0; i < cts.length; ++i) { CustomTexture customtexture = cts[i]; ITextureObject itextureobject = customtexture.getTexture(); TextureUtil.deleteTexture(itextureobject.getGlTextureId()); } } }
@Nullable private BufferedImage getBufferedImage(@Nonnull ResourceLocation textureResourceLocation) { BufferedImage skinImage = null; try { IResource skin = Minecraft.getMinecraft().getResourceManager().getResource(textureResourceLocation); skinImage = TextureUtil.readBufferedImage(skin.getInputStream()); MineLittlePony.logger.debug("Obtained skin from resource location {}", textureResourceLocation); // this.checkSkin(skinImage); } catch (IOException e) { try { ITextureObject e2 = Minecraft.getMinecraft().getTextureManager().getTexture(textureResourceLocation); if (e2 instanceof ThreadDownloadImageData) { skinImage = PonyFields.downloadedImage.get((ThreadDownloadImageData) e2); if (skinImage != null) { MineLittlePony.logger.debug("Successfully reflected downloadedImage from texture object", e); // this.checkSkin(skinImage); } } else if (e2 instanceof ThreadDownloadImageETag) { skinImage = ((ThreadDownloadImageETag) e2).getBufferedImage(); } else if (e2 instanceof DynamicTextureImage) { skinImage = ((DynamicTextureImage) e2).getImage(); } } catch (Exception ignored) { } } return skinImage; }
private void loadTexture(GameProfile profile, final Type type, final SkinAvailableCallback callback) { if (profile.getId() != null) { Map<Type, MinecraftProfileTexture> data = getProfileData(profile); final MinecraftProfileTexture texture = data.get(type); String skinDir = type.toString().toLowerCase() + "s/"; final ResourceLocation skin = new ResourceLocation("hdskins", skinDir + texture.getHash()); File file2 = new File(LiteLoader.getAssetsDirectory(), "hd/" + skinDir + texture.getHash().substring(0, 2) + "/" + texture.getHash()); final IImageBuffer imagebufferdownload = type == Type.SKIN ? new ImageBufferDownloadHD() : null; ITextureObject texObject = new ThreadDownloadImageETag(file2, texture.getUrl(), DefaultPlayerSkin.getDefaultSkinLegacy(), new IImageBuffer() { @Nonnull @Override public BufferedImage parseUserSkin(@Nonnull BufferedImage image) { BufferedImage image1 = image; if (imagebufferdownload != null) { image1 = imagebufferdownload.parseUserSkin(image); } return image1 == null ? image : image1; } @Override public void skinAvailable() { if (imagebufferdownload != null) { imagebufferdownload.skinAvailable(); } callback.skinAvailable(type, skin, texture); } }); // schedule texture loading on the main thread. TextureLoader.loadTexture(skin, texObject); } }
@SubscribeEvent @SideOnly(Side.CLIENT) public void onMainMenuOpen(GuiOpenEvent event) { if (!dumped && event.getGui() instanceof GuiMainMenu) { dumped = true; TextureManager textureManager = Minecraft.getMinecraft().getTextureManager(); for (Map.Entry<ResourceLocation, ITextureObject> entry : textureManager.mapTextureObjects.entrySet()) { ITextureObject textureObject = entry.getValue(); if (textureObject instanceof TextureMap) { String name = entry.getKey().toString().replace(':', '_').replace('/', '_'); dumpTextureMap((TextureMap) textureObject, name); } } } }
public TextureDrawable(ITextureObject texture, double tLeft, double tTop, double tRight, double tBottom) { this.texture = texture; this.size = new Point(255, 255); originalSize = size.clone(); this.tLeft = tLeft; this.tTop = tTop; this.tRight = tRight; this.tBottom = tBottom; }
public void draw(int x, int y, int z) { // We don't want to bind textures unless necessary TextureManager manager = Minecraft.getMinecraft().getTextureManager(); ITextureObject textureObject = manager.getTexture(texture); int bound = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D); if (textureObject == null || bound != textureObject.getGlTextureId()) { manager.bindTexture(texture); } // ...and then we draw SubTexture.drawTexturedModalRect(x, y, z, this.u, this.v, this.w, this.h); }
public static BufferedImage getImageForResource(ResourceLocation resource) throws IOException{ ITextureObject texob = Minecraft.getMinecraft().getTextureManager().getTexture(resource); if( texob instanceof PhysisAbstractTexture) { return ((PhysisAbstractTexture)texob).generatedImage; } else { InputStream layer = Minecraft.getMinecraft().getResourceManager().getResource(resource).getInputStream(); return ImageIO.read(layer); } }
private void doMapRendering(ItemStack item, HeraldryData heraldryData, IHeraldryItem item1) { glPushMatrix(); //glDepthFunc(GL11.GL_EQUAL); //glEnable(GL_BLEND); //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); Tessellator tess = Tessellator.getInstance(); Minecraft.getMinecraft().getTextureManager().bindTexture(map_overlay); tess.getBuffer().begin(GL11.GL_QUADS, DefaultVertexFormats.ITEM); tess.getBuffer().pos(-8, 136, -.01).tex(0, 1).endVertex(); tess.getBuffer().pos(136, 136, -.01).tex(1, 1).endVertex(); tess.getBuffer().pos(136, -8, -.01).tex(1, 0).endVertex(); tess.getBuffer().pos(-8, -8, -.01).tex(0, 0).endVertex(); tess.draw(); //glDisable(GL_BLEND); //glDepthFunc(GL11.GL_LEQUAL); RefreshableTexture currentCrest = new RefreshableTexture(32, 32); currentCrest.refreshWith(heraldryData, false); ResourceLocation crestLocation = Minecraft.getMinecraft().getTextureManager().getDynamicTextureLocation("gui_crest", currentCrest); ITextureObject texture = Minecraft.getMinecraft().getTextureManager().getTexture(crestLocation); if(texture == null){ texture = new HeraldryTextureSmall(heraldryData); Minecraft.getMinecraft().getTextureManager().loadTexture(crestLocation, texture); } Minecraft.getMinecraft().getTextureManager().bindTexture(crestLocation); tess.getBuffer().begin(GL11.GL_QUADS, DefaultVertexFormats.ITEM); tess.getBuffer().pos(8, 120, -0.015).tex(0, 1).endVertex(); tess.getBuffer().pos(120, 120, -0.015).tex(1, 1).endVertex(); tess.getBuffer().pos(120, 8, -0.015).tex(1, 0).endVertex(); tess.getBuffer().pos(8, 8, -0.015).tex(0, 0).endVertex(); tess.draw(); glPopMatrix(); }
private AbstractTexture getBlockTexture() { final TextureManager texturemanager = rendererDispatcher.renderEngine; if (texturemanager != null) { final ITextureObject texture = texturemanager.getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); if (texture instanceof AbstractTexture) return (AbstractTexture)texture; } return null; }
public int getStatusIconIndex(){ ITextureObject texture = Minecraft.getMinecraft().renderEngine.getTexture(icon); Minecraft.getMinecraft().renderEngine.bindTexture(icon); return super.getStatusIconIndex(); }
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(); } }
/** * 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; }
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); } }
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; } } }
public static ITextureObject getTexture(String p_getTexture_0_) { return getTexture(new ResourceLocation(p_getTexture_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); } }