Interface MutableQuadView

All Superinterfaces:
QuadView
All Known Subinterfaces:
QuadEmitter

public interface MutableQuadView extends QuadView
A mutable QuadView instance. The base interface for QuadEmitter and for dynamic renders/mesh transforms.

Instances of MutableQuadView will practically always be thread local and/or reused - do not retain references.

Unless otherwise stated, assume all properties persist through serialization into Meshes and have an effect in both block and item contexts. If a property is described as transient, then its value will not persist through serialization into a Mesh.

Only the renderer should implement or extend this interface.

  • Field Details

    • BAKE_ROTATE_NONE

      static final int BAKE_ROTATE_NONE
      When enabled, causes texture to appear with no rotation. This is the default and does not have to be specified explicitly. Can be overridden by other rotation flags. Pass in bakeFlags parameter to spriteBake(Sprite, int).
      See Also:
    • BAKE_ROTATE_90

      static final int BAKE_ROTATE_90
      When enabled, causes texture to appear rotated 90 degrees clockwise. Pass in bakeFlags parameter to spriteBake(Sprite, int).
      See Also:
    • BAKE_ROTATE_180

      static final int BAKE_ROTATE_180
      When enabled, causes texture to appear rotated 180 degrees. Pass in bakeFlags parameter to spriteBake(Sprite, int).
      See Also:
    • BAKE_ROTATE_270

      static final int BAKE_ROTATE_270
      When enabled, causes texture to appear rotated 270 degrees clockwise. Pass in bakeFlags parameter to spriteBake(Sprite, int).
      See Also:
    • BAKE_LOCK_UV

      static final int BAKE_LOCK_UV
      When enabled, texture coordinates are assigned based on vertex positions and the nominal face. Any existing UV coordinates will be replaced and the BAKE_NORMALIZED flag will be ignored. Pass in bakeFlags parameter to spriteBake(Sprite, int).

      UV lock derives texture coordinates based on nominal face by projecting the quad onto it, even when the quad is not co-planar with it. This flag is ignored if the normal face is null.

      See Also:
    • BAKE_FLIP_U

      static final int BAKE_FLIP_U
      When enabled, 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 from what can be obtained via rotation and both can be applied. Any rotation is applied before this flag. Pass in bakeFlags parameter to spriteBake(Sprite, int).
      See Also:
    • BAKE_FLIP_V

      static final int BAKE_FLIP_V
      Same as BAKE_FLIP_U but for V coordinate.
      See Also:
    • BAKE_NORMALIZED

      static final int BAKE_NORMALIZED
      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 spriteBake(Sprite, int).
      See Also:
  • Method Details

    • pos

      MutableQuadView pos(int vertexIndex, float x, float y, float z)
      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.

      The default value for all vertices is 0.0f.

    • pos

      default MutableQuadView pos(int vertexIndex, org.joml.Vector3f pos)
      Sets the geometric position for the given vertex. Only use this method if you already have a Vector3f. Otherwise, use pos(int, float, float, float).
    • pos

      default MutableQuadView pos(int vertexIndex, org.joml.Vector3fc pos)
      Sets the geometric position for the given vertex. Only use this method if you already have a Vector3fc. Otherwise, use pos(int, float, float, float).
    • color

      MutableQuadView color(int vertexIndex, int color)
      Sets the color in ARGB format (0xAARRGGBB) for the given vertex.

      The default value for all vertices is 0xFFFFFFFF.

    • color

      default MutableQuadView color(int c0, int c1, int c2, int c3)
      Sets the color in ARGB format (0xAARRGGBB) for all vertices at once.
      See Also:
    • uv

      MutableQuadView uv(int vertexIndex, float u, float v)
      Sets the texture coordinates for the given vertex.

      The default value for all vertices is 0.0f.

    • uv

      default MutableQuadView uv(int vertexIndex, org.joml.Vector2f uv)
      Sets the texture coordinates for the given vertex. Only use this method if you already have a Vector2f. Otherwise, use uv(int, float, float).
    • uv

      default MutableQuadView uv(int vertexIndex, org.joml.Vector2fc uv)
      Sets the texture coordinates for the given vertex. Only use this method if you already have a Vector2fc. Otherwise, use uv(int, float, float).
    • spriteBake

      default MutableQuadView spriteBake(Sprite sprite, int bakeFlags)
      Sets the texture coordinates for all vertices using 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.
    • lightmap

      MutableQuadView lightmap(int vertexIndex, int lightmap)
      Sets the minimum lightmap value for the given vertex. Input values will override lightmap values computed from world state if input values are higher. Exposed for completeness but some rendering implementations with non-standard lighting model may not honor it.

      For emissive rendering, prefer using emissive(boolean).

      The default value for all vertices is 0.

    • lightmap

      default MutableQuadView lightmap(int l0, int l1, int l2, int l3)
      Sets the lightmap value for all vertices at once.

      For emissive rendering, prefer using emissive(boolean).

      See Also:
    • normal

      MutableQuadView normal(int vertexIndex, float x, float y, float z)
      Sets the normal vector for the given vertex. The face normal is used when no vertex normal is provided. Models that have per-vertex normals should include them to get correct lighting when it matters.
    • normal

      default MutableQuadView normal(int vertexIndex, org.joml.Vector3f normal)
      Sets the normal vector for the given vertex. Only use this method if you already have a Vector3f. Otherwise, use normal(int, float, float, float).
    • normal

      default MutableQuadView normal(int vertexIndex, org.joml.Vector3fc normal)
      Sets the normal vector for the given vertex. Only use this method if you already have a Vector3fc. Otherwise, use normal(int, float, float, float).
    • nominalFace

      MutableQuadView nominalFace(@Nullable @Nullable Direction face)
      Sets the nominal face, which provides a hint to the renderer about the facing of this quad. It is not required, but if set, should be the expected value of QuadView.lightFace(). It may be used to shortcut geometric analysis, if the provided value was correct; otherwise, it is ignored.

      The nominal face is also used for spriteBake(Sprite, int) with BAKE_LOCK_UV.

      When cullFace(Direction) is called, it also sets the nominal face.

      The default value is null.

      This property is transient. It is set to the same value as QuadView.lightFace() when a quad is decoded.

    • cullFace

      MutableQuadView cullFace(@Nullable @Nullable Direction face)
      Sets the cull face. This quad will not be rendered if its cull face is non-null and the block is occluded by another block in the direction of the cull face.

      The cull face is different from BakedQuad.face(), which is equivalent to QuadView.lightFace(). The light face is computed based on geometry and must be non-null.

      When called, sets nominalFace(Direction) to the same value.

      The default value is null.

      This property is respected only in block contexts. It will not have an effect in other contexts.

    • renderLayer

      MutableQuadView renderLayer(@Nullable @Nullable BlockRenderLayer renderLayer)
      Controls how this quad's pixels should be blended with the scene.

      If set to null, RenderLayers.getBlockLayer(BlockState) will be used to retrieve the render layer in block contexts and the render layer of the state layer will be used in item contexts. Set to another value to override this behavior.

      In block contexts, a non-null value will be used directly. In item contexts, a non-null value will be converted to a RenderLayer using RenderLayerHelper.getEntityBlockLayer(BlockRenderLayer).

      The default value is null.

    • emissive

      MutableQuadView emissive(boolean emissive)
      When true, this quad will be rendered at full brightness. Lightmap values provided via QuadView.lightmap(int) will be ignored.

      This is the preferred method for emissive lighting effects as some renderers with advanced lighting pipelines may not use lightmaps.

      Note that vertex colors will still be modified by diffuse shading and ambient occlusion, unless disabled via diffuseShade(boolean) and ambientOcclusion(TriState).

      The default value is false.

    • diffuseShade

      MutableQuadView diffuseShade(boolean shade)
      Controls whether vertex colors should be modified for diffuse shading.

      The default value is true.

      This property is guaranteed to be respected in block contexts. Some renderers may also respect it in item contexts, but this is not guaranteed.

    • ambientOcclusion

      MutableQuadView ambientOcclusion(TriState ao)
      Controls whether vertex colors should be modified for ambient occlusion.

      If set to TriState.DEFAULT, ambient occlusion will be used if the block state has a luminance of 0. Set to TriState.TRUE or TriState.FALSE to override this behavior. TriState.TRUE will not have an effect if ambient occlusion is disabled globally.

      The default value is TriState.DEFAULT.

      This property is respected only in block contexts. It will not have an effect in other contexts.

    • glint

      MutableQuadView glint(@Nullable ItemRenderState.Glint glint)
      Controls how glint should be applied.

      If set to null, glint will be applied in item contexts based on the glint type of the layer. Set to another value to override this behavior.

      The default value is null.

      This property is guaranteed to be respected in item contexts. Some renderers may also respect it in block contexts, but this is not guaranteed.

    • shadeMode

      MutableQuadView shadeMode(ShadeMode mode)
      A hint to the renderer about how this quad is intended to be shaded, for example through ambient occlusion and diffuse shading. The renderer is free to ignore this hint.

      The default value is ShadeMode.ENHANCED.

      This property is respected only in block contexts. It will not have an effect in other contexts.

      See Also:
    • tintIndex

      MutableQuadView tintIndex(int tintIndex)
      Sets the tint index, which is used to retrieve the tint color.

      The default value is -1.

    • tag

      MutableQuadView tag(int tag)
      Sets the tag, which is an arbitrary integer that is meant to be encoded into Meshes to later allow performing conditional transformation or filtering on their quads.

      The default value is 0.

    • copyFrom

      MutableQuadView copyFrom(QuadView quad)
      Copies all quad data and properties from the given QuadView to this quad.

      Calling this method does not emit this quad.

    • fromVanilla

      MutableQuadView fromVanilla(int[] vertexData, int startIndex)
      Sets this quad's vertex data for all vertices using data in given array, starting at the given index. The array must have at least QuadView.VANILLA_QUAD_STRIDE elements starting at the given index. The format of the data must be the same as BakedQuad.vertexData(). This quad's lightmap values and normals will be set even though vanilla does not decode them from packed vertex data.

      Prefer using fromBakedQuad(BakedQuad) instead if you have a BakedQuad.

      Calling this method does not emit this quad.

    • fromBakedQuad

      MutableQuadView fromBakedQuad(BakedQuad quad)
      Sets all applicable data and properties of this quad as specified by the given BakedQuad. This quad's lightmap values and normals will be set even though vanilla does not decode them from packed vertex data. The baked quad's light emission will be applied to the lightmap values from the vertex data after copying.

      Calling this method does not emit this quad.