Fix missing uniform variable in UniversiumShader (#231)

This commit is contained in:
sisyphussy authored and GitHub committed 2025-12-11 18:33:17 -08:00
1 parent 53835361fd
commit b9590cfc69
2 files changed
+26 -13

No files matched your search

@@ -15,6 +15,7 @@ import net.minecraftforge.common.MinecraftForge;
import com.gtnewhorizon.gtnhlib.client.model.ModelISBRH;
import com.gtnewhorizon.gtnhlib.client.model.loading.ModelRegistry;
import com.gtnewhorizon.gtnhlib.client.renderer.postprocessing.shaders.UniversiumShader;
import com.gtnewhorizon.gtnhlib.client.tooltip.LoreHandler;
import com.gtnewhorizon.gtnhlib.commands.ItemInHandCommand;
import com.gtnewhorizon.gtnhlib.compat.FalseTweaks;
@@ -56,6 +57,7 @@ public class ClientProxy extends CommonProxy {
public void init(FMLInitializationEvent event) {
super.init(event);
ClientCommandHandler.instance.registerCommand(new ItemInHandCommand());
UniversiumShader.init();
}
@Override
@@ -24,7 +24,7 @@ public final class UniversiumShader extends ShaderProgram {
private final TextureAtlas textureAtlas;
private boolean inventoryRenderPass;
private static boolean inventoryRenderPass;
private boolean renderInInventory;
private boolean lastInventoryRender;
@@ -82,17 +82,21 @@ public final class UniversiumShader extends ShaderProgram {
location_starColorBase = getUniformLocation("starColorBase");
GL20.glUniform1f(location_lightmix, 0.2f);
GL20.glUniform1f(location_externalScale, 1);
bindTextureSlot("texture0", 0);
bindTextureSlot("cosmicTexture", 2);
unbind();
MinecraftForge.EVENT_BUS.register(this);
this.textureAtlas = TextureAtlas.createTextureAtlas(GTNHLib.RESOURCE_DOMAIN, "textures/avaritia/cosmic", 10);
}
public static void init() {
// Only register the events since there are some weird issues when trying to load the uniforms during init.
MinecraftForge.EVENT_BUS.register(new EventHandler());
}
public static UniversiumShader getInstance() {
if (instance == null) {
instance = new UniversiumShader();
@@ -100,16 +104,6 @@ public final class UniversiumShader extends ShaderProgram {
return instance;
}
@SubscribeEvent
public void makeCosmicStuffLessDumbInGUIs(GuiScreenEvent.DrawScreenEvent.Pre event) {
inventoryRenderPass = true;
}
@SubscribeEvent
public void finishMakingCosmicStuffLessDumbInGUIs(GuiScreenEvent.DrawScreenEvent.Post event) {
inventoryRenderPass = false;
}
@Override
// TODO This should probably get replaced by Uniform classes but i'm too lazy to implement those
public void use() {
@@ -242,4 +236,21 @@ public final class UniversiumShader extends ShaderProgram {
.set(MathHelper.clamp_float(r, 0, 1), MathHelper.clamp_float(g, 0, 1), MathHelper.clamp_float(b, 0, 1));
return this;
}
public static boolean isRenderingInInventory() {
return inventoryRenderPass;
}
private static final class EventHandler {
@SubscribeEvent
public void makeCosmicStuffLessDumbInGUIs(GuiScreenEvent.DrawScreenEvent.Pre event) {
inventoryRenderPass = true;
}
@SubscribeEvent
public void finishMakingCosmicStuffLessDumbInGUIs(GuiScreenEvent.DrawScreenEvent.Post event) {
inventoryRenderPass = false;
}
}
}