TexturedRect classes for GUIs & overlays, and Custom GUI buttons now support textures of all sizes when using URLs.

EntityCustomFX:
-Added URL support
This commit is contained in:
Luis C.M committed 2022-05-04 23:08:30 -05:00
1 parent 034707abd3
commit d6c46158f5
5 files changed
+21 -4

No files matched your search

@@ -3,10 +3,15 @@ package noppes.npcs.client.fx;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.ITextureObject;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.resources.SkinManager;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.client.ClientProxy;
import noppes.npcs.client.ImageDownloadAlt;
import noppes.npcs.client.renderer.ImageBufferDownloadAlt;
import org.lwjgl.opengl.GL11;
public class EntityCustomFX extends EntityFX {
@@ -118,6 +123,11 @@ public class EntityCustomFX extends EntityFX {
}
location = new ResourceLocation(directory);
if(directory.startsWith("https://")){
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
ITextureObject object = new ImageDownloadAlt(null, directory, new ResourceLocation("customnpcs:textures/gui/invisible.png"), new ImageBufferDownloadAlt(true,false));
texturemanager.loadTexture(this.location, object);
}
this.facePlayer = facePlayer;
}
@@ -53,7 +53,7 @@ public class CustomGuiButton extends GuiButton implements IClickListener {
if(texture.startsWith("https://")){
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
ITextureObject object = new ImageDownloadAlt(null, texture, SkinManager.field_152793_a, new ImageBufferDownloadAlt(false));
ITextureObject object = new ImageDownloadAlt(null, texture, new ResourceLocation("customnpcs:textures/gui/invisible.png"), new ImageBufferDownloadAlt(true,false));
texturemanager.loadTexture(this.texture, object);
}
}
@@ -57,7 +57,7 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
if(texture.startsWith("https://")){
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
ITextureObject object = new ImageDownloadAlt(null, texture, SkinManager.field_152793_a, new ImageBufferDownloadAlt(false));
ITextureObject object = new ImageDownloadAlt(null, texture, new ResourceLocation("customnpcs:textures/gui/invisible.png"), new ImageBufferDownloadAlt(true,false));
texturemanager.loadTexture(this.texture, object);
}
}
@@ -55,7 +55,7 @@ public class CustomOverlayTexturedRect extends Gui implements IOverlayComponent
if(texture.startsWith("https://")){
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
ITextureObject object = new ImageDownloadAlt(null, texture, SkinManager.field_152793_a, new ImageBufferDownloadAlt(false));
ITextureObject object = new ImageDownloadAlt(null, texture, new ResourceLocation("customnpcs:textures/gui/invisible.png"), new ImageBufferDownloadAlt(true,false));
texturemanager.loadTexture(this.texture, object);
}
}
@@ -12,12 +12,18 @@ public class ImageBufferDownloadAlt extends ImageBufferDownload {
private int imageWidth;
private int imageHeight;
private boolean version;
public boolean skinTexture = true;
// If Version == true, use 64 Loader
public ImageBufferDownloadAlt(boolean ver){
this.version = ver;
}
public ImageBufferDownloadAlt(boolean ver, boolean skinTexture){
this.version = ver;
this.skinTexture = skinTexture;
}
@Override
public BufferedImage parseUserSkin(BufferedImage bufferedimage) {
@@ -31,7 +37,8 @@ public class ImageBufferDownloadAlt extends ImageBufferDownload {
g.dispose();
imageData = ((DataBufferInt) bufferedimage1.getRaster().getDataBuffer()).getData();
setAreaTransparent(imageWidth / 2, 0, imageWidth, imageHeight / 4);
if(skinTexture)
setAreaTransparent(imageWidth / 2, 0, imageWidth, imageHeight / 4);
return bufferedimage1;
}