Back me up here!

- Add @BackendImplemented annotation to API and use where needed.
- Add @ApiStatus.NonExtendable to interfaces that are missing it.
This commit is contained in:
Jozufozu 2024-01-24 12:09:54 -08:00
parent 6f9cd8c099
commit 9b2b2be3a8
11 changed files with 46 additions and 1 deletions

View file

@ -0,0 +1,22 @@
package com.jozufozu.flywheel.api;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* <p>Indicates that the annotated API class, interface or method must not be extended, implemented or overridden,
* <strong>except by backend implementations</strong>.</p>
*
* <p>API class, interface or method may not be marked {@code final} because it is extended by classes of registered backends
* but it is not supposed to be extended outside of backend implementations. Instances of classes and interfaces marked with this annotation
* may be cast to an internal implementing class within the active backend, leading to {@code ClassCastException}
* if a different implementation is provided by a client.</p>
*/
@Documented
@Retention(RetentionPolicy.CLASS)
@Target({ElementType.TYPE, ElementType.ANNOTATION_TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.PACKAGE})
public @interface BackendImplemented {
}

View file

@ -2,6 +2,7 @@ package com.jozufozu.flywheel.api.backend;
import java.util.List; import java.util.List;
import com.jozufozu.flywheel.api.BackendImplemented;
import com.jozufozu.flywheel.api.event.RenderContext; import com.jozufozu.flywheel.api.event.RenderContext;
import com.jozufozu.flywheel.api.event.RenderStage; import com.jozufozu.flywheel.api.event.RenderStage;
import com.jozufozu.flywheel.api.instance.Instance; import com.jozufozu.flywheel.api.instance.Instance;
@ -13,6 +14,7 @@ import net.minecraft.client.Camera;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Vec3i; import net.minecraft.core.Vec3i;
@BackendImplemented
public interface Engine extends InstancerProvider { public interface Engine extends InstancerProvider {
/** /**
* Create a plan that will be executed every frame. * Create a plan that will be executed every frame.

View file

@ -1,5 +1,6 @@
package com.jozufozu.flywheel.api.event; package com.jozufozu.flywheel.api.event;
import org.jetbrains.annotations.ApiStatus;
import org.joml.Matrix4f; import org.joml.Matrix4f;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
@ -9,6 +10,7 @@ import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.client.renderer.RenderBuffers; import net.minecraft.client.renderer.RenderBuffers;
@ApiStatus.NonExtendable
public interface RenderContext { public interface RenderContext {
LevelRenderer renderer(); LevelRenderer renderer();

View file

@ -1,5 +1,8 @@
package com.jozufozu.flywheel.api.instance; package com.jozufozu.flywheel.api.instance;
import com.jozufozu.flywheel.api.BackendImplemented;
@BackendImplemented
public interface InstanceHandle { public interface InstanceHandle {
void setChanged(); void setChanged();

View file

@ -2,6 +2,8 @@ package com.jozufozu.flywheel.api.instance;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import com.jozufozu.flywheel.api.BackendImplemented;
/** /**
* An instancer is how you interact with an instanced model. * An instancer is how you interact with an instanced model.
* <p> * <p>
@ -20,6 +22,7 @@ import org.jetbrains.annotations.Nullable;
* *
* @param <I> the data that represents a copy of the instanced model. * @param <I> the data that represents a copy of the instanced model.
*/ */
@BackendImplemented
public interface Instancer<I extends Instance> { public interface Instancer<I extends Instance> {
/** /**
* @return a handle to a new copy of this model. * @return a handle to a new copy of this model.

View file

@ -1,8 +1,10 @@
package com.jozufozu.flywheel.api.instance; package com.jozufozu.flywheel.api.instance;
import com.jozufozu.flywheel.api.BackendImplemented;
import com.jozufozu.flywheel.api.event.RenderStage; import com.jozufozu.flywheel.api.event.RenderStage;
import com.jozufozu.flywheel.api.model.Model; import com.jozufozu.flywheel.api.model.Model;
@BackendImplemented
public interface InstancerProvider { public interface InstancerProvider {
/** /**
* Get an instancer for the given instance type, model, and render stage. * Get an instancer for the given instance type, model, and render stage.

View file

@ -1,8 +1,11 @@
package com.jozufozu.flywheel.api.visual; package com.jozufozu.flywheel.api.visual;
import org.jetbrains.annotations.ApiStatus;
/** /**
* Interface for rate-limiting updates based on an object's distance from the camera. * Interface for rate-limiting updates based on an object's distance from the camera.
*/ */
@ApiStatus.NonExtendable
public interface DistanceUpdateLimiter { public interface DistanceUpdateLimiter {
/** /**
* Check to see if an object at the given position relative to the camera should be updated. * Check to see if an object at the given position relative to the camera should be updated.

View file

@ -1,7 +1,9 @@
package com.jozufozu.flywheel.api.visual; package com.jozufozu.flywheel.api.visual;
import org.jetbrains.annotations.ApiStatus;
import org.joml.FrustumIntersection; import org.joml.FrustumIntersection;
@ApiStatus.NonExtendable
public interface VisualFrameContext { public interface VisualFrameContext {
double cameraX(); double cameraX();

View file

@ -1,5 +1,8 @@
package com.jozufozu.flywheel.api.visual; package com.jozufozu.flywheel.api.visual;
import org.jetbrains.annotations.ApiStatus;
@ApiStatus.NonExtendable
public interface VisualTickContext { public interface VisualTickContext {
double cameraX(); double cameraX();

View file

@ -1,5 +1,7 @@
package com.jozufozu.flywheel.api.visualization; package com.jozufozu.flywheel.api.visualization;
import org.jetbrains.annotations.ApiStatus;
import com.jozufozu.flywheel.api.instance.InstancerProvider; import com.jozufozu.flywheel.api.instance.InstancerProvider;
import net.minecraft.core.Vec3i; import net.minecraft.core.Vec3i;
@ -7,6 +9,7 @@ import net.minecraft.core.Vec3i;
/** /**
* A context object passed on visual creation. * A context object passed on visual creation.
*/ */
@ApiStatus.NonExtendable
public interface VisualizationContext { public interface VisualizationContext {
/** /**
* @return The {@link InstancerProvider} that the visual can use to get instancers to render models. * @return The {@link InstancerProvider} that the visual can use to get instancers to render models.

View file

@ -6,7 +6,7 @@ import net.minecraft.world.level.LevelAccessor;
* A marker interface custom levels can override to indicate * A marker interface custom levels can override to indicate
* that block entities and entities inside the level should * that block entities and entities inside the level should
* render with Flywheel. * render with Flywheel.
* * <br>
* {@link net.minecraft.client.Minecraft#level Minecraft#level} is special cased and will support Flywheel by default. * {@link net.minecraft.client.Minecraft#level Minecraft#level} is special cased and will support Flywheel by default.
*/ */
public interface VisualizationLevel extends LevelAccessor { public interface VisualizationLevel extends LevelAccessor {