Skip to content

Commit

Permalink
currently isn't launching, will try later
Browse files Browse the repository at this point in the history
  • Loading branch information
sakura-ryoko committed Sep 11, 2024
1 parent 579a7a5 commit 438ee1a
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 22 deletions.
26 changes: 15 additions & 11 deletions src/main/java/fi/dy/masa/malilib/event/RenderEventHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.List;

import net.minecraft.class_10209;
import net.minecraft.client.gui.LayeredDrawer;
import net.minecraft.util.profiler.Profiler;
import org.jetbrains.annotations.ApiStatus;
import org.joml.Matrix4f;
Expand Down Expand Up @@ -93,25 +94,28 @@ public void registerWorldLastRenderer(IRenderer renderer)
}

@ApiStatus.Internal
public void onRenderGameOverlayPost(DrawContext drawContext, MinecraftClient mc, float partialTicks)
public void onRenderGameOverlayPost(DrawContext drawContext, MinecraftClient mc, float partialTicks, LayeredDrawer layeredDrawer)
{
class_10209.method_64146().push("malilib_rendergameoverlaypost");
Profiler profiler = class_10209.method_64146();

profiler.push("malilib_rendergameoverlaypost");

if (this.overlayRenderers.isEmpty() == false)
{
for (IRenderer renderer : this.overlayRenderers)
{
class_10209.method_64146().push(renderer.getProfilerSectionSupplier());
profiler.push(renderer.getProfilerSectionSupplier());
renderer.onRenderGameOverlayPostAdvanced(drawContext, partialTicks, layeredDrawer, profiler, mc);
renderer.onRenderGameOverlayPost(drawContext);
class_10209.method_64146().pop();
profiler.pop();
}
}

class_10209.method_64146().push("malilib_ingamemessages");
profiler.push("malilib_ingamemessages");
InfoUtils.renderInGameMessages(drawContext);
class_10209.method_64146().pop();
profiler.pop();

class_10209.method_64146().pop();
profiler.pop();
}

