This commit is contained in:
kirillsaint 2023-07-01 14:58:30 +06:00
parent fc48f1507a
commit 99e0858f98
7 changed files with 100 additions and 48 deletions

View File

@ -1,12 +1,12 @@
package net.silentclient.client.cosmetics;
import java.util.ArrayList;
import net.minecraft.client.Minecraft;
import net.minecraft.util.ResourceLocation;
import net.silentclient.client.utils.SCTextureManager;
import net.silentclient.client.mixin.ducks.TextureManagerExt;
import net.silentclient.client.utils.TimerUtils;
import java.util.ArrayList;
public class AnimatedResourceLocation {
protected final String folder;
protected final int frames;
@ -72,7 +72,7 @@ public class AnimatedResourceLocation {
Minecraft.getMinecraft().getTextureManager().bindTexture(this.getTextures()[0]);
return;
}
binding = SCTextureManager.waitBindTexture(this.getTexture(), this.getTextures()[0], 1000);
binding = ((TextureManagerExt) Minecraft.getMinecraft().getTextureManager()).waitBindTexture(new StaticResourceLocation(this.getTexture().getResourcePath()), new StaticResourceLocation(this.getTextures()[0].getResourcePath()), 1000);
}
public void setCurrentFrame(int currentFrame) {

View File

@ -1,8 +1,5 @@
package net.silentclient.client.gui.util;
import net.silentclient.client.utils.SCTextureManager;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
@ -14,7 +11,10 @@ import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ResourceLocation;
import net.silentclient.client.Client;
import net.silentclient.client.cosmetics.StaticResourceLocation;
import net.silentclient.client.mixin.ducks.TextureManagerExt;
import net.silentclient.client.utils.ColorUtils;
import org.lwjgl.opengl.GL11;
import static org.lwjgl.opengl.GL11.*;
@ -572,7 +572,7 @@ public class RenderUtil {
if(mip) {
Client.getInstance().getTextureManager().bindTextureMipmapped(image);
} else {
SCTextureManager.waitBindTexture(image, new ResourceLocation("silentclient/transparent.png"), 500);
((TextureManagerExt) Minecraft.getMinecraft().getTextureManager()).waitBindTexture(new StaticResourceLocation(image.getResourcePath()), new StaticResourceLocation("silentclient/transparent.png"));
}
Gui.drawModalRectWithCustomSizedTexture((int) x, (int) y, (float) 0.0f, (float) 0.0f, (int) width, (int) height, (float) width, (float) height);
GL11.glDepthMask((boolean) true);

View File

@ -0,0 +1,12 @@
package net.silentclient.client.mixin.ducks;
import net.silentclient.client.cosmetics.StaticResourceLocation;
public interface TextureManagerExt {
boolean waitBindTexture(StaticResourceLocation resource);
boolean waitBindTexture(StaticResourceLocation resource, StaticResourceLocation saveTexture);
boolean waitBindTexture(StaticResourceLocation resource, StaticResourceLocation saveTexture, int timeout);
void setBinding(boolean a);
boolean isBinding();
}

View File

@ -0,0 +1,77 @@
package net.silentclient.client.mixin.mixins;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.texture.ITextureObject;
import net.minecraft.client.renderer.texture.SimpleTexture;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.util.ResourceLocation;
import net.silentclient.client.Client;
import net.silentclient.client.cosmetics.StaticResourceLocation;
import net.silentclient.client.mixin.ducks.TextureManagerExt;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import java.util.Map;
@Mixin(TextureManager.class)
public abstract class TextureManagerMixin implements TextureManagerExt {
@Shadow public abstract boolean loadTexture(ResourceLocation textureLocation, ITextureObject textureObj);
@Shadow public abstract void bindTexture(ResourceLocation resource);
@Shadow @Final private Map<ResourceLocation, ITextureObject> mapTextureObjects;
@Unique boolean binding = false;
@Override
public boolean waitBindTexture(StaticResourceLocation resource) {
return this.waitBindTexture(resource, new StaticResourceLocation(Client.getInstance().getBindingTexture().getResourcePath()), 500);
}
@Override
public boolean waitBindTexture(StaticResourceLocation resource, StaticResourceLocation saveTexture) {
return this.waitBindTexture(resource, saveTexture, 500);
}
@Override
public boolean waitBindTexture(StaticResourceLocation resource, StaticResourceLocation saveTexture, int timeout)
{
ITextureObject itextureobject = this.mapTextureObjects.get(resource.getLocation());
if (itextureobject == null)
{
if(((TextureManagerExt) Minecraft.getMinecraft().getTextureManager()).isBinding()) {
this.bindTexture(saveTexture.getLocation());
return true;
}
((TextureManagerExt) Minecraft.getMinecraft().getTextureManager()).setBinding(true);
itextureobject = new SimpleTexture(resource.getLocation());
loadTexture(resource.getLocation(), itextureobject);
(new Thread("waitBinding") {
public void run() {
try {
Thread.sleep(timeout);
} catch (InterruptedException e) {
e.printStackTrace();
}
((TextureManagerExt) Minecraft.getMinecraft().getTextureManager()).setBinding(false);
}
}).start();
}
GlStateManager.bindTexture(itextureobject.getGlTextureId());
return false;
}
@Override
public void setBinding(boolean binding) {
this.binding = binding;
}
@Override
public boolean isBinding() {
return binding;
}
}

View File

@ -35,6 +35,7 @@ public class PremiumCosmeticsGui extends GuiScreen {
GlStateManager.disableAlpha();
Client.backgroundPanorama.renderSkybox(mouseX, mouseY, partialTicks);
GlStateManager.enableAlpha();
this.drawGradientRect(0, 0, this.width, this.height, 0, Integer.MIN_VALUE);
ScaledResolution scaledResolution = new ScaledResolution(mc);
super.drawScreen(mouseX, mouseY, partialTicks);
String month = "";

View File

@ -188,43 +188,4 @@ public class SCTextureManager
return null;
}
}
public static boolean binding = false;
public static boolean waitBindTexture(ResourceLocation resource, ResourceLocation saveTexture, int timeout) {
if(isTextureLoaded(resource)) {
Minecraft.getMinecraft().getTextureManager().bindTexture(resource);
return false;
}
if(binding) {
Minecraft.getMinecraft().getTextureManager().bindTexture(saveTexture);
return true;
}
Minecraft.getMinecraft().getTextureManager().bindTexture(resource);
(new Thread("waitBinding") {
public void run() {
try {
Thread.sleep(timeout);
} catch (InterruptedException e) {
e.printStackTrace();
}
SCTextureManager.binding = false;
}
}).start();
return false;
}
public static boolean isTextureLoaded(ResourceLocation location) {
ITextureObject itextureobject = (ITextureObject)((TextureManagerAccessor) Minecraft.getMinecraft().getTextureManager()).getMapTextureObjects().get(location);
if (itextureobject == null)
{
return false;
}
return true;
}
}

View File

@ -41,6 +41,7 @@
"mixins.BlockGlassMixin",
"mixins.ShaderGroupMixin",
"mixins.GuiContainerMixin",
"mixins.InventoryEffectRendererMixin"
"mixins.InventoryEffectRendererMixin",
"mixins.TextureManagerMixin"
]
}