public static void init() { if (initialized) return; initialized = true; IResourceManager rm = Minecraft.getMinecraft().getResourceManager(); if (rm instanceof IReloadableResourceManager) { ((IReloadableResourceManager) rm).registerReloadListener(__ -> { loadedModels.clear(); reloadCount++; }); } }
private int detectMaxMipmapLevel(Map p_detectMaxMipmapLevel_1_, IResourceManager p_detectMaxMipmapLevel_2_) { int i = this.detectMinimumSpriteSize(p_detectMaxMipmapLevel_1_, p_detectMaxMipmapLevel_2_, 20); if (i < 16) { i = 16; } i = MathHelper.smallestEncompassingPowerOfTwo(i); if (i > 16) { Config.log("Sprite size: " + i); } int j = MathHelper.log2(i); if (j < 4) { j = 4; } return j; }
public static void loadNSMap1(IResourceManager manager, ResourceLocation location, int width, int height, int[] aint, int offset, int defaultColor) { boolean flag = false; try { IResource iresource = manager.getResource(location); BufferedImage bufferedimage = ImageIO.read(iresource.getInputStream()); if (bufferedimage != null && bufferedimage.getWidth() == width && bufferedimage.getHeight() == height) { bufferedimage.getRGB(0, 0, width, height, aint, offset, width); flag = true; } } catch (IOException var10) { ; } if (!flag) { Arrays.fill(aint, offset, offset + width * height, defaultColor); } }
public static int create(IResourceManager manager, @Nullable ResourceLocation vsh, @Nullable ResourceLocation fsh) { int vshId = 0, fshId = 0, program = 0; if(vsh != null) { vshId = parse(manager, vsh, VERTEX); } if(fsh != null) { fshId = parse(manager, fsh, FRAGMENT); } if(vsh != null || fsh != null) { program = ARBShaderObjects.glCreateProgramObjectARB(); } if(vsh != null) { OpenGlHelper.glAttachShader(program, vshId); } if(fsh != null) { OpenGlHelper.glAttachShader(program, fshId); } OpenGlHelper.glLinkProgram(program); if(OpenGlHelper.glGetShaderi(program, ARBShaderObjects.GL_OBJECT_LINK_STATUS_ARB) == GL11.GL_FALSE) { return 0; } if(OpenGlHelper.glGetShaderi(program, ARBShaderObjects.GL_OBJECT_VALIDATE_STATUS_ARB) == GL11.GL_FALSE) { return 0; } return program; }
public static void resourcesReloaded(IResourceManager p_resourcesReloaded_0_) { if (getTextureMapBlocks() != null) { Config.dbg("*** Reloading custom textures ***"); CustomSky.reset(); TextureAnimations.reset(); update(); NaturalTextures.update(); BetterGrass.update(); BetterSnow.update(); TextureAnimations.update(); CustomColors.update(); CustomSky.update(); RandomMobs.resetTextures(); CustomItems.updateModels(); CustomEntityModels.update(); Shaders.resourcesReloaded(); Lang.resourcesReloaded(); Config.updateTexturePackClouds(); SmartLeaves.updateLeavesModels(); CustomPanorama.update(); Config.getTextureManager().tick(); } }
public static int[] readImageData(IResourceManager resourceManager, ResourceLocation imageLocation) throws IOException { BufferedImage bufferedimage = readBufferedImage(resourceManager.getResource(imageLocation).getInputStream()); if (bufferedimage == null) { return null; } else { int i = bufferedimage.getWidth(); int j = bufferedimage.getHeight(); int[] aint = new int[i * j]; bufferedimage.getRGB(0, 0, i, j, aint, 0, i); return aint; } }
private int detectMaxMipmapLevel(Map p_detectMaxMipmapLevel_1_, IResourceManager p_detectMaxMipmapLevel_2_) { int i = this.detectMinimumSpriteSize(p_detectMaxMipmapLevel_1_, p_detectMaxMipmapLevel_2_, 20); if (i < 16) { i = 16; } i = MathHelper.roundUpToPowerOfTwo(i); if (i > 16) { Config.log("Sprite size: " + i); } int j = MathHelper.calculateLogBaseTwo(i); if (j < 4) { j = 4; } return j; }
public static void resourcesReloaded(IResourceManager p_resourcesReloaded_0_) { if (getTextureMapBlocks() != null) { Config.dbg("*** Reloading custom textures ***"); CustomSky.reset(); TextureAnimations.reset(); update(); NaturalTextures.update(); BetterGrass.update(); BetterSnow.update(); TextureAnimations.update(); CustomColorizer.update(); CustomSky.update(); RandomMobs.resetTextures(); Config.updateTexturePackClouds(); Config.getTextureManager().tick(); } }
public EntityRenderer(Minecraft mcIn, IResourceManager resourceManagerIn) { this.shaderIndex = SHADER_COUNT; this.mc = mcIn; this.resourceManager = resourceManagerIn; this.itemRenderer = mcIn.getItemRenderer(); this.theMapItemRenderer = new MapItemRenderer(mcIn.getTextureManager()); this.lightmapTexture = new DynamicTexture(16, 16); this.locationLightMap = mcIn.getTextureManager().getDynamicTextureLocation("lightMap", this.lightmapTexture); this.lightmapColors = this.lightmapTexture.getTextureData(); this.theShaderGroup = null; for (int i = 0; i < 32; ++i) { for (int j = 0; j < 32; ++j) { float f = (float)(j - 16); float f1 = (float)(i - 16); float f2 = MathHelper.sqrt(f * f + f1 * f1); this.rainXCoords[i << 5 | j] = -f1 / f2; this.rainYCoords[i << 5 | j] = f / f2; } } }
public void onResourceManagerReload(IResourceManager resourceManager) { if (this.theShaderGroup != null) { this.theShaderGroup.deleteShaderGroup(); } this.theShaderGroup = null; if (this.shaderIndex == SHADER_COUNT) { this.loadEntityShader(this.mc.getRenderViewEntity()); } else { this.loadShader(SHADERS_TEXTURES[this.shaderIndex]); } }
public EntityRenderer(Minecraft mcIn, IResourceManager resourceManagerIn) { this.shaderIndex = shaderCount; this.useShader = false; this.frameCount = 0; this.mc = mcIn; this.resourceManager = resourceManagerIn; this.itemRenderer = mcIn.getItemRenderer(); this.theMapItemRenderer = new MapItemRenderer(mcIn.getTextureManager()); this.lightmapTexture = new DynamicTexture(16, 16); this.locationLightMap = mcIn.getTextureManager().getDynamicTextureLocation("lightMap", this.lightmapTexture); this.lightmapColors = this.lightmapTexture.getTextureData(); this.theShaderGroup = null; for (int i = 0; i < 32; ++i) { for (int j = 0; j < 32; ++j) { float f = (float) (j - 16); float f1 = (float) (i - 16); float f2 = MathHelper.sqrt_float(f * f + f1 * f1); this.rainXCoords[i << 5 | j] = -f1 / f2; this.rainYCoords[i << 5 | j] = f / f2; } } }
public EntityRenderer(Minecraft mcIn, IResourceManager resourceManagerIn) { this.shaderIndex = SHADER_COUNT; this.mc = mcIn; this.resourceManager = resourceManagerIn; this.itemRenderer = mcIn.getItemRenderer(); this.theMapItemRenderer = new MapItemRenderer(mcIn.getTextureManager()); this.lightmapTexture = new DynamicTexture(16, 16); this.locationLightMap = mcIn.getTextureManager().getDynamicTextureLocation("lightMap", this.lightmapTexture); this.lightmapColors = this.lightmapTexture.getTextureData(); this.theShaderGroup = null; for (int i = 0; i < 32; ++i) { for (int j = 0; j < 32; ++j) { float f = (float)(j - 16); float f1 = (float)(i - 16); float f2 = MathHelper.sqrt_float(f * f + f1 * f1); this.rainXCoords[i << 5 | j] = -f1 / f2; this.rainYCoords[i << 5 | j] = f / f2; } } }
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); } } }
public Parser(IResource from, IResourceManager manager) throws IOException { this.manager = manager; this.objFrom = from.getResourceLocation(); this.objStream = new InputStreamReader(from.getInputStream(), StandardCharsets.UTF_8); this.objReader = new BufferedReader(objStream); }
public ShaderGroup(TextureManager p_i1050_1_, IResourceManager p_i1050_2_, Framebuffer p_i1050_3_, ResourceLocation p_i1050_4_) throws JsonException, IOException, JsonSyntaxException { this.resourceManager = p_i1050_2_; this.mainFramebuffer = p_i1050_3_; this.field_148036_j = 0.0F; this.field_148037_k = 0.0F; this.mainFramebufferWidth = p_i1050_3_.framebufferWidth; this.mainFramebufferHeight = p_i1050_3_.framebufferHeight; this.shaderGroupName = p_i1050_4_.toString(); this.resetProjectionMatrix(); this.parseGroup(p_i1050_1_, p_i1050_4_); }
@Override public void onResourceManagerReload(IResourceManager manager) { ProgressManager.ProgressBar bar = ProgressManager.push("Reloading Shader Manager", 0); reloading = true; SHADER_RESOURCES.forEach(shader -> shader.reload(manager)); reloading = false; ProgressManager.pop(bar); }
public static int[] readImageData(IResourceManager resourceManager, ResourceLocation imageLocation) throws IOException { BufferedImage bufferedimage = readBufferedImage(resourceManager.getResource(imageLocation).getInputStream()); int i = bufferedimage.getWidth(); int j = bufferedimage.getHeight(); int[] aint = new int[i * j]; bufferedimage.getRGB(0, 0, i, j, aint, 0, i); return aint; }
public void loadTexture(IResourceManager resourceManager) throws IOException { if (this.iconCreator != null) { this.loadSprites(resourceManager, this.iconCreator); } }
public void loadSprites(IResourceManager resourceManager, IIconCreator p_174943_2_) { this.mapRegisteredSprites.clear(); p_174943_2_.registerSprites(this); this.initMissingImage(); this.deleteGlTexture(); this.loadTextureAtlas(resourceManager); }
public void loadTexture(IResourceManager resourceManager) throws IOException { this.deleteGlTexture(); IResource iresource = null; try { iresource = resourceManager.getResource(this.textureLocation); BufferedImage bufferedimage = TextureUtil.readBufferedImage(iresource.getInputStream()); boolean flag = false; boolean flag1 = false; if (iresource.hasMetadata()) { try { TextureMetadataSection texturemetadatasection = (TextureMetadataSection)iresource.getMetadata("texture"); if (texturemetadatasection != null) { flag = texturemetadatasection.getTextureBlur(); flag1 = texturemetadatasection.getTextureClamp(); } } catch (RuntimeException runtimeexception) { LOG.warn("Failed reading metadata of: {}", new Object[] {this.textureLocation, runtimeexception}); } } TextureUtil.uploadTextureImageAllocate(this.getGlTextureId(), bufferedimage, flag, flag1); } finally { IOUtils.closeQuietly((Closeable)iresource); } }
public void loadTexture(IResourceManager resourceManager) throws IOException { if (this.bufferedImage == null && this.textureLocation != null) { super.loadTexture(resourceManager); } if (this.imageThread == null) { if (this.cacheFile != null && this.cacheFile.isFile()) { logger.debug("Loading http texture from local cache ({})", new Object[] {this.cacheFile}); try { this.bufferedImage = ImageIO.read(this.cacheFile); if (this.imageBuffer != null) { this.setBufferedImage(this.imageBuffer.parseUserSkin(this.bufferedImage)); } } catch (IOException ioexception) { logger.error((String)("Couldn\'t load skin " + this.cacheFile), (Throwable)ioexception); this.loadTextureFromServer(); } } else { this.loadTextureFromServer(); } } }
public void loadTexture(IResourceManager resourceManager) throws IOException { if (this.bufferedImage == null && this.textureLocation != null) { super.loadTexture(resourceManager); } if (this.imageThread == null) { if (this.cacheFile != null && this.cacheFile.isFile()) { LOGGER.debug("Loading http texture from local cache ({})", new Object[] {this.cacheFile}); try { this.bufferedImage = ImageIO.read(this.cacheFile); if (this.imageBuffer != null) { this.setBufferedImage(this.imageBuffer.parseUserSkin(this.bufferedImage)); } } catch (IOException ioexception) { LOGGER.error("Couldn\'t load skin {}", new Object[] {this.cacheFile, ioexception}); this.loadTextureFromServer(); } } else { this.loadTextureFromServer(); } } }
public void onResourceManagerReload(IResourceManager resourceManager) { this.sndManager.reloadSoundSystem(); this.sndRegistry.clearMap(); for (String s : resourceManager.getResourceDomains()) { try { for (IResource iresource : resourceManager.getAllResources(new ResourceLocation(s, "sounds.json"))) { try { Map<String, SoundList> map = this.getSoundMap(iresource.getInputStream()); for (Entry<String, SoundList> entry : map.entrySet()) { this.loadSoundResource(new ResourceLocation(s, (String)entry.getKey()), (SoundList)entry.getValue()); } } catch (RuntimeException runtimeexception) { logger.warn((String)"Invalid sounds.json", (Throwable)runtimeexception); } } } catch (IOException var11) { ; } } }
public void loadTexture(IResourceManager resourceManager) throws IOException { if (this.bufferedImage == null && this.textureLocation != null) { super.loadTexture(resourceManager); } if (this.imageThread == null) { if (this.cacheFile != null && this.cacheFile.isFile()) { LOGGER.debug("Loading http texture from local cache ({})", new Object[] {this.cacheFile}); try { this.bufferedImage = ImageIO.read(this.cacheFile); if (this.imageBuffer != null) { this.setBufferedImage(this.imageBuffer.parseUserSkin(this.bufferedImage)); } this.imageFound = Boolean.valueOf(this.bufferedImage != null); } catch (IOException ioexception) { LOGGER.error("Couldn\'t load skin {}", new Object[] {this.cacheFile, ioexception}); this.loadTextureFromServer(); } } else { this.loadTextureFromServer(); } } }
public static ShaderLoader loadShader(IResourceManager resourceManager, ShaderLoader.ShaderType type, String filename) throws IOException { ShaderLoader shaderloader = (ShaderLoader)type.getLoadedShaders().get(filename); if (shaderloader == null) { ResourceLocation resourcelocation = new ResourceLocation("shaders/program/" + filename + type.getShaderExtension()); IResource iresource = resourceManager.getResource(resourcelocation); try { byte[] abyte = IOUtils.toByteArray((InputStream)(new BufferedInputStream(iresource.getInputStream()))); ByteBuffer bytebuffer = BufferUtils.createByteBuffer(abyte.length); bytebuffer.put(abyte); bytebuffer.position(0); int i = OpenGlHelper.glCreateShader(type.getShaderMode()); OpenGlHelper.glShaderSource(i, bytebuffer); OpenGlHelper.glCompileShader(i); if (OpenGlHelper.glGetShaderi(i, OpenGlHelper.GL_COMPILE_STATUS) == 0) { String s = StringUtils.trim(OpenGlHelper.glGetShaderInfoLog(i, 32768)); JsonException jsonexception = new JsonException("Couldn\'t compile " + type.getShaderName() + " program: " + s); jsonexception.setFilenameAndFlush(resourcelocation.getResourcePath()); throw jsonexception; } shaderloader = new ShaderLoader(type, i, filename); type.getLoadedShaders().put(filename, shaderloader); } finally { IOUtils.closeQuietly((Closeable)iresource); } } return shaderloader; }
public void onResourceManagerReload(IResourceManager resourceManager) { this.locationFontTexture = getHdFontLocation(this.locationFontTextureBase); for (int i = 0; i < unicodePageLocations.length; ++i) { unicodePageLocations[i] = null; } this.readFontTexture(); }
public static void loadNSMap(IResourceManager manager, ResourceLocation location, int width, int height, int[] aint) { if (Shaders.configNormalMap) { loadNSMap1(manager, getNSMapLocation(location, "n"), width, height, aint, width * height, -8421377); } if (Shaders.configSpecularMap) { loadNSMap1(manager, getNSMapLocation(location, "s"), width, height, aint, width * height * 2, 0); } }
public void onResourceManagerReload(IResourceManager resourceManager) { net.minecraftforge.fml.common.ProgressManager.ProgressBar bar = net.minecraftforge.fml.common.ProgressManager.push("Reloading Texture Manager", this.mapTextureObjects.keySet().size(), true); for (Entry<ResourceLocation, ITextureObject> entry : this.mapTextureObjects.entrySet()) { bar.step(entry.getKey().toString()); this.loadTexture((ResourceLocation)entry.getKey(), (ITextureObject)entry.getValue()); } net.minecraftforge.fml.common.ProgressManager.pop(bar); }
public Parser(IResource from, IResourceManager manager) throws IOException { this.manager = manager; this.objFrom = from.getResourceLocation(); this.objStream = new InputStreamReader(from.getInputStream(), Charsets.UTF_8); this.objReader = new BufferedReader(objStream); }
public static void clearModelCache(IResourceManager manager) { ModelLoaderRegistry.manager = manager; cache.clear(); // putting the builtin models in cache.put(new ResourceLocation("minecraft:builtin/generated"), ItemLayerModel.INSTANCE); cache.put(new ResourceLocation("minecraft:block/builtin/generated"), ItemLayerModel.INSTANCE); cache.put(new ResourceLocation("minecraft:item/builtin/generated"), ItemLayerModel.INSTANCE); }
public void loadTexture(IResourceManager resourceManager) throws IOException { ShadersTex.resManager = resourceManager; if (this.iconCreator != null) { this.loadSprites(resourceManager, this.iconCreator); } }
public void loadSprites(IResourceManager resourceManager, IIconCreator p_174943_2_) { this.mapRegisteredSprites.clear(); p_174943_2_.registerSprites(this); if (this.mipmapLevels >= 4) { this.mipmapLevels = this.detectMaxMipmapLevel(this.mapRegisteredSprites, resourceManager); Config.log("Mipmap levels: " + this.mipmapLevels); } this.initMissingImage(); this.deleteGlTexture(); this.loadTextureAtlas(resourceManager); }
public void loadTexture(IResourceManager resourceManager) throws IOException { if (this.bufferedImage == null && this.textureLocation != null) { super.loadTexture(resourceManager); } if (this.imageThread == null) { if (this.cacheFile != null && this.cacheFile.isFile()) { logger.debug("Loading http texture from local cache ({})", new Object[] {this.cacheFile}); try { this.bufferedImage = ImageIO.read(this.cacheFile); if (this.imageBuffer != null) { this.setBufferedImage(this.imageBuffer.parseUserSkin(this.bufferedImage)); } this.imageFound = Boolean.valueOf(this.bufferedImage != null); } catch (IOException ioexception) { logger.error((String)("Couldn\'t load skin " + this.cacheFile), (Throwable)ioexception); this.loadTextureFromServer(); } } else { this.loadTextureFromServer(); } } }
public void onResourceManagerReload(IResourceManager resourceManager) { this.locationFontTexture = FontUtils.getHdFontLocation(this.locationFontTextureBase); for (int i = 0; i < unicodePageLocations.length; ++i) { unicodePageLocations[i] = null; } this.readFontTexture(); this.readGlyphSizes(); }
public static boolean hasResource(IResourceManager p_hasResource_0_, ResourceLocation p_hasResource_1_) { try { IResource iresource = p_hasResource_0_.getResource(p_hasResource_1_); return iresource != null; } catch (IOException var3) { return false; } }
public static ShaderLoader loadShader(IResourceManager resourceManager, ShaderLoader.ShaderType type, String filename) throws IOException { ShaderLoader shaderloader = (ShaderLoader)type.getLoadedShaders().get(filename); if (shaderloader == null) { ResourceLocation resourcelocation = new ResourceLocation("shaders/program/" + filename + type.getShaderExtension()); BufferedInputStream bufferedinputstream = new BufferedInputStream(resourceManager.getResource(resourcelocation).getInputStream()); byte[] abyte = toByteArray(bufferedinputstream); ByteBuffer bytebuffer = BufferUtils.createByteBuffer(abyte.length); bytebuffer.put(abyte); bytebuffer.position(0); int i = OpenGlHelper.glCreateShader(type.getShaderMode()); OpenGlHelper.glShaderSource(i, bytebuffer); OpenGlHelper.glCompileShader(i); if (OpenGlHelper.glGetShaderi(i, OpenGlHelper.GL_COMPILE_STATUS) == 0) { String s = StringUtils.trim(OpenGlHelper.glGetShaderInfoLog(i, 32768)); JsonException jsonexception = new JsonException("Couldn\'t compile " + type.getShaderName() + " program: " + s); jsonexception.func_151381_b(resourcelocation.getResourcePath()); throw jsonexception; } shaderloader = new ShaderLoader(type, i, filename); type.getLoadedShaders().put(filename, shaderloader); } return shaderloader; }
public void onResourceManagerReload(IResourceManager resourceManager) { Config.dbg("*** Reloading textures ***"); Config.log("Resource packs: " + Config.getResourcePackNames()); Iterator iterator = this.mapTextureObjects.keySet().iterator(); while (iterator.hasNext()) { ResourceLocation resourcelocation = (ResourceLocation)iterator.next(); String s = resourcelocation.getResourcePath(); if (s.startsWith("mcpatcher/") || s.startsWith("optifine/")) { ITextureObject itextureobject = (ITextureObject)this.mapTextureObjects.get(resourcelocation); if (itextureobject instanceof AbstractTexture) { AbstractTexture abstracttexture = (AbstractTexture)itextureobject; abstracttexture.deleteGlTexture(); } iterator.remove(); } } for (Entry<ResourceLocation, ITextureObject> entry : this.mapTextureObjects.entrySet()) { this.loadTexture((ResourceLocation)entry.getKey(), (ITextureObject)entry.getValue()); } }