Skip to content

Commit

Permalink
Fix Thaumcraft foci rendering (#559)
Browse files Browse the repository at this point in the history
* remove redundent @Getter

* Fix slow thaumcraft rendering

* swap to @Getter

* Revert "swap to @Getter"

This reverts commit 92f216a.

* fix getter
  • Loading branch information
Caedis authored Jul 19, 2024
1 parent f38fcd1 commit 52e886a
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class ModStatus {
public static boolean isHoloInventoryLoaded;
public static boolean isBattlegearLoaded;
public static boolean isBackhandLoaded;
public static boolean isThaumcraftLoaded;

public static void preInit(){
isBetterCrashesLoaded = Loader.isModLoaded("bettercrashes");
Expand All @@ -38,6 +39,7 @@ public static void preInit(){
isHoloInventoryLoaded = Loader.isModLoaded("holoinventory");
isBattlegearLoaded = Loader.isModLoaded("battlegear2");
isBackhandLoaded = Loader.isModLoaded("backhand");
isThaumcraftLoaded = Loader.isModLoaded("Thaumcraft");

if (isHoloInventoryLoaded){
isHoloInventoryLoaded = new DefaultArtifactVersion("2.4.4-GTNH")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1215,10 +1215,6 @@ public static Matrix4fStack getMatrixStack() {
}
}

public static Matrix4f getModelviewMatrix() {
return modelViewMatrix;
}

public static void glLoadIdentity() {
GL11.glLoadIdentity();
getMatrixStack().identity();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ public LightState(int light, Vector4f ambient, Vector4f diffuse, Vector4f specul
this.quadraticAttenuation = quadraticAttenuation;

this.position = position;
this.position.mul(GLStateManager.getModelviewMatrix());
this.position.mul(GLStateManager.getModelViewMatrix());

this.spotDirection = spotDirection;
GLStateManager.getModelviewMatrix().get3x3(matrix3f);
GLStateManager.getModelViewMatrix().get3x3(matrix3f);
this.spotDirection.mul(matrix3f);
}

Expand Down Expand Up @@ -129,30 +129,30 @@ public void setPosition(FloatBuffer newBuffer) {
// are big and probably more than just bypassing. We would need to track the modelview matrix it was transformed
// with and the untransformed coordinates in addition to the final transformation.
this.position.set(newBuffer);
this.position.mul(GLStateManager.getModelviewMatrix());
this.position.mul(GLStateManager.getModelViewMatrix());
GL11.glLight(this.light, GL11.GL_POSITION, newBuffer);
}

public void setPosition(IntBuffer newBuffer) {
vector4i.set(newBuffer);
this.position.set((float) vector4i.x, (float) vector4i.y, (float) vector4i.z, (float) vector4i.w);
this.position.mul(GLStateManager.getModelviewMatrix());
this.position.mul(GLStateManager.getModelViewMatrix());
GL11.glLight(this.light, GL11.GL_POSITION, newBuffer);
}

public void setSpotDirection(FloatBuffer newBuffer) {
// We are bypassing cache everytime for spot direction, because the necessary components to enable tracking the cache
// are big and probably more than just bypassing. We would need to track the modelview matrix it was transformed
// with and the untransformed coordinates in addition to the final transformation.
GLStateManager.getModelviewMatrix().get3x3(matrix3f);
GLStateManager.getModelViewMatrix().get3x3(matrix3f);
this.spotDirection.set(newBuffer);
this.spotDirection.mul(matrix3f);
GL11.glLight(this.light, GL11.GL_SPOT_DIRECTION, newBuffer);
}

public void setSpotDirection(IntBuffer newBuffer) {
vector3i.set(newBuffer);
GLStateManager.getModelviewMatrix().get3x3(matrix3f);
GLStateManager.getModelViewMatrix().get3x3(matrix3f);
this.spotDirection.set((float) vector3i.x, (float) vector3i.y, (float) vector3i.z);
this.spotDirection.mul(matrix3f);
GL11.glLight(this.light, GL11.GL_SPOT_DIRECTION, newBuffer);
Expand Down
33 changes: 12 additions & 21 deletions src/main/java/com/gtnewhorizons/angelica/hudcaching/HUDCaching.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.InputEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiIngame;
Expand All @@ -33,6 +32,7 @@
import net.minecraft.client.shader.Framebuffer;
import net.minecraft.util.ChatComponentText;
import net.minecraftforge.client.GuiIngameForge;
import thaumcraft.common.Thaumcraft;
import xaero.common.core.XaeroMinimapCore;

import static com.gtnewhorizons.angelica.loading.AngelicaTweaker.LOGGER;
Expand Down Expand Up @@ -61,7 +61,8 @@ public class HUDCaching {
// Crosshairs need to be blended with the scene
public static boolean renderCrosshairsCaptured;

private static RenderGameOverlayEvent fakeHoloInventoryEvent = new RenderGameOverlayEvent.Pre(new RenderGameOverlayEvent(0, null, 0, 0), RenderGameOverlayEvent.ElementType.HELMET);
private final static RenderGameOverlayEvent fakeTextEvent = new RenderGameOverlayEvent.Text(new RenderGameOverlayEvent(0, null, 0, 0), null, null);
private final static RenderGameOverlayEvent fakePreEvent = new RenderGameOverlayEvent.Pre(new RenderGameOverlayEvent(0, null, 0, 0), RenderGameOverlayEvent.ElementType.HELMET);

public static final HUDCaching INSTANCE = new HUDCaching();

Expand All @@ -82,21 +83,6 @@ public static void registerKeyBindings() {
ClientRegistry.registerKeyBinding(toggle);
}

// @SubscribeEvent
// public void onFrame(RenderGameOverlayEvent.Post event) {
// if (event.type == RenderGameOverlayEvent.ElementType.TEXT) {
// final long currentTimeMillis = System.currentTimeMillis();
// updateTimeList.removeIf(time -> currentTimeMillis - time > 1000L);
// String text = EnumChatFormatting.GREEN + "HUD Fps : " + updateTimeList.size();
// mc.fontRenderer.drawStringWithShadow(
// text,
// event.resolution.getScaledWidth() / 4,
// event.resolution.getScaledHeight() / 4,
// 0xFFFFFF);
// updateTimeList.add(currentTimeMillis);
// }
// }

@SubscribeEvent
public void onKeypress(InputEvent.KeyInputEvent event) {
if (toggle != null && toggle.isPressed()) {
Expand All @@ -120,7 +106,6 @@ public void onJoinWorld(WorldEvent.Load event) {

@SuppressWarnings("unused")
public static void renderCachedHud(EntityRenderer renderer, GuiIngame ingame, float partialTicks, boolean hasScreen, int mouseX, int mouseY) {

if (ModStatus.isXaerosMinimapLoaded && ingame instanceof GuiIngameForge) {
// this used to be called by asming into renderGameOverlay, but we removed it
XaeroMinimapCore.beforeIngameGuiRender(partialTicks);
Expand Down Expand Up @@ -171,8 +156,8 @@ public static void renderCachedHud(EntityRenderer renderer, GuiIngame ingame, fl
if (ModStatus.isHoloInventoryLoaded){
Renderer.INSTANCE.angelicaOverride = false;
// only settings the partial ticks as mouseX and mouseY are not used in renderEvent
((RenderGameOverlayEventAccessor) fakeHoloInventoryEvent).setPartialTicks(partialTicks);
Renderer.INSTANCE.renderEvent(fakeHoloInventoryEvent);
((RenderGameOverlayEventAccessor) fakePreEvent).setPartialTicks(partialTicks);
Renderer.INSTANCE.renderEvent(fakePreEvent);
}
}
if (renderPortalCapturedTicks > 0) {
Expand All @@ -181,7 +166,13 @@ public static void renderCachedHud(EntityRenderer renderer, GuiIngame ingame, fl
if (renderCrosshairsCaptured) {
guiForge.callRenderCrosshairs(width, height);
}

if (ModStatus.isThaumcraftLoaded){
((RenderGameOverlayEventAccessor) fakeTextEvent).setPartialTicks(partialTicks);
((RenderGameOverlayEventAccessor) fakeTextEvent).setResolution(resolution);
((RenderGameOverlayEventAccessor) fakeTextEvent).setMouseX(mouseX);
((RenderGameOverlayEventAccessor) fakeTextEvent).setMouseY(mouseY);
Thaumcraft.instance.renderEventHandler.renderOverlay(fakeTextEvent);
}
} else {
if (renderHelmetCaptured)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.gtnewhorizons.angelica.mixins.early.angelica.hudcaching;

import net.minecraft.client.gui.ScaledResolution;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.event.terraingen.BiomeEvent;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -9,4 +10,13 @@
public interface RenderGameOverlayEventAccessor {
@Accessor(value = "partialTicks", remap = false)
void setPartialTicks(float value);

@Accessor(value = "resolution", remap = false)
void setResolution(ScaledResolution resolution);

@Accessor(value = "mouseX", remap = false)
void setMouseX(int mouseX);

@Accessor(value = "mouseY", remap = false)
void setMouseY(int mouseY);
}

0 comments on commit 52e886a

Please sign in to comment.