Start adding a event API system

This commit is contained in:
James Seibel
2022-07-13 07:54:34 -05:00
parent 9673150fa1
commit e04f1d9dd5
4 changed files with 82 additions and 0 deletions
@@ -0,0 +1,37 @@
package com.seibel.lod.core.api.external.events;
import com.seibel.lod.core.api.external.events.interfaces.IDhApiEvent;
import com.seibel.lod.core.api.external.sharedObjects.DhApiResult;
/**
* Handles adding/removing event handlers.
* Based off of JQuery's event system.
*
* @author James Seibel
* @version 2022-7-13
*/
public class DhApiEventRegister
{
/**
* Registers the given event handler. <Br>
* Only one eventHandler of a specific class can be added at a time.
* If multiple of the same eventHandler are added DhApiResult will return
* the name of the already added handler and success = false.
*/
public static DhApiResult on(IDhApiEvent eventHandler)
{
throw new UnsupportedOperationException();
}
/**
* Removes the given event handler for this event if one has been registered. <br>
* If no eventHandler of the given class has been registered the result will return
* success = false.
*/
public static DhApiResult off(IDhApiEvent eventHandler)
{
throw new UnsupportedOperationException();
}
}
@@ -0,0 +1 @@
The events api package holds objects and methods for listening to events fired by Distant Horizons'.
@@ -0,0 +1,13 @@
package com.seibel.lod.core.api.external.events.interfaces;
/**
* All Api event handlers should implement this, so
* they can be more easily organized.
*
* @author James Seibel
* @version 2022-7-13
*/
public interface IDhApiEvent
{
}
@@ -0,0 +1,31 @@
package com.seibel.lod.core.api.external.events.interfaces;
import com.seibel.lod.core.objects.math.Mat4f;
import com.seibel.lod.core.wrapperInterfaces.world.ILevelWrapper;
/**
* Event handler for when Distant Horizons
* starts and finishes rendering
*
* @author James Seibel
* @version 2022-7-13
*/
public interface IDhApiRenderEvent extends IDhApiEvent
{
// TODO should we allow editing the levelWrapper MVM matrix, etc.?
// TODO make sure to document it either way.
/**
* Called before Distant Horizons starts rendering. <Br>
* If this methods returns false DH's rendering will be skipped for that frame.
*/
public boolean beforeRender(ILevelWrapper levelWrapper, Mat4f mcModelViewMatrix, Mat4f mcProjectionMatrix, float partialTicks);
/**
* Called after Distant Horizons finishes rendering.
* If DH has rendering disabled or beforeRender //TODO Link
* canceled the rendering this event will not fire.
*/
public void afterRender(ILevelWrapper levelWrapper, Mat4f mcModelViewMatrix, Mat4f mcProjectionMatrix, float partialTicks);
}