diff --git a/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/RenderContext.java b/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/RenderContext.java
deleted file mode 100644
index f4e8a8f4b..000000000
--- a/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/RenderContext.java
+++ /dev/null
@@ -1,75 +0,0 @@
-package net.modificationstation.stationapi.api.client.render;
-
-import net.modificationstation.stationapi.api.client.render.mesh.Mesh;
-import net.modificationstation.stationapi.api.client.render.mesh.MeshBuilder;
-import net.modificationstation.stationapi.api.client.render.mesh.MutableQuadView;
-import net.modificationstation.stationapi.api.client.render.mesh.QuadEmitter;
-import net.modificationstation.stationapi.api.client.render.model.BakedModel;
-
-import java.util.function.Consumer;
-
-/**
- * This defines the instance made available to models for buffering vertex data at render time.
- *
- *
Only the renderer should implement or extend this interface.
- */
-public interface RenderContext {
- /**
- * Used by models to send vertex data previously baked via {@link MeshBuilder}.
- * The fastest option and preferred whenever feasible.
- */
- Consumer meshConsumer();
-
- /**
- * Fabric causes vanilla baked models to send themselves
- * via this interface. Can also be used by compound models that contain a mix
- * of vanilla baked models, packaged quads and/or dynamic elements.
- */
- Consumer fallbackConsumer();
-
- /**
- * Returns a {@link QuadEmitter} instance that emits directly to the render buffer.
- * It remains necessary to call {@link QuadEmitter#emit()} to output the quad.
- *
- *
This method will always be less performant than passing pre-baked meshes
- * via {@link #meshConsumer()}. It should be used sparingly for model components that
- * demand it - text, icons, dynamic indicators, or other elements that vary too
- * much for static baking to be feasible.
- *
- *
Calling this method invalidates any {@link QuadEmitter} returned earlier.
- * Will be threadlocal/re-used - do not retain references.
- */
- QuadEmitter getEmitter();
-
- /**
- * Causes all models/quads/meshes sent to this consumer to be transformed by the provided
- * {@link QuadTransform} that edits each quad before buffering. Quads in the mesh will
- * be passed to the {@link QuadTransform} for modification before offsets, face culling or lighting are applied.
- * Meant for animation and mesh customization.
- *
- *
You MUST call {@link #popTransform()} after model is done outputting quads.
- *
- *
More than one transformer can be added to the context. Transformers are applied in reverse order.
- * (Last pushed is applied first.)
- *
- *
Meshes are never mutated by the transformer - only buffered quads. This ensures thread-safe
- * use of meshes/models across multiple chunk builders.
- */
- void pushTransform(QuadTransform transform);
-
- /**
- * Removes the transformation added by the last call to {@link #pushTransform(QuadTransform)}.
- * MUST be called before exiting from {@link BakedModel} .emit... methods.
- */
- void popTransform();
-
- @FunctionalInterface
- interface QuadTransform {
-
- /**
- * Return false to filter out quads from rendering. When more than one transform
- * is in effect, returning false means unapplied transforms will not receive the quad.
- */
- boolean transform(MutableQuadView quad);
- }
-}
\ No newline at end of file
diff --git a/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/Renderer.java b/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/Renderer.java
index 796d07013..0b6259d94 100644
--- a/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/Renderer.java
+++ b/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/Renderer.java
@@ -1,11 +1,6 @@
package net.modificationstation.stationapi.api.client.render;
-import net.modificationstation.stationapi.api.client.render.material.MaterialFinder;
-import net.modificationstation.stationapi.api.client.render.material.RenderMaterial;
-import net.modificationstation.stationapi.api.client.render.mesh.MeshBuilder;
import net.modificationstation.stationapi.api.client.render.model.BakedModelRenderer;
-import net.modificationstation.stationapi.api.util.Identifier;
-import org.jetbrains.annotations.Nullable;
/**
* Interface for rendering plug-ins that provide enhanced capabilities
@@ -13,41 +8,6 @@
* enhanced model rendering interfaces specified by the Fabric API.
*/
public interface Renderer {
- /**
- * Obtain a new {@link MeshBuilder} instance used to create
- * baked models with enhanced features.
- *
- *
Renderer does not retain a reference to returned instances and they should be re-used for
- * multiple models when possible to avoid memory allocation overhead.
- */
- MeshBuilder meshBuilder();
-
- /**
- * Obtain a new {@link MaterialFinder} instance used to retrieve
- * standard {@link RenderMaterial} instances.
- *
- *
Renderer does not retain a reference to returned instances and they should be re-used for
- * multiple materials when possible to avoid memory allocation overhead.
- */
- MaterialFinder materialFinder();
-
- /**
- * Return a material previously registered via {@link #registerMaterial(Identifier, RenderMaterial)}.
- * Will return null if no material was found matching the given identifier.
- */
- @Nullable
- RenderMaterial materialById(Identifier id);
-
- /**
- * Register a material for re-use by other mods or models within a mod.
- * The registry does not persist registrations - mods must create and register
- * all materials at game initialization.
- *
- *
Returns false if a material with the given identifier is already present,
- * leaving the existing material intact.
- */
- boolean registerMaterial(Identifier id, RenderMaterial material);
-
/**
* Obtain a new {@link BakedModelRenderer} instance used to render
* baked models.
diff --git a/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/material/BlendMode.java b/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/material/BlendMode.java
deleted file mode 100644
index 68db3ee17..000000000
--- a/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/material/BlendMode.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package net.modificationstation.stationapi.api.client.render.material;
-
-/**
- * Defines how sprite pixels will be blended with the scene.
- */
-public enum BlendMode {
-
- /**
- * Emulate blending behavior of {@code BlockRenderLayer} associated with the block.
- */
- DEFAULT(-1),
-
- /**
- * Fully opaque with depth test, no blending. Used for most normal blocks.
- */
- SOLID(0),
-
- /**
- * Pixels are blended with the background according to alpha colour values. Some performance cost,
- * use in moderation. Texture mip-map enabled. Used for ice.
- */
- TRANSLUCENT(1);
-
- public final int blockRenderPass;
-
- BlendMode(int blockRenderPass) {
- this.blockRenderPass = blockRenderPass;
- }
-
- public static BlendMode fromRenderPass(int renderPass) {
- return switch (renderPass) {
- case 0 -> SOLID;
- case 1 -> TRANSLUCENT;
- default -> DEFAULT;
- };
- }
-}
\ No newline at end of file
diff --git a/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/material/MaterialFinder.java b/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/material/MaterialFinder.java
deleted file mode 100644
index 7b0845d5c..000000000
--- a/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/material/MaterialFinder.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package net.modificationstation.stationapi.api.client.render.material;
-
-import net.modificationstation.stationapi.api.client.render.RenderContext;
-import net.modificationstation.stationapi.api.client.render.Renderer;
-import net.modificationstation.stationapi.api.client.render.mesh.QuadEmitter;
-
-/**
- * Finds standard {@link RenderMaterial} instances used to communicate
- * quad rendering characteristics to a {@link RenderContext}.
- *
- *
Must be obtained via {@link Renderer#materialFinder()}.
- */
-public interface MaterialFinder {
- /**
- * Returns the standard material encoding all
- * of the current settings in this finder. The settings in
- * this finder are not changed.
- *
- *
Resulting instances can and should be re-used to prevent
- * needless memory allocation. {@link Renderer} implementations
- * may or may not cache standard material instances.
- */
- RenderMaterial find();
-
- /**
- * Resets this instance to default values. Values will match those
- * in effect when an instance is newly obtained via {@link Renderer#materialFinder()}.
- */
- MaterialFinder clear();
-
- /**
- * Reserved for future use. Behavior for values > 1 is currently undefined.
- */
- MaterialFinder spriteDepth(int depth);
-
- /**
- * Defines how sprite pixels will be blended with the scene.
- *
- *
See {@link BlendMode} for more information.
- */
- MaterialFinder blendMode(int spriteIndex, BlendMode blendMode);
-
- /**
- * Vertex color(s) will be modified for quad color index unless disabled.
- */
- MaterialFinder disableColorIndex(int spriteIndex, boolean disable);
-
- /**
- * Vertex color(s) will be modified for diffuse shading unless disabled.
- */
- MaterialFinder disableDiffuse(int spriteIndex, boolean disable);
-
- /**
- * Vertex color(s) will be modified for ambient occlusion unless disabled.
- */
- MaterialFinder disableAo(int spriteIndex, boolean disable);
-
- /**
- * When true, sprite texture and color will be rendered at full brightness.
- * Lightmap values provided via {@link QuadEmitter#lightmap(int)} will be ignored.
- * False by default
- *
- *
This is the preferred method for emissive lighting effects. Some renderers
- * with advanced lighting models may not use block lightmaps and this method will
- * allow per-sprite emissive lighting in future extensions that support overlay sprites.
- *
- *
Note that color will still be modified by diffuse shading and ambient occlusion,
- * unless disabled via {@link #disableAo(int, boolean)} and {@link #disableDiffuse(int, boolean)}.
- */
- MaterialFinder emissive(int spriteIndex, boolean isEmissive);
-}
\ No newline at end of file
diff --git a/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/material/RenderMaterial.java b/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/material/RenderMaterial.java
deleted file mode 100644
index 20935c16b..000000000
--- a/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/material/RenderMaterial.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package net.modificationstation.stationapi.api.client.render.material;
-
-import net.modificationstation.stationapi.api.client.render.Renderer;
-import net.modificationstation.stationapi.api.client.render.mesh.MeshBuilder;
-import net.modificationstation.stationapi.api.client.render.mesh.MutableQuadView;
-import net.modificationstation.stationapi.api.util.Identifier;
-
-import static net.modificationstation.stationapi.api.StationAPI.NAMESPACE;
-import static net.modificationstation.stationapi.api.util.Identifier.of;
-
-import net.minecraft.block.Block;
-
-/**
- * All model quads have an associated render material governing
- * how the quad will be rendered.
- *
- *
A material instance is always immutable and thread-safe. References to a material
- * remain valid until the end of the current game session.
- *
- *
Materials can be registered and shared between mods using {@link Renderer#registerMaterial(Identifier, RenderMaterial)}.
- * The registering mod is responsible for creating each registered material at startup.
- *
- *
Materials are not required to know their registration identity, and two materials
- * with the same attributes may or may not satisfy equality and identity tests. Model
- * implementations should never attempt to analyze materials or implement control logic based on them.
- * They are only tokens for communicating quad attributes to the ModelRenderer.
- *
- *
There are three classes of materials...
- *
- *
STANDARD MATERIALS
- *
- *
Standard materials have "normal" rendering with control over lighting,
- * color, and texture blending. In the default renderer, "normal" rendering
- * emulates unmodified Minecraft. Other renderers may offer a different aesthetic.
- *
- *
The number of standard materials is finite, but not necessarily small.
- * To find a standard material, use {@link Renderer#materialFinder()}.
- *
- *
All renderer implementations should support standard materials.
- *
- *
SPECIAL MATERIALS
- *
- *
Special materials are implemented directly by the Renderer implementation, typically
- * with the aim of providing advanced/extended features. Such materials may offer additional
- * vertex attributes via extensions to {@link MeshBuilder} and {@link MutableQuadView}.
- *
- *
Special materials can be obtained using {@link Renderer#materialById(Identifier)}
- * with a known identifier. Renderers may provide other means of access. Popular
- * special materials could be implemented by multiple renderers, however there is
- * no requirement that special materials be cross-compatible.
- */
-public interface RenderMaterial {
- /**
- * This will be identical to the material that would be obtained by calling {@link MaterialFinder#find()}
- * on a new, unaltered, {@link MaterialFinder} instance. It is defined here for clarity and convenience.
- *
- *
Quads using this material use {@link Block#getRenderLayer()} of
- * the associated block to determine texture blending, honor block color index, are non-emissive, and apply both
- * diffuse and ambient occlusion shading to vertex colors.
- *
- *
All standard, non-fluid baked models are rendered using this material.
- */
- Identifier MATERIAL_STANDARD = of(NAMESPACE, "standard");
-
- /**
- * How many sprite color/uv coordinates are in the material.
- * Behavior for values > 1 is currently undefined.
- * See {@link MaterialFinder#spriteDepth(int)}
- */
- int spriteDepth();
-}
\ No newline at end of file
diff --git a/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/mesh/Mesh.java b/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/mesh/Mesh.java
deleted file mode 100644
index ce536f373..000000000
--- a/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/mesh/Mesh.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package net.modificationstation.stationapi.api.client.render.mesh;
-
-import net.modificationstation.stationapi.api.client.render.Renderer;
-
-import java.util.function.Consumer;
-
-/**
- * A bundle of one or more {@link QuadView} instances encoded by the renderer,
- * typically via {@link Renderer#meshBuilder()}.
- *
- *
Similar in purpose to the {@code List} instances returned by BakedModel, but
- * affords the renderer the ability to optimize the format for performance
- * and memory allocation.
- *
- *
Only the renderer should implement or extend this interface.
- */
-public interface Mesh {
- /**
- * Use to access all of the quads encoded in this mesh. The quad instances
- * sent to the consumer will likely be threadlocal/reused and should never
- * be retained by the consumer.
- */
- void forEach(Consumer consumer);
-}
\ No newline at end of file
diff --git a/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/mesh/MeshBuilder.java b/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/mesh/MeshBuilder.java
deleted file mode 100644
index b7943de07..000000000
--- a/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/mesh/MeshBuilder.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package net.modificationstation.stationapi.api.client.render.mesh;
-
-/**
- * Decouples models from the vertex format(s) used by
- * ModelRenderer to allow compatibility across diverse implementations.
- */
-public interface MeshBuilder {
-
- /**
- * Returns the {@link QuadEmitter} used to append quad to this mesh.
- * Calling this method a second time invalidates any prior result.
- * Do not retain references outside the context of building the mesh.
- */
- QuadEmitter getEmitter();
-
- /**
- * Returns a new {@link Mesh} instance containing all
- * quads added to this builder and resets the builder to an empty state.
- */
- Mesh build();
-}
\ No newline at end of file
diff --git a/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/mesh/MutableQuadView.java b/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/mesh/MutableQuadView.java
deleted file mode 100644
index cede9400c..000000000
--- a/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/mesh/MutableQuadView.java
+++ /dev/null
@@ -1,214 +0,0 @@
-package net.modificationstation.stationapi.api.client.render.mesh;
-
-import net.modificationstation.stationapi.api.client.render.Renderer;
-import net.modificationstation.stationapi.api.client.render.material.RenderMaterial;
-import net.modificationstation.stationapi.api.client.render.model.BakedQuad;
-import net.modificationstation.stationapi.api.client.texture.Sprite;
-import net.modificationstation.stationapi.api.util.math.Direction;
-import net.modificationstation.stationapi.api.util.math.Vec3f;
-import net.modificationstation.stationapi.api.util.math.Vector2f;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * A mutable {@link QuadView} instance. The base interface for
- * {@link QuadEmitter} and for dynamic renders/mesh transforms.
- *
- *
Instances of {@link MutableQuadView} will practically always be
- * threadlocal and/or reused - do not retain references.
- *
- *
Only the renderer should implement or extend this interface.
- */
-public interface MutableQuadView extends QuadView {
- /**
- * Causes texture to appear with no rotation.
- * Pass in bakeFlags parameter to {@link #spriteBake(int, Sprite, int)}.
- */
- int BAKE_ROTATE_NONE = 0;
-
- /**
- * Causes texture to appear rotated 90 deg. clockwise relative to nominal face.
- * Pass in bakeFlags parameter to {@link #spriteBake(int, Sprite, int)}.
- */
- int BAKE_ROTATE_90 = 1;
-
- /**
- * Causes texture to appear rotated 180 deg. relative to nominal face.
- * Pass in bakeFlags parameter to {@link #spriteBake(int, Sprite, int)}.
- */
- int BAKE_ROTATE_180 = 2;
-
- /**
- * Causes texture to appear rotated 270 deg. clockwise relative to nominal face.
- * Pass in bakeFlags parameter to {@link #spriteBake(int, Sprite, int)}.
- */
- int BAKE_ROTATE_270 = 3;
-
- /**
- * When enabled, texture coordinate are assigned based on vertex position.
- * Any existing uv coordinates will be replaced.
- * Pass in bakeFlags parameter to {@link #spriteBake(int, Sprite, int)}.
- *
- *
UV lock always derives texture coordinates based on nominal face, even
- * when the quad is not co-planar with that face, and the result is
- * the same as if the quad were projected onto the nominal face, which
- * is usually the desired result.
- */
- int BAKE_LOCK_UV = 4;
-
- /**
- * When set, U texture coordinates for the given sprite are
- * flipped as part of baking. Can be useful for some randomization
- * and texture mapping scenarios. Results are different than what
- * can be obtained via rotation and both can be applied.
- * Pass in bakeFlags parameter to {@link #spriteBake(int, Sprite, int)}.
- */
- int BAKE_FLIP_U = 8;
-
- /**
- * Same as {@link MutableQuadView#BAKE_FLIP_U} but for V coordinate.
- */
- int BAKE_FLIP_V = 16;
-
- /**
- * UV coordinates by default are assumed to be 0-16 scale for consistency
- * with conventional Minecraft model format. This is scaled to 0-1 during
- * baking before interpolation. Model loaders that already have 0-1 coordinates
- * can avoid wasteful multiplication/division by passing 0-1 coordinates directly.
- * Pass in bakeFlags parameter to {@link #spriteBake(int, Sprite, int)}.
- */
- int BAKE_NORMALIZED = 32;
-
- /**
- * Assigns a different material to this quad. Useful for transformation of
- * existing meshes because lighting and texture blending are controlled by material.
- */
- MutableQuadView material(RenderMaterial material);
-
- /**
- * If non-null, quad is coplanar with a block face which, if known, simplifies
- * or shortcuts geometric analysis that might otherwise be needed.
- * Set to null if quad is not coplanar or if this is not known.
- * Also controls face culling during block rendering.
- *
- *
Null by default.
- *
- *
When called with a non-null value, also sets {@link #nominalFace(Direction)}
- * to the same value.
- *
- *
This is different than the value reported by {@link BakedQuad#getFace()}. That value
- * is computed based on face geometry and must be non-null in vanilla quads.
- * That computed value is returned by {@link #lightFace()}.
- */
- @Nullable
- MutableQuadView cullFace(@Nullable Direction face);
-
- /**
- * Provides a hint to renderer about the facing of this quad. Not required,
- * but if provided can shortcut some geometric analysis if the quad is parallel to a block face.
- * Should be the expected value of {@link #lightFace()}. Value will be confirmed
- * and if invalid the correct light face will be calculated.
- *
- *
Null by default, and set automatically by {@link #cullFace()}.
- *
- *
Models may also find this useful as the face for texture UV locking and rotation semantics.
- *
- *
Note: This value is not persisted independently when the quad is encoded.
- * When reading encoded quads, this value will always be the same as {@link #lightFace()}.
- */
- @Nullable
- MutableQuadView nominalFace(Direction face);
-
- /**
- * Value functions identically to {@link BakedQuad#getColorIndex()} and is
- * used by renderer / model builder in same way. Default value is -1.
- */
- MutableQuadView colorIndex(int colourIndex);
-
- /**
- * Enables bulk vertex data transfer using the standard Minecraft vertex formats.
- * This method should be performant whenever caller's vertex representation makes it feasible.
- *
- *
Calling this method does not emit the quad.
- */
- MutableQuadView fromVanilla(BakedQuad quad, RenderMaterial material, Direction cullFace);
-
- /**
- * Encodes an integer tag with this quad that can later be retrieved via
- * {@link QuadView#tag()}. Useful for models that want to perform conditional
- * transformation or filtering on static meshes.
- */
- MutableQuadView tag(int tag);
-
- /**
- * Sets the geometric vertex position for the given vertex,
- * relative to block origin. (0,0,0). Minecraft rendering is designed
- * for models that fit within a single block space and is recommended
- * that coordinates remain in the 0-1 range, with multi-block meshes
- * split into multiple per-block models.
- */
- MutableQuadView pos(int vertexIndex, float x, float y, float z);
-
- /**
- * Same as {@link #pos(int, float, float, float)} but accepts vector type.
- */
- default MutableQuadView pos(int vertexIndex, Vec3f vec) {
- return pos(vertexIndex, vec.getX(), vec.getY(), vec.getZ());
- }
-
- /**
- * Adds a vertex normal. Models that have per-vertex
- * normals should include them to get correct lighting when it matters.
- * Computed face normal is used when no vertex normal is provided.
- *
- *
{@link Renderer} implementations should honor vertex normals for
- * diffuse lighting - modifying vertex color(s) or packing normals in the vertex
- * buffer as appropriate for the rendering method/vertex format in effect.
- */
- MutableQuadView normal(int vertexIndex, float x, float y, float z);
-
- /**
- * Same as {@link #normal(int, float, float, float)} but accepts vector type.
- */
- default MutableQuadView normal(int vertexIndex, Vec3f vec) {
- return normal(vertexIndex, vec.getX(), vec.getY(), vec.getZ());
- }
-
- /**
- * Set sprite color. Behavior for {@code spriteIndex > 0} is currently undefined.
- */
- MutableQuadView spriteColor(int vertexIndex, int spriteIndex, int color);
-
- /**
- * Convenience: set sprite color for all vertices at once. Behavior for {@code spriteIndex > 0} is currently undefined.
- */
- default MutableQuadView spriteColor(int spriteIndex, int c0, int c1, int c2, int c3) {
- spriteColor(0, spriteIndex, c0);
- spriteColor(1, spriteIndex, c1);
- spriteColor(2, spriteIndex, c2);
- spriteColor(3, spriteIndex, c3);
- return this;
- }
-
- /**
- * Set sprite atlas coordinates. Behavior for {@code spriteIndex > 0} is currently undefined.
- */
- MutableQuadView sprite(int vertexIndex, int spriteIndex, float u, float v);
-
- /**
- * Set sprite atlas coordinates. Behavior for {@code spriteIndex > 0} is currently undefined.
- *
- *
Only use this function if you already have a {@link Vector2f}.
- * Otherwise, see {@link MutableQuadView#sprite(int, int, float, float)}.
- */
- default MutableQuadView sprite(int vertexIndex, int spriteIndex, Vector2f uv) {
- return sprite(vertexIndex, spriteIndex, uv.x, uv.y);
- }
-
- /**
- * Assigns sprite atlas u,v coordinates to this quad for the given sprite.
- * Can handle UV locking, rotation, interpolation, etc. Control this behavior
- * by passing additive combinations of the BAKE_ flags defined in this interface.
- * Behavior for {@code spriteIndex > 0} is currently undefined.
- */
- MutableQuadView spriteBake(int spriteIndex, Sprite sprite, int bakeFlags);
-}
\ No newline at end of file
diff --git a/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/mesh/QuadEmitter.java b/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/mesh/QuadEmitter.java
deleted file mode 100644
index e00a46190..000000000
--- a/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/mesh/QuadEmitter.java
+++ /dev/null
@@ -1,158 +0,0 @@
-package net.modificationstation.stationapi.api.client.render.mesh;
-
-import net.modificationstation.stationapi.api.client.render.RenderContext;
-import net.modificationstation.stationapi.api.client.render.material.RenderMaterial;
-import net.modificationstation.stationapi.api.client.texture.Sprite;
-import net.modificationstation.stationapi.api.util.math.Direction;
-import net.modificationstation.stationapi.api.util.math.Vec3f;
-import net.modificationstation.stationapi.api.util.math.Vector2f;
-
-/**
- * Specialized {@link MutableQuadView} obtained via {@link MeshBuilder#getEmitter()}
- * to append quads during mesh building.
- *
- *
Also obtained from {@link RenderContext#getEmitter()} to submit
- * dynamic quads one-by-one at render time.
- *
- *
Instances of {@link QuadEmitter} will practically always be
- * threadlocal and/or reused - do not retain references.
- *
- *
Only the renderer should implement or extend this interface.
- */
-public interface QuadEmitter extends MutableQuadView {
- @Override
- QuadEmitter material(RenderMaterial material);
-
- @Override
- QuadEmitter cullFace(Direction face);
-
- @Override
- QuadEmitter nominalFace(Direction face);
-
- @Override
- QuadEmitter colorIndex(int colourIndex);
-
- @Override
- QuadEmitter tag(int tag);
-
- @Override
- QuadEmitter pos(int vertexIndex, float x, float y, float z);
-
- @Override
- default QuadEmitter pos(int vertexIndex, Vec3f vec) {
- MutableQuadView.super.pos(vertexIndex, vec);
- return this;
- }
-
- @Override
- default QuadEmitter normal(int vertexIndex, Vec3f vec) {
- MutableQuadView.super.normal(vertexIndex, vec);
- return this;
- }
-
- @Override
- QuadEmitter spriteColor(int vertexIndex, int spriteIndex, int color);
-
- @Override
- default QuadEmitter spriteColor(int spriteIndex, int c0, int c1, int c2, int c3) {
- MutableQuadView.super.spriteColor(spriteIndex, c0, c1, c2, c3);
- return this;
- }
-
- @Override
- QuadEmitter sprite(int vertexIndex, int spriteIndex, float u, float v);
-
- /**
- * Set sprite atlas coordinates. Behavior for {@code spriteIndex > 0} is currently undefined.
- *
- *
Only use this function if you already have a {@link Vector2f}.
- * Otherwise, see {@link QuadEmitter#sprite(int, int, float, float)}.
- */
- default QuadEmitter sprite(int vertexIndex, int spriteIndex, Vector2f uv) {
- return sprite(vertexIndex, spriteIndex, uv.x, uv.y);
- }
-
- default QuadEmitter spriteUnitSquare(int spriteIndex) {
- sprite(0, spriteIndex, 0, 0);
- sprite(1, spriteIndex, 0, 1);
- sprite(2, spriteIndex, 1, 1);
- sprite(3, spriteIndex, 1, 0);
- return this;
- }
-
- @Override
- QuadEmitter spriteBake(int spriteIndex, Sprite sprite, int bakeFlags);
-
- /**
- * Tolerance for determining if the depth parameter to {@link #square(Direction, float, float, float, float, float)}
- * is effectively zero - meaning the face is a cull face.
- */
- float CULL_FACE_EPSILON = 0.00001f;
-
- /**
- * Helper method to assign vertex coordinates for a square aligned with the given face.
- * Ensures that vertex order is consistent with vanilla convention. (Incorrect order can
- * lead to bad AO lighting unless enhanced lighting logic is available/enabled.)
- *
- *
Square will be parallel to the given face and coplanar with the face (and culled if the
- * face is occluded) if the depth parameter is approximately zero. See {@link #CULL_FACE_EPSILON}.
- *
- *
All coordinates should be normalized (0-1).
- */
- default QuadEmitter square(Direction nominalFace, float left, float bottom, float right, float top, float depth) {
- if (Math.abs(depth) < CULL_FACE_EPSILON) {
- cullFace(nominalFace);
- depth = 0; // avoid any inconsistency for face quads
- } else {
- cullFace(null);
- }
-
- nominalFace(nominalFace);
- switch (nominalFace) {
- case UP:
- depth = 1 - depth;
- top = 1 - top;
- bottom = 1 - bottom;
-
- case DOWN:
- pos(0, left, depth, top);
- pos(1, left, depth, bottom);
- pos(2, right, depth, bottom);
- pos(3, right, depth, top);
- break;
-
- case WEST:
- depth = 1 - depth;
- left = 1 - left;
- right = 1 - right;
-
- case EAST:
- pos(0, 1 - left, top, depth);
- pos(1, 1 - left, bottom, depth);
- pos(2, 1 - right, bottom, depth);
- pos(3, 1 - right, top, depth);
- break;
-
- case SOUTH:
- depth = 1 - depth;
- left = 1 - left;
- right = 1 - right;
-
- case NORTH:
- pos(0, depth, top, left);
- pos(1, depth, bottom, left);
- pos(2, depth, bottom, right);
- pos(3, depth, top, right);
- break;
- }
-
- return this;
- }
-
- /**
- * In static mesh building, causes quad to be appended to the mesh being built.
- * In a dynamic render context, create a new quad to be output to rendering.
- * In both cases, current instance is reset to default values.
- */
- QuadEmitter emit();
-}
\ No newline at end of file
diff --git a/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/mesh/QuadView.java b/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/mesh/QuadView.java
deleted file mode 100644
index 7cb7c8126..000000000
--- a/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/mesh/QuadView.java
+++ /dev/null
@@ -1,187 +0,0 @@
-package net.modificationstation.stationapi.api.client.render.mesh;
-
-import net.modificationstation.stationapi.api.client.render.material.RenderMaterial;
-import net.modificationstation.stationapi.api.client.render.model.BakedQuad;
-import net.modificationstation.stationapi.api.client.texture.Sprite;
-import net.modificationstation.stationapi.api.util.math.Direction;
-import net.modificationstation.stationapi.api.util.math.Vec3f;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Interface for reading quad data encoded by {@link MeshBuilder}.
- * Enables models to do analysis, re-texturing or translation without knowing the
- * renderer's vertex formats and without retaining redundant information.
- *
- *
Only the renderer should implement or extend this interface.
- */
-public interface QuadView {
- /** Count of integers in a conventional (un-modded) block or item vertex. */
- int VANILLA_VERTEX_STRIDE = 8;
-
- /** Count of integers in a conventional (un-modded) block or item quad. */
- int VANILLA_QUAD_STRIDE = VANILLA_VERTEX_STRIDE * 4;
-
- /**
- * Reads baked vertex data and outputs standard baked quad
- * vertex data in the given array and location.
- *
- * @param spriteIndex The sprite to be used for the quad.
- * Behavior for values > 0 is currently undefined.
- *
- * @param target Target array for the baked quad data.
- *
- * @param targetIndex Starting position in target array - array must have
- * at least 28 elements available at this index.
- *
- * @param isItem If true, will output vertex normals. Otherwise will output
- * lightmaps, per Minecraft vertex formats for baked models.
- */
- void toVanilla(int spriteIndex, int[] target, int targetIndex, boolean isItem);
-
- /**
- * Extracts all quad properties except material to the given {@link MutableQuadView} instance.
- * Must be used before calling {link QuadEmitter#emit()} on the target instance.
- * Meant for re-texturing, analysis and static transformation use cases.
- */
- void copyTo(MutableQuadView target);
-
- /**
- * Retrieves the material serialized with the quad.
- */
- RenderMaterial material();
-
- /**
- * Retrieves the quad color index serialized with the quad.
- */
- int colorIndex();
-
- /**
- * Equivalent to {@link BakedQuad#getFace()}. This is the face used for vanilla lighting
- * calculations and will be the block face to which the quad is most closely aligned. Always
- * the same as cull face for quads that are on a block face, but never null.
- */
- @NotNull
- Direction lightFace();
-
- /**
- * If non-null, quad should not be rendered in-world if the
- * opposite face of a neighbor block occludes it.
- *
- * @see MutableQuadView#cullFace(Direction)
- */
- @Nullable Direction cullFace();
-
- /**
- * See {@link MutableQuadView#nominalFace(Direction)}.
- */
- Direction nominalFace();
-
- /**
- * Normal of the quad as implied by geometry. Will be invalid
- * if quad vertices are not co-planar. Typically computed lazily
- * on demand and not encoded.
- *
- *
Not typically needed by models. Exposed to enable standard lighting
- * utility functions for use by renderers.
- */
- Vec3f faceNormal();
-
- /**
- * Generates a new BakedQuad instance with texture
- * coordinates and colors from the given sprite.
- *
- * @param spriteIndex The sprite to be used for the quad.
- * Behavior for {@code spriteIndex > 0} is currently undefined.
- *
- * @param sprite {@link MutableQuadView} does not serialize sprites
- * so the sprite must be provided by the caller.
- *
- * @param isItem If true, will output vertex normals. Otherwise will output
- * lightmaps, per Minecraft vertex formats for baked models.
- *
- * @return A new baked quad instance with the closest-available appearance
- * supported by vanilla features. Will retain emissive light maps, for example,
- * but the standard Minecraft renderer will not use them.
- */
- default BakedQuad toBakedQuad(int spriteIndex, Sprite sprite, boolean isItem) {
- int[] vertexData = new int[VANILLA_QUAD_STRIDE];
- toVanilla(spriteIndex, vertexData, 0, isItem);
- return new BakedQuad(vertexData, colorIndex(), lightFace(), sprite, true);
- }
-
- /**
- * Retrieves the integer tag encoded with this quad via {@link MutableQuadView#tag(int)}.
- * Will return zero if no tag was set. For use by models.
- */
- int tag();
-
- /**
- * Pass a non-null target to avoid allocation - will be returned with values.
- * Otherwise returns a new instance.
- */
- Vec3f copyPos(int vertexIndex, @Nullable Vec3f target);
-
- /**
- * Convenience: access x, y, z by index 0-2.
- */
- float posByIndex(int vertexIndex, int coordinateIndex);
-
- /**
- * Geometric position, x coordinate.
- */
- float x(int vertexIndex);
-
- /**
- * Geometric position, y coordinate.
- */
- float y(int vertexIndex);
-
- /**
- * Geometric position, z coordinate.
- */
- float z(int vertexIndex);
-
- /**
- * If false, no vertex normal was provided.
- * Lighting should use face normal in that case.
- */
- boolean hasNormal(int vertexIndex);
-
- /**
- * Pass a non-null target to avoid allocation - will be returned with values.
- * Otherwise returns a new instance. Returns null if normal not present.
- */
- @Nullable
- Vec3f copyNormal(int vertexIndex, @Nullable Vec3f target);
-
- /**
- * Will return {@link Float#NaN} if normal not present.
- */
- float normalX(int vertexIndex);
-
- /**
- * Will return {@link Float#NaN} if normal not present.
- */
- float normalY(int vertexIndex);
-
- /**
- * Will return {@link Float#NaN} if normal not present.
- */
- float normalZ(int vertexIndex);
-
- /**
- * Retrieve vertex color.
- */
- int spriteColor(int vertexIndex, int spriteIndex);
-
- /**
- * Retrieve horizontal sprite atlas coordinates.
- */
- float spriteU(int vertexIndex, int spriteIndex);
-
- /**
- * Retrieve vertical sprite atlas coordinates.
- */
- float spriteV(int vertexIndex, int spriteIndex);
-}
\ No newline at end of file
diff --git a/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/model/BakedModel.java b/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/model/BakedModel.java
index da510c4b1..175a1647c 100644
--- a/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/model/BakedModel.java
+++ b/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/model/BakedModel.java
@@ -1,20 +1,14 @@
package net.modificationstation.stationapi.api.client.render.model;
import com.google.common.collect.ImmutableList;
-import net.minecraft.item.ItemStack;
-import net.minecraft.util.math.BlockPos;
-import net.minecraft.world.BlockView;
import net.modificationstation.stationapi.api.block.BlockState;
-import net.modificationstation.stationapi.api.client.render.RenderContext;
import net.modificationstation.stationapi.api.client.render.model.json.ModelOverrideList;
import net.modificationstation.stationapi.api.client.render.model.json.ModelTransformation;
import net.modificationstation.stationapi.api.client.texture.Sprite;
import net.modificationstation.stationapi.api.util.math.Direction;
-import net.modificationstation.stationapi.api.util.math.MatrixStack;
import org.jetbrains.annotations.Nullable;
import java.util.Random;
-import java.util.function.Supplier;
public interface BakedModel {
@@ -41,94 +35,4 @@ public interface BakedModel {
ModelTransformation getTransformation();
ModelOverrideList getOverrides();
-
- /**
- * When true, signals renderer this producer is implemented through {@link BakedModel#getQuads(BlockState, Direction, Random)}.
- * Also means the model does not rely on any non-vanilla features.
- * Allows the renderer to optimize or route vanilla models through the unmodified vanilla pipeline if desired.
- *
- *
Fabric overrides to true for vanilla baked models.
- * Enhanced models that use this API should return false,
- * otherwise the API will not recognize the model.
- */
- default boolean isVanillaAdapter() {
- return true;
- }
-
- /**
- * This method will be called during chunk rebuilds to generate both the static and
- * dynamic portions of a block model when the model implements this interface and
- * {@link #isVanillaAdapter()} returns false.
- *
- *
During chunk rebuild, this method will always be called exactly one time per block
- * position, irrespective of which or how many faces or block render layers are included
- * in the model. Models must output all quads/meshes in a single pass.
- *
- *
Also called to render block models outside of chunk rebuild or block entity rendering.
- * Typically this happens when the block is being rendered as an entity, not as a block placed in the world.
- * Currently this happens for falling blocks and blocks being pushed by a piston, but renderers
- * should invoke this for all calls to {@link BlockModelRenderer#render(BlockView, BakedModel, BlockState, TilePos, MatrixStack, VertexConsumer, boolean, Random, long, int)}
- * that occur outside of chunk rebuilds to allow for features added by mods, unless
- * {@link #isVanillaAdapter()} returns true.
- *
- *
Outside of chunk rebuilds, this method will be called every frame. Model implementations should
- * rely on pre-baked meshes as much as possible and keep transformation to a minimum. The provided
- * block position may be the nearest block position and not actual. For this reason, neighbor
- * state lookups are best avoided or will require special handling. Block entity lookups are
- * likely to fail and/or give meaningless results.
- *
- *
In all cases, renderer will handle face occlusion and filter quads on faces obscured by
- * neighboring blocks (if appropriate). Models only need to consider "sides" to the
- * extent the model is driven by connection with neighbor blocks or other world state.
- *
- *
Note: with {@link BakedModel#getQuads(BlockState, Direction, Random)}, the random
- * parameter is normally initialized with the same seed prior to each face layer.
- * Model authors should note this method is called only once per block, and call the provided
- * Random supplier multiple times if re-seeding is necessary. For wrapped vanilla baked models,
- * it will probably be easier to use {@link RenderContext#fallbackConsumer} which handles
- * re-seeding per face automatically.
- *
- * @param blockView Access to world state. Using {@link net.fabricmc.fabric.api.rendering.data.v1.RenderAttachedBlockView#getBlockEntityRenderAttachment(BlockPos)} to
- * retrieve block entity state unless thread safety can be guaranteed.
- * param safeBlockEntityAccessor Thread-safe access to block entity data
- * @param state Block state for model being rendered.
- * @param pos Position of block for model being rendered.
- * @param randomSupplier Random object seeded per vanilla conventions. Call multiple times to re-seed.
- * Will not be thread-safe. Do not cache or retain a reference.
- * @param context Accepts model output.
- */
- default void emitBlockQuads(BlockView blockView, BlockState state, BlockPos pos, Supplier randomSupplier, RenderContext context) {
- context.fallbackConsumer().accept(this);
- }
-
- /**
- * This method will be called during item rendering to generate both the static and
- * dynamic portions of an item model when the model implements this interface and
- * {@link #isVanillaAdapter()} returns false.
- *
- *
Vanilla item rendering is normally very limited. It ignores lightmaps, vertex colors,
- * and vertex normals. Renderers are expected to implement enhanced features for item
- * models. If a feature is impractical due to performance or other concerns, then the
- * renderer must at least give acceptable visual results without the need for special-
- * case handling in model implementations.
- *
- *
Calls to this method will generally happen on the main client thread but nothing
- * prevents a mod or renderer from calling this method concurrently. Implementations
- * should not mutate the ItemStack parameter, and best practice will be to make the
- * method thread-safe.
- *
- *
Implementing this method does NOT mitigate the need to implement a functional
- * {@link BakedModel#getOverrides()} method, because this method will be called
- * on the result of {@link BakedModel#getOverrides}. However, that
- * method can simply return the base model because the output from this method will
- * be used for rendering.
- *
- *
Renderer implementations should also use this method to obtain the quads used
- * for item enchantment glint rendering. This means models can put geometric variation
- * logic here, instead of returning every possible shape from {@link BakedModel#getOverrides}
- * as vanilla baked models.
- */
- default void emitItemQuads(ItemStack stack, Supplier randomSupplier, RenderContext context) {
- context.fallbackConsumer().accept(this);
- }
}
diff --git a/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/model/ForwardingBakedModel.java b/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/model/ForwardingBakedModel.java
index 164e74a79..8c90d6fcd 100644
--- a/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/model/ForwardingBakedModel.java
+++ b/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/model/ForwardingBakedModel.java
@@ -1,18 +1,13 @@
package net.modificationstation.stationapi.api.client.render.model;
import com.google.common.collect.ImmutableList;
-import net.minecraft.item.ItemStack;
-import net.minecraft.util.math.BlockPos;
-import net.minecraft.world.BlockView;
import net.modificationstation.stationapi.api.block.BlockState;
-import net.modificationstation.stationapi.api.client.render.RenderContext;
import net.modificationstation.stationapi.api.client.render.model.json.ModelOverrideList;
import net.modificationstation.stationapi.api.client.render.model.json.ModelTransformation;
import net.modificationstation.stationapi.api.client.texture.Sprite;
import net.modificationstation.stationapi.api.util.math.Direction;
import java.util.Random;
-import java.util.function.Supplier;
/**
* Base class for specialized model implementations that need to wrap other baked models.
@@ -23,18 +18,6 @@ public abstract class ForwardingBakedModel implements BakedModel {
/** implementations must set this somehow. */
protected BakedModel wrapped;
- public void emitBlockQuads(BlockView blockView, BlockState state, BlockPos pos, Supplier randomSupplier, RenderContext context) {
- wrapped.emitBlockQuads(blockView, state, pos, randomSupplier, context);
- }
-
- public boolean isVanillaAdapter() {
- return wrapped.isVanillaAdapter();
- }
-
- public void emitItemQuads(ItemStack stack, Supplier randomSupplier, RenderContext context) {
- wrapped.emitItemQuads(stack, randomSupplier, context);
- }
-
@Override
public ImmutableList getQuads(BlockState blockState, Direction face, Random rand) {
return wrapped.getQuads(blockState, face, rand);
diff --git a/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/model/ModelHelper.java b/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/model/ModelHelper.java
deleted file mode 100644
index 9021a87ed..000000000
--- a/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/model/ModelHelper.java
+++ /dev/null
@@ -1,113 +0,0 @@
-package net.modificationstation.stationapi.api.client.render.model;
-
-import com.google.common.collect.ImmutableList;
-import net.modificationstation.stationapi.api.client.StationRenderAPI;
-import net.modificationstation.stationapi.api.client.render.mesh.Mesh;
-import net.modificationstation.stationapi.api.client.render.model.json.ModelTransformation;
-import net.modificationstation.stationapi.api.client.render.model.json.Transformation;
-import net.modificationstation.stationapi.api.client.texture.atlas.Atlases;
-import net.modificationstation.stationapi.api.util.math.Direction;
-import net.modificationstation.stationapi.api.util.math.Vec3f;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Collection of utilities for model implementations.
- */
-public abstract class ModelHelper {
- private ModelHelper() { }
-
- /** Result from {@link #toFaceIndex(Direction)} for null values. */
- public static final int NULL_FACE_ID = 6;
-
- /**
- * Convenient way to encode faces that may be null.
- * Null is returned as {@link #NULL_FACE_ID}.
- * Use {@link #faceFromIndex(int)} to retrieve encoded face.
- */
- public static int toFaceIndex(Direction face) {
- return face == null ? NULL_FACE_ID : face.getId();
- }
-
- /**
- * Use to decode a result from {@link #toFaceIndex(Direction)}.
- * Return value will be null if encoded value was null.
- * Can also be used for no-allocation iteration of {@link Direction#values()},
- * optionally including the null face. (Use < or <= {@link #NULL_FACE_ID}
- * to exclude or include the null value, respectively.)
- */
- @Nullable
- public static Direction faceFromIndex(int faceIndex) {
- return FACES[faceIndex];
- }
-
- /** @see #faceFromIndex(int) */
- private static final Direction[] FACES = Arrays.copyOf(Direction.values(), 7);
-
- /**
- * Converts a mesh into an array of lists of vanilla baked quads.
- * Useful for creating vanilla baked models when required for compatibility.
- * The array indexes correspond to {@link Direction#getId()} with the
- * addition of {@link #NULL_FACE_ID}.
- *
- *
Retrieves sprites from the block texture atlas via {@link SpriteFinder}.
- */
- public static List[] toQuadLists(Mesh mesh) {
- SpriteFinder finder = SpriteFinder.get(StationRenderAPI.getBakedModelManager().getAtlas(Atlases.GAME_ATLAS_TEXTURE));
-
- @SuppressWarnings("unchecked")
- final ImmutableList.Builder[] builders = new ImmutableList.Builder[7];
-
- for (int i = 0; i < 7; i++) {
- builders[i] = ImmutableList.builder();
- }
-
- if (mesh != null) {
- mesh.forEach(q -> {
- final int limit = q.material().spriteDepth();
-
- for (int l = 0; l < limit; l++) {
- Direction face = q.cullFace();
- builders[face == null ? 6 : face.getId()].add(q.toBakedQuad(l, finder.find(q, l), false));
- }
- });
- }
-
- @SuppressWarnings("unchecked")
- List[] result = new List[7];
-
- for (int i = 0; i < 7; i++) {
- result[i] = builders[i].build();
- }
-
- return result;
- }
-
- /**
- * The vanilla model transformation logic is closely coupled with model deserialization.
- * That does little good for modded model loaders and procedurally generated models.
- * This convenient construction method applies the same scaling factors used for vanilla models.
- * This means you can use values from a vanilla JSON file as inputs to this method.
- */
- private static Transformation makeTransform(float rotationX, float rotationY, @SuppressWarnings("SameParameterValue") float rotationZ, @SuppressWarnings("SameParameterValue") float translationX, float translationY, @SuppressWarnings("SameParameterValue") float translationZ, float scaleX, float scaleY, float scaleZ) {
- Vec3f translation = new Vec3f(translationX, translationY, translationZ);
- translation.scale(0.0625f);
- translation.clamp(-5.0F, 5.0F);
- return new Transformation(new Vec3f(rotationX, rotationY, rotationZ), translation, new Vec3f(scaleX, scaleY, scaleZ));
- }
-
- public static final Transformation TRANSFORM_BLOCK_GUI = makeTransform(30, 225, 0, 0, 0, 0, 0.625f, 0.625f, 0.625f);
- public static final Transformation TRANSFORM_BLOCK_GROUND = makeTransform(0, 0, 0, 0, 3, 0, 0.25f, 0.25f, 0.25f);
- public static final Transformation TRANSFORM_BLOCK_FIXED = makeTransform(0, 0, 0, 0, 0, 0, 0.5f, 0.5f, 0.5f);
- public static final Transformation TRANSFORM_BLOCK_3RD_PERSON_RIGHT = makeTransform(75, 45, 0, 0, 2.5f, 0, 0.375f, 0.375f, 0.375f);
- public static final Transformation TRANSFORM_BLOCK_1ST_PERSON_RIGHT = makeTransform(0, 45, 0, 0, 0, 0, 0.4f, 0.4f, 0.4f);
- public static final Transformation TRANSFORM_BLOCK_1ST_PERSON_LEFT = makeTransform(0, 225, 0, 0, 0, 0, 0.4f, 0.4f, 0.4f);
-
- /**
- * Mimics the vanilla model transformation used for most vanilla blocks,
- * and should be suitable for most custom block-like models.
- */
- public static final ModelTransformation MODEL_TRANSFORM_BLOCK = new ModelTransformation(TRANSFORM_BLOCK_3RD_PERSON_RIGHT, TRANSFORM_BLOCK_3RD_PERSON_RIGHT, TRANSFORM_BLOCK_1ST_PERSON_LEFT, TRANSFORM_BLOCK_1ST_PERSON_RIGHT, Transformation.IDENTITY, TRANSFORM_BLOCK_GUI, TRANSFORM_BLOCK_GROUND, TRANSFORM_BLOCK_FIXED);
-}
\ No newline at end of file
diff --git a/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/model/MultipartBakedModel.java b/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/model/MultipartBakedModel.java
index c973f0337..60cbbb154 100644
--- a/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/model/MultipartBakedModel.java
+++ b/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/model/MultipartBakedModel.java
@@ -5,11 +5,7 @@
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
-import net.minecraft.item.ItemStack;
-import net.minecraft.util.math.BlockPos;
-import net.minecraft.world.BlockView;
import net.modificationstation.stationapi.api.block.BlockState;
-import net.modificationstation.stationapi.api.client.render.RenderContext;
import net.modificationstation.stationapi.api.client.render.model.json.ModelOverrideList;
import net.modificationstation.stationapi.api.client.render.model.json.ModelTransformation;
import net.modificationstation.stationapi.api.client.texture.Sprite;
@@ -23,7 +19,6 @@
import java.util.Map;
import java.util.Random;
import java.util.function.Predicate;
-import java.util.function.Supplier;
@Environment(EnvType.CLIENT)
public class MultipartBakedModel implements BakedModel {
@@ -35,7 +30,6 @@ public class MultipartBakedModel implements BakedModel {
protected final ModelTransformation transformations;
protected final ModelOverrideList itemPropertyOverrides;
private final Map stateCache = new Object2ObjectOpenCustomHashMap<>(Util.identityHashStrategy());
- private final boolean isVanilla;
public MultipartBakedModel(List, BakedModel>> components) {
this.components = components;
@@ -46,46 +40,6 @@ public MultipartBakedModel(List, BakedModel>> compone
this.sprite = bakedModel.getSprite();
this.transformations = bakedModel.getTransformation();
this.itemPropertyOverrides = bakedModel.getOverrides();
- boolean isVanilla = true;
- for (Pair, BakedModel> component : components)
- if (!component.getRight().isVanillaAdapter()) {
- isVanilla = false;
- break;
- }
- this.isVanilla = isVanilla;
- }
-
- @Override
- public boolean isVanillaAdapter() {
- return isVanilla;
- }
-
- @Override
- public void emitBlockQuads(BlockView blockView, BlockState state, BlockPos pos, Supplier randomSupplier, RenderContext context) {
- BitSet bitSet = this.stateCache.get(state);
-
- if (bitSet == null) {
- bitSet = new BitSet();
-
- for (int i = 0; i < this.components.size(); i++) {
- Pair, BakedModel> pair = components.get(i);
-
- if (pair.getLeft().test(state)) {
- pair.getRight().emitBlockQuads(blockView, state, pos, randomSupplier, context);
- bitSet.set(i);
- }
- }
-
- stateCache.put(state, bitSet);
- } else
- for (int i = 0; i < this.components.size(); i++)
- if (bitSet.get(i))
- components.get(i).getRight().emitBlockQuads(blockView, state, pos, randomSupplier, context);
- }
-
- @Override
- public void emitItemQuads(ItemStack stack, Supplier randomSupplier, RenderContext context) {
- // Vanilla doesn't use MultipartBakedModel for items.
}
@Override
diff --git a/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/model/SpriteFinder.java b/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/model/SpriteFinder.java
deleted file mode 100644
index dd0b9d678..000000000
--- a/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/model/SpriteFinder.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package net.modificationstation.stationapi.api.client.render.model;
-
-import net.modificationstation.stationapi.api.client.render.mesh.Mesh;
-import net.modificationstation.stationapi.api.client.render.mesh.MutableQuadView;
-import net.modificationstation.stationapi.api.client.render.mesh.QuadView;
-import net.modificationstation.stationapi.api.client.texture.Sprite;
-import net.modificationstation.stationapi.api.client.texture.SpriteAtlasTexture;
-import net.modificationstation.stationapi.impl.client.render.SpriteFinderImpl;
-
-/**
- * Indexes a texture atlas to allow fast lookup of Sprites from
- * baked vertex coordinates. Main use is for {@link Mesh}-based models
- * to generate vanilla quads on demand without tracking and retaining
- * the sprites that were baked into the mesh. In other words, this class
- * supplies the sprite parameter for {@link QuadView#toBakedQuad(int, Sprite, boolean)}.
- */
-public interface SpriteFinder {
- /**
- * Retrieves or creates the finder for the given atlas.
- * Instances should not be retained as fields or they must be
- * refreshed whenever there is a resource reload or other event
- * that causes atlas textures to be re-stitched.
- */
- static SpriteFinder get(SpriteAtlasTexture atlas) {
- return SpriteFinderImpl.get(atlas);
- }
-
- /**
- * Finds the atlas sprite containing the vertex centroid of the quad.
- * Vertex centroid is essentially the mean u,v coordinate - the intent being
- * to find a point that is unambiguously inside the sprite (vs on an edge.)
- *
- *
Should be reliable for any convex quad or triangle. May fail for non-convex quads.
- * Note that all the above refers to u,v coordinates. Geometric vertex does not matter,
- * except to the extent it was used to determine u,v.
- */
- Sprite find(QuadView quad, int textureIndex);
-
- /**
- * Alternative to {@link #find(QuadView, int)} when vertex centroid is already
- * known or unsuitable. Expects normalized (0-1) coordinates on the atlas texture,
- * which should already be the case for u,v values in vanilla baked quads and in
- * {@link QuadView} after calling {@link MutableQuadView#spriteBake(int, Sprite, int)}.
- *
- *
Coordinates must be in the sprite interior for reliable results. Generally will
- * be easier to use {@link #find(QuadView, int)} unless you know the vertex
- * centroid will somehow not be in the quad interior. This method will be slightly
- * faster if you already have the centroid or another appropriate value.
- */
- Sprite find(float u, float v);
-}
\ No newline at end of file
diff --git a/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/model/WeightedBakedModel.java b/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/model/WeightedBakedModel.java
index a876640f9..a9059606f 100644
--- a/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/model/WeightedBakedModel.java
+++ b/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/render/model/WeightedBakedModel.java
@@ -4,11 +4,7 @@
import com.google.common.collect.Lists;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
-import net.minecraft.item.ItemStack;
-import net.minecraft.util.math.BlockPos;
-import net.minecraft.world.BlockView;
import net.modificationstation.stationapi.api.block.BlockState;
-import net.modificationstation.stationapi.api.client.render.RenderContext;
import net.modificationstation.stationapi.api.client.render.model.json.ModelOverrideList;
import net.modificationstation.stationapi.api.client.render.model.json.ModelTransformation;
import net.modificationstation.stationapi.api.client.texture.Sprite;
@@ -19,45 +15,17 @@
import java.util.List;
import java.util.Objects;
import java.util.Random;
-import java.util.function.Supplier;
@Environment(EnvType.CLIENT)
public class WeightedBakedModel implements BakedModel {
private final int totalWeight;
private final List models;
private final BakedModel defaultModel;
- private final boolean isVanilla;
public WeightedBakedModel(List models) {
this.models = models;
this.totalWeight = WeightedPicker.getWeightSum(models);
this.defaultModel = models.get(0).model;
- boolean isVanilla = true;
- for (Entry model : models)
- if (!model.model.isVanillaAdapter()) {
- isVanilla = false;
- break;
- }
- this.isVanilla = isVanilla;
- }
-
- @Override
- public boolean isVanillaAdapter() {
- return isVanilla;
- }
-
- @Override
- public void emitBlockQuads(BlockView blockView, BlockState state, BlockPos pos, Supplier randomSupplier, RenderContext context) {
- Entry entry = WeightedPicker.getAt(this.models, Math.abs((int) randomSupplier.get().nextLong()) % this.totalWeight);
- if (entry != null)
- entry.model.emitBlockQuads(blockView, state, pos, randomSupplier, context);
- }
-
- @Override
- public void emitItemQuads(ItemStack stack, Supplier randomSupplier, RenderContext context) {
- Entry entry = WeightedPicker.getAt(this.models, Math.abs((int) randomSupplier.get().nextLong()) % this.totalWeight);
- if (entry != null)
- entry.model.emitItemQuads(stack, randomSupplier, context);
}
@Override
diff --git a/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/texture/SpriteAtlasTexture.java b/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/texture/SpriteAtlasTexture.java
index 0b9db1805..24794cabb 100644
--- a/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/texture/SpriteAtlasTexture.java
+++ b/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/api/client/texture/SpriteAtlasTexture.java
@@ -1,12 +1,11 @@
package net.modificationstation.stationapi.api.client.texture;
import lombok.Getter;
-import net.modificationstation.stationapi.api.util.Identifier;
import net.modificationstation.stationapi.api.resource.ResourceManager;
+import net.modificationstation.stationapi.api.util.Identifier;
import net.modificationstation.stationapi.api.util.crash.CrashException;
import net.modificationstation.stationapi.api.util.crash.CrashReport;
import net.modificationstation.stationapi.api.util.crash.CrashReportSection;
-import net.modificationstation.stationapi.impl.client.render.SpriteFinderImpl;
import java.io.BufferedWriter;
import java.io.IOException;
@@ -29,7 +28,6 @@ public class SpriteAtlasTexture extends AbstractTexture implements DynamicTextur
private int width;
@Getter
private int height;
- private SpriteFinderImpl spriteFinder = null;
public SpriteAtlasTexture(Identifier id) {
this.id = id;
@@ -65,7 +63,6 @@ public void upload(SpriteLoader.StitchResult stitchResult) {
}
this.spritesToLoad = List.copyOf(list);
this.animatedSprites = List.copyOf(list2);
- spriteFinder = null;
}
@Override
@@ -118,14 +115,5 @@ public int getMaxTextureSize() {
public void applyTextureFilter(SpriteLoader.StitchResult data) {
this.setFilter(false, false);
}
-
- public SpriteFinderImpl spriteFinder() {
- SpriteFinderImpl result = spriteFinder;
- if (result == null) {
- result = new SpriteFinderImpl(sprites, this);
- spriteFinder = result;
- }
- return result;
- }
}
diff --git a/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/impl/client/render/SpriteFinderImpl.java b/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/impl/client/render/SpriteFinderImpl.java
deleted file mode 100644
index 0b7d1835e..000000000
--- a/station-renderer-api-v0/src/main/java/net/modificationstation/stationapi/impl/client/render/SpriteFinderImpl.java
+++ /dev/null
@@ -1,130 +0,0 @@
-package net.modificationstation.stationapi.impl.client.render;
-
-import net.modificationstation.stationapi.api.client.render.mesh.QuadView;
-import net.modificationstation.stationapi.api.client.render.model.SpriteFinder;
-import net.modificationstation.stationapi.api.client.texture.MissingSprite;
-import net.modificationstation.stationapi.api.client.texture.Sprite;
-import net.modificationstation.stationapi.api.client.texture.SpriteAtlasTexture;
-import net.modificationstation.stationapi.api.util.Identifier;
-
-import java.util.Map;
-import java.util.function.Consumer;
-
-/**
- * Indexes an atlas sprite to allow fast lookup of Sprites from
- * baked vertex coordinates. Implementation is a straightforward
- * quad tree. Other options that were considered were linear search
- * (slow) and direct indexing of fixed-size cells. Direct indexing
- * would be fastest but would be memory-intensive for large atlases
- * and unsuitable for any atlas that isn't consistently aligned to
- * a fixed cell size.
- */
-public class SpriteFinderImpl implements SpriteFinder {
-
- private final Node root;
- private final SpriteAtlasTexture spriteAtlasTexture;
-
- public SpriteFinderImpl(Map sprites, SpriteAtlasTexture spriteAtlasTexture) {
- root = new Node(0.5f, 0.5f, 0.25f);
- this.spriteAtlasTexture = spriteAtlasTexture;
- sprites.values().forEach(root::add);
- }
-
- @Override
- public Sprite find(QuadView quad, int textureIndex) {
- float u = 0;
- float v = 0;
-
- for (int i = 0; i < 4; i++) {
- u += quad.spriteU(i, textureIndex);
- v += quad.spriteV(i, textureIndex);
- }
-
- return find(u * 0.25f, v * 0.25f);
- }
-
- @Override
- public Sprite find(float u, float v) {
- return root.find(u, v);
- }
-
- private class Node {
- final float midU;
- final float midV;
- final float cellRadius;
- Object lowLow = null;
- Object lowHigh = null;
- Object highLow = null;
- Object highHigh = null;
-
- Node(float midU, float midV, float radius) {
- this.midU = midU;
- this.midV = midV;
- cellRadius = radius;
- }
-
- static final float EPS = 0.00001f;
-
- void add(Sprite sprite) {
- final boolean lowU = sprite.getMinU() < midU - EPS;
- final boolean highU = sprite.getMaxU() > midU + EPS;
- final boolean lowV = sprite.getMinV() < midV - EPS;
- final boolean highV = sprite.getMaxV() > midV + EPS;
-
- if (lowU && lowV) {
- addInner(sprite, lowLow, -1, -1, q -> lowLow = q);
- }
-
- if (lowU && highV) {
- addInner(sprite, lowHigh, -1, 1, q -> lowHigh = q);
- }
-
- if (highU && lowV) {
- addInner(sprite, highLow, 1, -1, q -> highLow = q);
- }
-
- if (highU && highV) {
- addInner(sprite, highHigh, 1, 1, q -> highHigh = q);
- }
- }
-
- private void addInner(Sprite sprite, Object quadrant, int uStep, int vStep, Consumer