public void downloadMap(@Nullable String fileName, @Nullable Integer scaledRes) { if (MC.player == null || !(MC.player.getHeldItemMainhand().getItem() instanceof ItemMap)) return; ItemMap map = (ItemMap) MC.player.getHeldItemMainhand().getItem(); MapData heldMapData = map.getMapData(MC.player.getHeldItemMainhand(), MC.world); if (fileName == null) fileName = heldMapData.mapName; ResourceLocation location = findResourceLocation(heldMapData.mapName); if (location == null) { Helper.printMessage("Failed to find ResourceLocation"); return; } DynamicTexture texture = (DynamicTexture)MC.getTextureManager().getTexture(location); BufferedImage image = dynamicToImage(texture); if (scaledRes != null) image = createResizedCopy(image, scaledRes, scaledRes, true); saveImage(fileName, image); }
@Override public void onLoad() { MC.addScheduledTask(() -> { try { BufferedImage image = getImageFromUrl(waifuUrl); if (image == null) { LOGGER.warn("Failed to download waifu image"); return; } DynamicTexture dynamicTexture = new DynamicTexture(image); dynamicTexture.loadTexture(MC.getResourceManager()); waifu = MC.getTextureManager().getDynamicTextureLocation("WAIFU", dynamicTexture); } catch (Exception e) { e.printStackTrace(); } }); }
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 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); }
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; } } }
@SideOnly(Side.CLIENT) public static void handleImage(LImage img) { if (isImageHandled(img)) { return; } try { LithiumMod.log("Loading image for control with UUID[" + img.getUUID() + "]."); handledControls.add(img.getUUID()); bufferedImages.put(img.getUUID(), new DynamicTexture(ImageIO.read(new URL(img.getImageURL())))); LithiumMod.log("Finished loading image for control with UUID[" + img.getUUID() + "]."); } catch (IOException e) { LithiumMod.log("An error occured while trying to load image for control with UUID[" + img.getUUID() + "]."); e.printStackTrace(); } }
@SideOnly(Side.CLIENT) @Override public void renderLithiumControl(LImage control, GuiScreen gui) { Point loc = NewLithiumGUI.centerControl(control); //Ask ImageManager to give us a dynamic texture DynamicTexture imageTexture = ImageManager.getDynamicTexture(control); if (imageTexture != null) { //Get Minecraft's texture manager TextureManager textureManager = ModCoderPackUtils.getTextureManager(); //Bind the texture. (In other words, tell Minecraft to use this texture) textureManager.bindTexture(textureManager.getDynamicTextureLocation(control.getUUID().toString(), imageTexture)); //Correct colors GlStateManager.color(1, 1, 1, 1); //Draw the image to the screen Gui.drawModalRectWithCustomSizedTexture(loc.getX(), loc.getY(), 0.0F, 0.0F, control.getSize().getWidth(), control.getSize().getHeight(), control.getSize().getWidth(), control.getSize().getHeight()); } }
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 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 render(int x, int y, int mouseX, int mouseY) { rc = txt.getDynamicTextureLocation(c.toString(), new DynamicTexture(img)); if (!frame.isVisible()) frame.setVisible(true); if (rc != null) { mc.getRenderManager().renderEngine.bindTexture(rc); drawRectWithFullTexture(x, y, width, height); txt.deleteTexture(rc); } if (mouseX >= x && mouseY >= y && mouseX < x + this.width && mouseY < y + this.height) { if (mouseX != lastMouseX && mouseY != lastMouseY) { if (c instanceof BrowserView) { Point p = new Point(Math.round(SwingUtils.map(mouseX - x, 0, width, 0, c.getWidth())), Math.round(SwingUtils.map(mouseY - y, 0, height, 0, c.getHeight()))); Point globalP = p.getLocation(); SwingUtilities.convertPointToScreen(globalP, c); BrowserView view = (BrowserView) c; SwingUtils.forwardMouseMoveEvent(view.getBrowser(), p.x, p.y, globalP.x, globalP.y); } } } lastMouseX = mouseX; lastMouseY = mouseY; }
@SideOnly(Side.CLIENT) public static void resetClientBody() { ClientProxyCore.overworldTextureRequestSent = false; ClientProxyCore.overworldTexturesValid = false; clientRequests.clear(); File baseFolder = new File(FMLClientHandler.instance().getClient().mcDataDir, "assets/temp"); if (baseFolder.exists() && baseFolder.isDirectory()) { for (File f : baseFolder.listFiles()) if (f.isFile()) f.delete(); } GalacticraftCore.packetPipeline.sendToServer(new PacketSimple(PacketSimple.EnumSimplePacket.S_REQUEST_OVERWORLD_IMAGE, new Object[] {})); DrawGameScreen.reusableMap = new DynamicTexture(MapUtil.SIZE_STD2, MapUtil.SIZE_STD2); MapUtil.biomeColours.clear(); setupColours(); }
public EntityRenderer(Minecraft p_i45076_1_, IResourceManager p_i45076_2_) { this.shaderIndex = shaderCount; this.cameraZoom = 1.0D; this.prevFrameTime = Minecraft.getSystemTime(); this.random = new Random(); this.fogColorBuffer = GLAllocation.createDirectFloatBuffer(16); this.mc = p_i45076_1_; this.resourceManager = p_i45076_2_; this.theMapItemRenderer = new MapItemRenderer(p_i45076_1_.getTextureManager()); this.itemRenderer = new ItemRenderer(p_i45076_1_); this.lightmapTexture = new DynamicTexture(16, 16); this.locationLightMap = p_i45076_1_.getTextureManager().getDynamicTextureLocation("lightMap", this.lightmapTexture); this.lightmapColors = this.lightmapTexture.getTextureData(); this.theShaderGroup = null; }
public void generateQrCode() { if (mResourceLocation != null) { return; } BufferedImage bufferedImage = null; File imageFile = QRCode.from(mIpAddress).to(ImageType.PNG).withSize(256, 256).file(); try { bufferedImage = ImageIO.read(imageFile); } catch (IOException e) { e.printStackTrace(); } mResourceLocation = Minecraft.getMinecraft().renderEngine.getDynamicTextureLocation(imageFile.getName(), new DynamicTexture(bufferedImage)); }
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(); } }
@Override @Strippable(side = Side.CLIENT) public ResourceLocation getLogoTexture() { if (this.logo == null) { try { URL url = this.getClass().getProtectionDomain().getCodeSource().getLocation(); InputStream stream = new URL(url.toString() + "/logo.png").openStream(); BufferedImage image = ImageIO.read(stream); DynamicTexture texture = new DynamicTexture(image); this.logo = Minecraft.getMinecraft().getTextureManager().getDynamicTextureLocation("mods/" + getModID(), texture); stream.close(); } catch (IOException e) { throw new RuntimeException(e); } } return logo; }
@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; }
@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(); } } } }
/** * Pushes a fetch image request to the queue so that when the image is done being fetched it * will be returned to the calling thread * * @param future The task being waited on * @param url The url of the image */ public static void pushImageTaskToQueue(Future<BufferedImage> future, String url) { MinecraftEventHandler.queue.add(new AbstractMap.SimpleEntry<>(future, (image) -> { if (image == null) { VolatileSettings.icons.remove(url); return; } DynamicTexture t = new DynamicTexture((BufferedImage) image); Minecraft mc = Minecraft.getMinecraft(); VolatileSettings.icons.put(url, mc.getTextureManager().getDynamicTextureLocation(url, t)); })); }
public DynaTextureProvider(TilePMon owner) { this.owner = owner; this.textureManager = Minecraft.getMinecraft().getTextureManager(); this.resourceManager = Minecraft.getMinecraft().getResourceManager(); this.id = EnderIOAddons.DOMAIN + "pmon/x" + owner.xCoord + "y" + owner.yCoord + "z" + owner.zCoord; this.dynamicTexture = new DynamicTexture(TEXSIZE, TEXSIZE); this.imageData = this.dynamicTexture.getTextureData(); this.resourceLocation = textureManager.getDynamicTextureLocation(id, this.dynamicTexture); for (int i = 0; i < this.imageData.length; ++i) { this.imageData[i] = 0; } loadTextures(); updateTexture(); instances.add(this); }
@Override public void drawOverlay(int x, int y, int[] pixelsCurrent, DynamicTexture overlay, int rgb, boolean shift) { int[] pixelsOverlay = overlay.getTextureData(); System.arraycopy(pixelsCurrent, 0, pixelsOverlay, 0, pixelsOverlay.length); if(shift){ drawLine(x, last_x, y, last_y, pixelsOverlay, rgb); }else{ if (x > -1 && x < ImageData.IMAGE_RES && y > -1 && y < ImageData.IMAGE_RES){ pixelsOverlay[x+ImageData.IMAGE_RES*y] = rgb; } } overlay.updateDynamicTexture(); }
@Override public void drawOverlay(int x, int y, int[] pixelsCurrent, DynamicTexture overlay, int rgb, boolean shift) { int[] pixelsOverlay = overlay.getTextureData(); System.arraycopy(pixelsCurrent, 0, pixelsOverlay, 0, pixelsOverlay.length); if(Mouse.isButtonDown(0) && last_x > -1000 && last_y > -1000){ if(shift){ if(last_y > y) y = last_y - Math.abs(last_x - x); else y = last_y + Math.abs(last_x - x); } drawShape(Math.min(last_x, x), Math.min(last_y, y), Math.max(last_x, x), Math.max(last_y, y), pixelsOverlay, rgb); } }
public LocatedTexture(ResourceLocation texture, int x, int y, int width, int height){ this.texture = texture; this.x = x; this.y = y; this.width = width; this.height = height; if(texture.getResourcePath().startsWith("server")) { try { BufferedImage image = ImageIO.read(new FileInputStream(new File(IGWMod.proxy.getSaveLocation() + File.separator + "igwmod" + File.separator + texture.getResourcePath().substring(7)))); DynamicTexture t = new DynamicTexture(image); textureId = t.getGlTextureId(); } catch(Exception e) { e.printStackTrace(); } } }
@Override public void drawOverlay(int x, int y, int[] pixelsCurrent, DynamicTexture overlay, int rgb, boolean shift) { int[] pixelsOverlay = overlay.func_110565_c(); for(int i = 0; i < pixelsOverlay.length; i++){ pixelsOverlay[i] = pixelsCurrent[i]; } if(shift){ drawLine(x, last_x, y, last_y, pixelsOverlay, rgb); }else{ if (x > -1 && x < ImageData.IMAGE_RES && y > -1 && y < ImageData.IMAGE_RES){ pixelsOverlay[x+ImageData.IMAGE_RES*y] = rgb; } } overlay.func_110564_a(); }
@Override public void drawOverlay(int x, int y, int[] pixelsCurrent, DynamicTexture overlay, int rgb, boolean shift) { int[] pixelsOverlay = overlay.func_110565_c(); for(int i = 0; i < pixelsOverlay.length; i++){ pixelsOverlay[i] = pixelsCurrent[i]; } if(Mouse.isButtonDown(0) && last_x > -1000 && last_y > -1000){ if(shift){ if(last_y > y) y = last_y - Math.abs(last_x - x); else y = last_y + Math.abs(last_x - x); } drawShape(Math.min(last_x, x), Math.min(last_y, y), Math.max(last_x, x), Math.max(last_y, y), pixelsOverlay, rgb); } }
@SuppressWarnings("null") public DynaTextureProvider(@Nonnull TilePowerMonitor owner) { this.owner = owner; this.textureManager = Minecraft.getMinecraft().getTextureManager(); this.resourceManager = Minecraft.getMinecraft().getResourceManager(); this.id = EnderIO.DOMAIN + "pmon/" + owner.getPos().toLong(); this.dynamicTexture = new DynamicTexture(TEXSIZE, TEXSIZE); this.imageData = this.dynamicTexture.getTextureData(); this.resourceLocation = textureManager.getDynamicTextureLocation(id, this.dynamicTexture); for (int i = 0; i < this.imageData.length; ++i) { this.imageData[i] = 0; } loadTextures(); updateTexture(); instances.add(this); }
@SuppressWarnings("null") public DynaTextureProvider(@Nonnull IDataProvider owner) { this.owner = owner; this.textureManager = Minecraft.getMinecraft().getTextureManager(); this.resourceManager = Minecraft.getMinecraft().getResourceManager(); this.id = EnderIO.DOMAIN + "pmon/" + owner.getLocation().toLong(); this.dynamicTexture = new DynamicTexture(TEXSIZE, TEXSIZE); this.imageData = this.dynamicTexture.getTextureData(); this.resourceLocation = textureManager.getDynamicTextureLocation(id, this.dynamicTexture); for (int i = 0; i < this.imageData.length; ++i) { this.imageData[i] = 0; } loadTextures(); updateTexture(); instances.add(this); }
public void loadIcon(String url, int id) { if ( cache.get(url) != null ) { if (id >= m_Privelegies_Icons.length) m_Privelegies_Icons = Arrays.copyOf(m_Privelegies_Icons, id + 1); m_Privelegies_Icons[id] = cache.get(url); return; } BufferedImage image = null; System.out.println("Icon url: " + url); try { image = ImageIO.read(new URL(url)); if (image != null) { DynamicTexture dyn_tex = new DynamicTexture(image); if (id >= m_Privelegies_Icons.length) m_Privelegies_Icons = Arrays.copyOf(m_Privelegies_Icons, id + 1); cache.put(url, dyn_tex); m_Privelegies_Icons[id] = dyn_tex; } else { System.out.println("Null image!!"); } } catch (IOException e) { e.printStackTrace(); } }
private BufferedImage dynamicToImage(DynamicTexture texture) { int[] data = texture.getTextureData(); if (data.length != 128*128) return null; BufferedImage image = new BufferedImage(128, 128, 2); image.setRGB(0, 0, image.getWidth(), image.getHeight(), data, 0, 128); return image; }
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(); } }); }
protected DynamicTexture setupTexture(Font font, boolean antiAlias, boolean fractionalMetrics, CharData[] chars) { BufferedImage img = generateFontImage(font, antiAlias, fractionalMetrics, chars); try { return new DynamicTexture(img); } catch (Exception e) { e.printStackTrace(); } return null; }
public void bindTexturePackIcon(TextureManager textureManagerIn) { if (this.locationTexturePackIcon == null) { this.locationTexturePackIcon = textureManagerIn.getDynamicTextureLocation("texturepackicon", new DynamicTexture(this.texturePackIcon)); } textureManagerIn.bindTexture(this.locationTexturePackIcon); }
private Instance(MapData mapdataIn) { this.mapData = mapdataIn; this.mapTexture = new DynamicTexture(128, 128); this.mapTextureData = this.mapTexture.getTextureData(); this.location = MapItemRenderer.this.textureManager.getDynamicTextureLocation("map/" + mapdataIn.mapName, this.mapTexture); for (int i = 0; i < this.mapTextureData.length; ++i) { this.mapTextureData[i] = 0; } }
protected ServerListEntryNormal(GuiMultiplayer p_i45048_1_, ServerData p_i45048_2_) { this.field_148303_c = p_i45048_1_; this.field_148301_e = p_i45048_2_; this.mc = Minecraft.getMinecraft(); this.field_148306_i = new ResourceLocation("servers/" + p_i45048_2_.serverIP + "/icon"); this.field_148305_h = (DynamicTexture)this.mc.getTextureManager().getTexture(this.field_148306_i); }