Implement DhApi Before/After render events
This commit is contained in:
+5
-9
@@ -1,12 +1,11 @@
|
||||
package com.seibel.lod.core.api.external.methods.events.abstractEvents;
|
||||
|
||||
import com.seibel.lod.core.api.external.items.objects.math.DhApiMat4f;
|
||||
import com.seibel.lod.core.api.external.methods.events.sharedParameterObjects.DhApiRenderParam;
|
||||
import com.seibel.lod.core.api.implementation.interfaces.events.IDhApiEvent;
|
||||
|
||||
/**
|
||||
* @author James Seibel
|
||||
* @version 2022-7-17
|
||||
* @version 2022-8-21
|
||||
*/
|
||||
public abstract class DhApiAfterRenderEvent implements IDhApiEvent<DhApiAfterRenderEvent.EventParam>
|
||||
{
|
||||
@@ -35,14 +34,11 @@ public abstract class DhApiAfterRenderEvent implements IDhApiEvent<DhApiAfterRen
|
||||
|
||||
public static class EventParam extends DhApiRenderParam
|
||||
{
|
||||
public EventParam(
|
||||
DhApiMat4f newMinecraftProjectionMatrix, DhApiMat4f newMinecraftModelViewMatrix,
|
||||
DhApiMat4f newDistantHorizonsProjectionMatrix, DhApiMat4f newDistantHorizonsModelViewMatrix,
|
||||
float newPartialTicks)
|
||||
public EventParam(DhApiRenderParam dhApiRenderParam)
|
||||
{
|
||||
super(newMinecraftProjectionMatrix, newMinecraftModelViewMatrix,
|
||||
newDistantHorizonsProjectionMatrix, newDistantHorizonsModelViewMatrix,
|
||||
newPartialTicks);
|
||||
super(dhApiRenderParam.mcProjectionMatrix, dhApiRenderParam.mcModelViewMatrix,
|
||||
dhApiRenderParam.dhProjectionMatrix, dhApiRenderParam.dhModelViewMatrix,
|
||||
dhApiRenderParam.partialTicks);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-10
@@ -1,17 +1,16 @@
|
||||
package com.seibel.lod.core.api.external.methods.events.abstractEvents;
|
||||
|
||||
import com.seibel.lod.core.api.external.items.objects.math.DhApiMat4f;
|
||||
import com.seibel.lod.core.api.external.methods.events.sharedParameterObjects.DhApiRenderParam;
|
||||
import com.seibel.lod.core.api.implementation.interfaces.events.IDhApiEvent;
|
||||
|
||||
/**
|
||||
* @author James Seibel
|
||||
* @version 2022-7-17
|
||||
* @version 2022-8-21
|
||||
*/
|
||||
public abstract class DhApiBeforeRenderEvent implements IDhApiEvent<DhApiBeforeRenderEvent.EventParam>
|
||||
{
|
||||
/**
|
||||
* Fired before Distant Horizons finishes rendering fake chunks.
|
||||
* Fired before Distant Horizons renders fake chunks.
|
||||
*
|
||||
* @return whether the event should be canceled or not.
|
||||
*/
|
||||
@@ -38,14 +37,11 @@ public abstract class DhApiBeforeRenderEvent implements IDhApiEvent<DhApiBeforeR
|
||||
|
||||
public static class EventParam extends DhApiRenderParam
|
||||
{
|
||||
public EventParam(
|
||||
DhApiMat4f newMinecraftProjectionMatrix, DhApiMat4f newMinecraftModelViewMatrix,
|
||||
DhApiMat4f newDistantHorizonsProjectionMatrix, DhApiMat4f newDistantHorizonsModelViewMatrix,
|
||||
float newPartialTicks)
|
||||
public EventParam(DhApiRenderParam dhApiRenderParam)
|
||||
{
|
||||
super(newMinecraftProjectionMatrix, newMinecraftModelViewMatrix,
|
||||
newDistantHorizonsProjectionMatrix, newDistantHorizonsModelViewMatrix,
|
||||
newPartialTicks);
|
||||
super(dhApiRenderParam.mcProjectionMatrix, dhApiRenderParam.mcModelViewMatrix,
|
||||
dhApiRenderParam.dhProjectionMatrix, dhApiRenderParam.dhModelViewMatrix,
|
||||
dhApiRenderParam.partialTicks);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+25
-12
@@ -1,41 +1,54 @@
|
||||
package com.seibel.lod.core.api.external.methods.events.sharedParameterObjects;
|
||||
|
||||
import com.seibel.lod.core.api.external.items.objects.math.DhApiMat4f;
|
||||
import com.seibel.lod.core.objects.math.Mat4f;
|
||||
|
||||
/**
|
||||
* Parameter passed into Render events.
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 7-17-2022
|
||||
* @version 2022-8-21
|
||||
*/
|
||||
public class DhApiRenderParam
|
||||
{
|
||||
/** The projection matrix Minecraft is using to render this frame. */
|
||||
public final DhApiMat4f MinecraftProjectionMatrix;
|
||||
public final DhApiMat4f mcProjectionMatrix;
|
||||
/** The model view matrix Minecraft is using to render this frame. */
|
||||
public final DhApiMat4f MinecraftModelViewMatrix;
|
||||
public final DhApiMat4f mcModelViewMatrix;
|
||||
|
||||
/** The projection matrix Distant Horizons is using to render this frame. */
|
||||
public final DhApiMat4f DistantHorizonsProjectionMatrix;
|
||||
public final DhApiMat4f dhProjectionMatrix;
|
||||
/** The model view matrix Distant Horizons is using to render this frame. */
|
||||
public final DhApiMat4f DistantHorizonsModelViewMatrix;
|
||||
public final DhApiMat4f dhModelViewMatrix;
|
||||
|
||||
/** Indicates how far into this tick the frame is. */
|
||||
public final float partialTicks;
|
||||
|
||||
|
||||
protected DhApiRenderParam(
|
||||
DhApiMat4f newMinecraftProjectionMatrix, DhApiMat4f newMinecraftModelViewMatrix,
|
||||
DhApiMat4f newDistantHorizonsProjectionMatrix, DhApiMat4f newDistantHorizonsModelViewMatrix,
|
||||
|
||||
public DhApiRenderParam(
|
||||
Mat4f newMcProjectionMatrix, Mat4f newMcModelViewMatrix,
|
||||
Mat4f newDhProjectionMatrix, Mat4f newDhModelViewMatrix,
|
||||
float newPartialTicks)
|
||||
{
|
||||
this.MinecraftProjectionMatrix = newMinecraftProjectionMatrix;
|
||||
this.MinecraftModelViewMatrix = newMinecraftModelViewMatrix;
|
||||
this(newMcProjectionMatrix.createApiObject(), newMcModelViewMatrix.createApiObject(),
|
||||
newDhProjectionMatrix.createApiObject(), newDhModelViewMatrix.createApiObject(),
|
||||
newPartialTicks);
|
||||
}
|
||||
|
||||
public DhApiRenderParam(
|
||||
DhApiMat4f newMcProjectionMatrix, DhApiMat4f newMcModelViewMatrix,
|
||||
DhApiMat4f newDhProjectionMatrix, DhApiMat4f newDhModelViewMatrix,
|
||||
float newPartialTicks)
|
||||
{
|
||||
this.mcProjectionMatrix = newMcProjectionMatrix;
|
||||
this.mcModelViewMatrix = newMcModelViewMatrix;
|
||||
|
||||
this.DistantHorizonsProjectionMatrix = newDistantHorizonsProjectionMatrix;
|
||||
this.DistantHorizonsModelViewMatrix = newDistantHorizonsModelViewMatrix;
|
||||
this.dhProjectionMatrix = newDhProjectionMatrix;
|
||||
this.dhModelViewMatrix = newDhModelViewMatrix;
|
||||
|
||||
this.partialTicks = newPartialTicks;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -21,10 +21,14 @@ package com.seibel.lod.core.api.internal.a7;
|
||||
|
||||
import com.seibel.lod.core.a7.level.IClientLevel;
|
||||
import com.seibel.lod.core.a7.world.*;
|
||||
import com.seibel.lod.core.api.external.methods.events.abstractEvents.DhApiAfterRenderEvent;
|
||||
import com.seibel.lod.core.api.external.methods.events.abstractEvents.DhApiBeforeRenderEvent;
|
||||
import com.seibel.lod.core.api.external.methods.events.sharedParameterObjects.DhApiRenderParam;
|
||||
import com.seibel.lod.core.config.Config;
|
||||
import com.seibel.lod.core.ModInfo;
|
||||
import com.seibel.lod.core.enums.rendering.EDebugMode;
|
||||
import com.seibel.lod.core.enums.rendering.ERendererMode;
|
||||
import com.seibel.lod.core.handlers.dependencyInjection.DhApiEventInjector;
|
||||
import com.seibel.lod.core.handlers.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.lod.core.logging.ConfigBasedLogger;
|
||||
import com.seibel.lod.core.logging.ConfigBasedSpamLogger;
|
||||
@@ -38,8 +42,6 @@ import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.minecraft.IProfilerWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.world.IClientLevelWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.world.ILevelWrapper;
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
@@ -251,9 +253,17 @@ public class ClientApi
|
||||
{
|
||||
if (Config.Client.Advanced.Debugging.rendererMode.get() == ERendererMode.DEFAULT)
|
||||
{
|
||||
if (!rendererDisabledBecauseOfExceptions)
|
||||
DhApiRenderParam renderEventParam =
|
||||
new DhApiRenderParam(mcProjectionMatrix, mcModelViewMatrix,
|
||||
RenderUtil.createLodProjectionMatrix(mcProjectionMatrix, partialTicks),
|
||||
RenderUtil.createLodModelViewMatrix(mcModelViewMatrix), partialTicks);
|
||||
|
||||
boolean renderingCanceled = DhApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeRenderEvent.class, new DhApiBeforeRenderEvent.EventParam(renderEventParam));
|
||||
|
||||
if (!rendererDisabledBecauseOfExceptions && !renderingCanceled)
|
||||
{
|
||||
level.render(mcModelViewMatrix, mcProjectionMatrix, partialTicks, profiler);
|
||||
DhApiEventInjector.INSTANCE.fireAllEvents(DhApiAfterRenderEvent.class, new DhApiAfterRenderEvent.EventParam(renderEventParam));
|
||||
}
|
||||
}
|
||||
else if (Config.Client.Advanced.Debugging.rendererMode.get() == ERendererMode.DEBUG)
|
||||
|
||||
Reference in New Issue
Block a user