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 91a1b4adc9
commit 7cfaf06f36
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 com.jozufozu.flywheel.api.BackendImplemented;
import com.jozufozu.flywheel.api.event.RenderContext;
import com.jozufozu.flywheel.api.event.RenderStage;
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.Vec3i;
@BackendImplemented
public interface Engine extends InstancerProvider {
/**
* Create a plan that will be executed every frame.

View File

@ -1,5 +1,6 @@
package com.jozufozu.flywheel.api.event;
import org.jetbrains.annotations.ApiStatus;
import org.joml.Matrix4f;
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.RenderBuffers;
@ApiStatus.NonExtendable
public interface RenderContext {
LevelRenderer renderer();

View File

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

View File

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

View File

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

View File

@ -1,8 +1,11 @@
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.
*/
@ApiStatus.NonExtendable
public interface DistanceUpdateLimiter {
/**
* 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;
import org.jetbrains.annotations.ApiStatus;
import org.joml.FrustumIntersection;
@ApiStatus.NonExtendable
public interface VisualFrameContext {
double cameraX();

View File

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

View File

@ -1,5 +1,7 @@
package com.jozufozu.flywheel.api.visualization;
import org.jetbrains.annotations.ApiStatus;
import com.jozufozu.flywheel.api.instance.InstancerProvider;
import net.minecraft.core.Vec3i;
@ -7,6 +9,7 @@ import net.minecraft.core.Vec3i;
/**
* A context object passed on visual creation.
*/
@ApiStatus.NonExtendable
public interface VisualizationContext {
/**
* @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
* that block entities and entities inside the level should
* render with Flywheel.
*
* <br>
* {@link net.minecraft.client.Minecraft#level Minecraft#level} is special cased and will support Flywheel by default.
*/
public interface VisualizationLevel extends LevelAccessor {