Jump to content

Whodundid

Members
  • Posts

    5
  • Joined

  • Last visited

Everything posted by Whodundid

  1. I am currently in the process of updating many of my mods from 1.8.9 to 1.15.2 and am trying to figure out how to setup the same main/api code structure that existed in previous versions. This is currently how I have the packages setup. EnancedMC is the main mod that I wish to run and the ClearVisualsMod is a mod I wish to run along side EnhancedMC as a reference-able API. When I run the game through eclipse, only the EnhancedMC mod gets loaded and the ClearVisualsMod does not. My question is, how can I get my mod ClearVisuals to load alongside EnhancedMC? I am running on: -Forge: 1.15.2-31.1.14 -Eclipse: 2020-03 M2 (4.15.0M2) -Java: JavaSE-jre1.8.0_241 Any help would be appreciated.
  2. Hi, I working on system that moves items around the player's inventory and hotbar. I am looking for some kind of forge mc event to hook into which is called when the server gives the client that client's inventory data. An event that is fired on inventory updates would also be helpful. Thank you.
  3. Update: That does not appear to have fixed it. I am really not sure what is causing it at this point. EDIT: Tried another thing which actually fixed it: import java.awt.image.BufferedImage; import java.awt.image.DataBufferInt; import net.minecraft.client.renderer.texture.DynamicTexture; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.util.ResourceLocation; public class InGameTextureHandler { private final TextureManager textureManager; private final DynamicTexture texture; private int[] textureData; private ResourceLocation loc; public InGameTextureHandler(TextureManager manager, DynamicTexture textureIn) { this.textureManager = manager; this.texture = textureIn; this.textureData = textureIn.getTextureData(); this.loc = textureManager.getDynamicTextureLocation("texture/", texture); } public void updateTextureData(BufferedImage newImage) { int[] newImgData = ((DataBufferInt)newImage.getRaster().getDataBuffer()).getData(); if (this.textureData.length == newImgData.length) { for (int i = 0; i < newImgData.length; i++) { this.textureData[i] = newImgData[i]; } } this.texture.updateDynamicTexture(); } public ResourceLocation getTextureLocation() { return loc; } } The problem was that it seemed to be creating a new ResourceLocation every time it returned the texture location. So to fix, I just made one and paired it with the dynamic texture.
  4. I THINK I fixed it. I looked more into the MapItemRenderer and tried creating my own texture handler based off of it. After running the game for a solid 10 minutes while running the redraw process (an amount of time which would have definitely ate up a bunch of memory by now), the leak seems to have been fixed. This is what I came up with to fix it: package com.Whodundid.main.util; import java.awt.image.BufferedImage; import java.awt.image.DataBufferInt; import net.minecraft.client.renderer.texture.DynamicTexture; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.util.ResourceLocation; public class InGameTextureHandler { private final TextureManager textureManager; private final DynamicTexture texture; private int[] textureData; public InGameTextureHandler(TextureManager manager, DynamicTexture textureIn) { this.textureManager = manager; this.texture = textureIn; this.textureData = textureIn.getTextureData(); } public void updateTextureData(BufferedImage newImage) { int[] newImgData = ((DataBufferInt)newImage.getRaster().getDataBuffer()).getData(); if (this.textureData.length == newImgData.length) { for (int i = 0; i < newImgData.length; i++) { this.textureData[i] = newImgData[i]; } } this.texture.updateDynamicTexture(); } public ResourceLocation getTextureLocation() { return textureManager.getDynamicTextureLocation("texture/", texture); } } Then back in the class where I am re-creating the BufferedImage I do: public static BufferedImage image = new BufferedImage(75, 75, BufferedImage.TYPE_INT_ARGB); public static DynamicTexture redrawnImage = new DynamicTexture(image); public static InGameTextureHandler handler = new InGameTextureHandler(Minecraft.getMinecraft.getTextureManager(), redrawnImage); public static void updateImage() { //(re-create the BufferedImage 'image' here) handler.updateTextureData(image); }
  5. So the current way I've been using DynamicTextures is causing a constant memory leak as I have to create a new one every 10th of a second. I am creating the DynamicTexture using a BufferedImage I am creating at run time. My only problem is that I don't know how to update the texture after it has already been created with the initial BufferedImage. So to fix the memory leak issue, I need some way to either delete the previous DynamicTexture object or reuse the already existing one. I've looked into the MapItemRenderer as it uses the DynamicTexture but I am not sure how to implement this. This is essentially what I currently have: public static BufferedImage image = new BufferedImage(75, 75, BufferedImage.TYPE_INT_ARGB); public static DynamicTexture redrawnImage = new DynamicTexture(image); public static void updateImage() { redrawnImage.deleteGlTexture(); //(re-create the BufferedImage 'image' here) redrawnImage = new DynamicTexture(image); }
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.