@ApiStatus.Internal
Expand Down Expand Up @@ -155,7 +159,7 @@ public void runRenderWorldPreMain(Matrix4f posMatrix, Matrix4f projMatrix, Minec
for (IRenderer renderer : this.worldPreMainRenderers)
{
profiler.push(renderer.getProfilerSectionSupplier());
renderer.onRenderWorldPreMain(posMatrix, projMatrix, frustum, camera, fog);
renderer.onRenderWorldPreMain(posMatrix, projMatrix, frustum, camera, fog, profiler);
profiler.pop();
}

Expand Down Expand Up @@ -198,7 +202,7 @@ public void runRenderWorldPreParticles(Matrix4f posMatrix, Matrix4f projMatrix,
for (IRenderer renderer : this.worldPreParticleRenderers)
{
profiler.push(renderer.getProfilerSectionSupplier());
renderer.onRenderWorldPreParticle(posMatrix, projMatrix, frustum, camera, fog);
renderer.onRenderWorldPreParticle(posMatrix, projMatrix, frustum, camera, fog, profiler);
profiler.pop();
}

Expand Down Expand Up @@ -241,7 +245,7 @@ public void runRenderWorldPreWeather(Matrix4f posMatrix, Matrix4f projMatrix, Mi
for (IRenderer renderer : this.worldPreWeatherRenderers)
{
profiler.push(renderer.getProfilerSectionSupplier());
renderer.onRenderWorldPreWeather(posMatrix, projMatrix, frustum, camera, fog);
renderer.onRenderWorldPreWeather(posMatrix, projMatrix, frustum, camera, fog, profiler);
profiler.pop();
}

Expand Down Expand Up @@ -332,7 +336,7 @@ public void runRenderWorldLast(Matrix4f posMatrix, Matrix4f projMatrix, Minecraf
{
profiler.push(renderer.getProfilerSectionSupplier());
// This really should be used either or, and never both in the same mod.
renderer.onRenderWorldLastAdvanced(posMatrix, projMatrix, frustum, camera, fog);
renderer.onRenderWorldLastAdvanced(posMatrix, projMatrix, frustum, camera, fog, profiler);
renderer.onRenderWorldLast(posMatrix, projMatrix);
profiler.pop();
}
Expand Down
21 changes: 15 additions & 6 deletions src/main/java/fi/dy/masa/malilib/interfaces/IRenderer.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package fi.dy.masa.malilib.interfaces;

import java.util.function.Supplier;

import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.LayeredDrawer;
import net.minecraft.util.profiler.Profiler;
import org.joml.Matrix4f;

import net.minecraft.client.gui.DrawContext;
Expand All @@ -12,32 +16,37 @@
public interface IRenderer
{
/**
* Called after the vanilla overlays have been rendered
* Called after the vanilla overlays have been rendered, with advanced Parameters such as ticks, drawer, profiler
*/
default void onRenderGameOverlayPostAdvanced(DrawContext drawContext, float partialTicks, LayeredDrawer layeredDrawer, Profiler profiler, MinecraftClient mc) {}

/**
* Called after the vanilla overlays have been rendered (Original)
*/
default void onRenderGameOverlayPost(DrawContext drawContext) {}

/**
* Called before vanilla Main Pass rendering
*/
default void onRenderWorldPreMain(Matrix4f posMatrix, Matrix4f projMatrix, Frustum frustum, Camera camera, Fog fog) {}
default void onRenderWorldPreMain(Matrix4f posMatrix, Matrix4f projMatrix, Frustum frustum, Camera camera, Fog fog, Profiler profiler) {}

/**
* Called before vanilla Particle rendering
*/
default void onRenderWorldPreParticle(Matrix4f posMatrix, Matrix4f projMatrix, Frustum frustum, Camera camera, Fog fog) {}
default void onRenderWorldPreParticle(Matrix4f posMatrix, Matrix4f projMatrix, Frustum frustum, Camera camera, Fog fog, Profiler profiler) {}

/**
* Called before vanilla Weather rendering
*/
default void onRenderWorldPreWeather(Matrix4f posMatrix, Matrix4f projMatrix, Frustum frustum, Camera camera, Fog fog) {}
default void onRenderWorldPreWeather(Matrix4f posMatrix, Matrix4f projMatrix, Frustum frustum, Camera camera, Fog fog, Profiler profiler) {}

/**
* Called after vanilla world rendering, with advanced Parameters, such as Frustum, Camera, and Fog
*/
default void onRenderWorldLastAdvanced(Matrix4f posMatrix, Matrix4f projMatrix, Frustum frustum, Camera camera, Fog fog) {}
default void onRenderWorldLastAdvanced(Matrix4f posMatrix, Matrix4f projMatrix, Frustum frustum, Camera camera, Fog fog, Profiler profiler) {}

/**
* Called after vanilla world rendering
* Called after vanilla world rendering (Original)
*/
default void onRenderWorldLast(Matrix4f posMatrix, Matrix4f projMatrix) {}

Expand Down
4 changes: 3 additions & 1 deletion src/main/java/fi/dy/masa/malilib/mixin/MixinInGameHud.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package fi.dy.masa.malilib.mixin;

import net.minecraft.client.gui.LayeredDrawer;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand All @@ -16,10 +17,11 @@
public abstract class MixinInGameHud
{
@Shadow @Final private MinecraftClient client;
@Shadow @Final private LayeredDrawer layeredDrawer;

@Inject(method = "render", at = @At("RETURN"))
private void onGameOverlayPost(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci)
{
((RenderEventHandler) RenderEventHandler.getInstance()).onRenderGameOverlayPost(context, this.client, tickCounter.getTickDelta(false));
//((RenderEventHandler) RenderEventHandler.getInstance()).onRenderGameOverlayPost(context, this.client, tickCounter.getTickDelta(false), this.layeredDrawer);
}
}
15 changes: 11 additions & 4 deletions src/main/java/fi/dy/masa/malilib/test/TestRenderHandler.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package fi.dy.masa.malilib.test;

import java.util.function.Supplier;

import net.minecraft.client.gui.LayeredDrawer;
import net.minecraft.util.profiler.Profiler;
import org.joml.Matrix4f;

import com.mojang.blaze3d.systems.RenderSystem;
Expand Down Expand Up @@ -43,13 +46,13 @@ public class TestRenderHandler implements IRenderer
private boolean wasHeld = false;

@Override
public void onRenderGameOverlayPost(DrawContext drawContext)
public void onRenderGameOverlayPostAdvanced(DrawContext drawContext, float partialTicks, LayeredDrawer layeredDrawer, Profiler profiler, MinecraftClient mc)
{
MinecraftClient mc = MinecraftClient.getInstance();

if (MaLiLibConfigs.Test.TEST_CONFIG_BOOLEAN.getBooleanValue() && GuiBase.isAltDown())
{
profiler.push(this.getProfilerSectionSupplier()+"_render_overlay");
renderInventoryOverlay(mc, drawContext);
profiler.pop();
}
}

Expand All @@ -65,12 +68,13 @@ public void onRenderWorldLast(Matrix4f posMatrix, Matrix4f projMatrix)
}

@Override
public void onRenderWorldPreWeather(Matrix4f posMatrix, Matrix4f projMatrix, Frustum frustum, Camera camera, Fog fog)
public void onRenderWorldPreWeather(Matrix4f posMatrix, Matrix4f projMatrix, Frustum frustum, Camera camera, Fog fog, Profiler profiler)
{
if (MaLiLibConfigs.Test.TEST_CONFIG_BOOLEAN.getBooleanValue())
{
MinecraftClient mc = MinecraftClient.getInstance();

profiler.push(this.getProfilerSectionSupplier()+"_test_walls");
if (wasHeld && !GuiBase.isShiftDown())
{
TestWalls.clear();
Expand All @@ -80,12 +84,15 @@ else if (GuiBase.isShiftDown())
{
if (TestWalls.needsUpdate(camera.getBlockPos()))
{
profiler.swap(this.getProfilerSectionSupplier()+"_test_walls_update");
TestWalls.update(camera, mc);
}

profiler.swap(this.getProfilerSectionSupplier()+"_test_walls_draw");
TestWalls.draw(camera.getPos(), posMatrix, projMatrix, mc);
wasHeld = true;
}
profiler.pop();
}
}

Expand Down

0 comments on commit 438ee1a

Please sign in to comment.