Add DhApi Before/After Render Event objects

This commit is contained in:
James Seibel
2022-07-17 20:09:14 -05:00
parent c7e4781a95
commit a7c3f9ec20
7 changed files with 150 additions and 34 deletions
@@ -1,11 +0,0 @@
package com.seibel.lod.core.api.external.items.objects.events;
/**
* @author James Seibel
* @version 2022-7-14
*/
public class DhApiAfterRenderEvent extends DhApiRenderEvent
{
/** False if DH rendering was disabled or canceled for this frame. */
public boolean renderingEnabled;
}
@@ -1,23 +0,0 @@
package com.seibel.lod.core.api.external.items.objects.events;
import com.seibel.lod.core.api.external.items.interfaces.world.IDhApiLevelWrapper;
import com.seibel.lod.core.api.external.items.objects.math.DhApiMat4f;
/**
* @author James Seibel
* @version 2022-7-14
*/
public class DhApiRenderEvent
{
public IDhApiLevelWrapper levelWrapper;
// the matrices received from Minecraft
public DhApiMat4f mcModelViewMatrix;
public DhApiMat4f mcProjectionMatrix;
// the matrices used by Distant Horizons
public DhApiMat4f dhModelViewMatrix;
public DhApiMat4f dhProjectionMatrix;
public float partialTicks;
}
@@ -0,0 +1,29 @@
package com.seibel.lod.core.api.external.methods.events.abstractEvents;
import com.seibel.lod.core.api.external.methods.events.parameterObjects.DhApiAfterRenderParam;
import com.seibel.lod.core.api.implementation.interfaces.events.IDhApiEvent;
/**
* @author James Seibel
* @version 2022-7-17
*/
public abstract class DhApiAfterRenderEvent implements IDhApiEvent<DhApiAfterRenderParam>
{
/** Fired after Distant Horizons finishes rendering fake chunks. */
public abstract void afterRender(DhApiAfterRenderParam input);
//=========================//
// internal DH API methods //
//=========================//
@Override
public final boolean onEvent(DhApiAfterRenderParam input)
{
afterRender(input);
return false;
}
@Override
public final boolean getCancelable() { return false; }
}
@@ -0,0 +1,32 @@
package com.seibel.lod.core.api.external.methods.events.abstractEvents;
import com.seibel.lod.core.api.external.methods.events.parameterObjects.DhApiBeforeRenderParam;
import com.seibel.lod.core.api.implementation.interfaces.events.IDhApiEvent;
/**
* @author James Seibel
* @version 2022-7-17
*/
public abstract class DhApiBeforeRenderEvent implements IDhApiEvent<DhApiBeforeRenderParam>
{
/**
* Fired before Distant Horizons finishes rendering fake chunks.
*
* @return whether the event should be canceled or not.
*/
public abstract boolean beforeRender(DhApiBeforeRenderParam input);
//=========================//
// internal DH API methods //
//=========================//
@Override
public final boolean onEvent(DhApiBeforeRenderParam input)
{
return beforeRender(input);
}
@Override
public final boolean getCancelable() { return true; }
}
@@ -0,0 +1,24 @@
package com.seibel.lod.core.api.external.methods.events.parameterObjects;
import com.seibel.lod.core.api.external.items.objects.math.DhApiMat4f;
/**
* Parameter passed into the After Render event.
*
* @author James Seibel
* @version 7-17-2022
*/
public class DhApiAfterRenderParam extends DhApiRenderParam
{
public DhApiAfterRenderParam(
DhApiMat4f newMinecraftProjectionMatrix, DhApiMat4f newMinecraftModelViewMatrix,
DhApiMat4f newDistantHorizonsProjectionMatrix, DhApiMat4f newDistantHorizonsModelViewMatrix,
float newPartialTicks)
{
super(newMinecraftProjectionMatrix, newMinecraftModelViewMatrix,
newDistantHorizonsProjectionMatrix, newDistantHorizonsModelViewMatrix,
newPartialTicks);
}
}
@@ -0,0 +1,24 @@
package com.seibel.lod.core.api.external.methods.events.parameterObjects;
import com.seibel.lod.core.api.external.items.objects.math.DhApiMat4f;
/**
* Parameter passed into the Before Render event.
*
* @author James Seibel
* @version 7-17-2022
*/
public class DhApiBeforeRenderParam extends DhApiRenderParam
{
public DhApiBeforeRenderParam(
DhApiMat4f newMinecraftProjectionMatrix, DhApiMat4f newMinecraftModelViewMatrix,
DhApiMat4f newDistantHorizonsProjectionMatrix, DhApiMat4f newDistantHorizonsModelViewMatrix,
float newPartialTicks)
{
super(newMinecraftProjectionMatrix, newMinecraftModelViewMatrix,
newDistantHorizonsProjectionMatrix, newDistantHorizonsModelViewMatrix,
newPartialTicks);
}
}
@@ -0,0 +1,41 @@
package com.seibel.lod.core.api.external.methods.events.parameterObjects;
import com.seibel.lod.core.api.external.items.objects.math.DhApiMat4f;
/**
* Parameter passed into Render events.
*
* @author James Seibel
* @version 7-17-2022
*/
class DhApiRenderParam // default visibility so this class isn't visible outside the package
{
/** The projection matrix Minecraft is using to render this frame. */
public final DhApiMat4f MinecraftProjectionMatrix;
/** The model view matrix Minecraft is using to render this frame. */
public final DhApiMat4f MinecraftModelViewMatrix;
/** The projection matrix Distant Horizons is using to render this frame. */
public final DhApiMat4f DistantHorizonsProjectionMatrix;
/** The model view matrix Distant Horizons is using to render this frame. */
public final DhApiMat4f DistantHorizonsModelViewMatrix;
/** Indicates how far into this tick the frame is. */
public final float partialTicks;
protected DhApiRenderParam(
DhApiMat4f newMinecraftProjectionMatrix, DhApiMat4f newMinecraftModelViewMatrix,
DhApiMat4f newDistantHorizonsProjectionMatrix, DhApiMat4f newDistantHorizonsModelViewMatrix,
float newPartialTicks)
{
this.MinecraftProjectionMatrix = newMinecraftProjectionMatrix;
this.MinecraftModelViewMatrix = newMinecraftModelViewMatrix;
this.DistantHorizonsProjectionMatrix = newDistantHorizonsProjectionMatrix;
this.DistantHorizonsModelViewMatrix = newDistantHorizonsModelViewMatrix;
this.partialTicks = newPartialTicks;
}
}