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 materialBake(Material.Baked, 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 materialBake(Material.Baked, 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 materialBake(Material.Baked, 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 materialBake(Material.Baked, 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 materialBake(Material.Baked, 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 materialBake(Material.Baked, 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 materialBake(Material.Baked, int).
      See Also:
    • CULL_FACE_EPSILON

      static final float CULL_FACE_EPSILON
      Tolerance for determining if the depth parameter to square(Direction, float, float, float, float, float) is effectively zero - meaning the face is a cull face.
      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).
    • translate

      default MutableQuadView translate(float x, float y, float z)
      Translates the geometric positions of all vertices of this quad by the given offset.
    • 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:
    • multiplyColor

      default MutableQuadView multiplyColor(int color)
      Multiplies all components of each of this quad's vertex colors by the given color in ARGB format (0xAARRGGBB).
      Parameters:
      color - the color in ARGB format (0xAARRGGBB) to multiply by
    • 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).
    • uvUnitSquare

      default MutableQuadView uvUnitSquare()
    • materialBake

      default MutableQuadView materialBake(net.minecraft.client.resources.model.sprite.Material.Baked material, int bakeFlags)
      Sets the texture coordinates for all vertices using the given material's sprite, then invokes postMaterialBake(Material.Baked). Can handle UV locking, rotation, interpolation, etc. Control this behavior by passing additive combinations of the BAKE_ flags defined in this interface.
    • postMaterialBake

      default MutableQuadView postMaterialBake(net.minecraft.client.resources.model.sprite.Material.Baked material)
      Sets this quad's atlas, animated(boolean), chunk layer, and item render type to appropriate values based on the given material and this quad's texture coordinates. Exposed separately from materialBake(Material.Baked, int) as mods frequently transform texture coordinates in ways that are based on a material, but do not want to use materialBake(Material.Baked, int); for example, interpolating sprites for connected textures.
    • lightmap

      MutableQuadView lightmap(int vertexIndex, int lightmap)
      Sets the minimum lightmap value for the given vertex. Input values will override lightmap values computed from level 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:
    • minLightmap

      default MutableQuadView minLightmap(int lightmap)
      Sets the minimum lightmap value for the whole quad; in other words, sets each vertex's lightmap value to the per-component maximum of its existing value and the given value.
      Parameters:
      lightmap - the minimum lightmap value
    • 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 net.minecraft.core.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 materialBake(Material.Baked, 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 net.minecraft.core.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.direction(), 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.

    • atlas

      MutableQuadView atlas(QuadAtlas quadAtlas)
      Sets the atlas texture used by this quad. This property is mainly used to retrieve this quad's sprite via the appropriate atlas' SpriteFinder.

      In block contexts, this property must be QuadAtlas.BLOCK.

      The default value is QuadAtlas.BLOCK.

      See Also:
    • chunkLayer

      MutableQuadView chunkLayer(net.minecraft.client.renderer.chunk.ChunkSectionLayer layer)
      Controls how this quad should be rendered after buffering in block contexts.

      The default value is ChunkSectionLayer.CUTOUT.

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

    • itemRenderType

      MutableQuadView itemRenderType(net.minecraft.client.renderer.rendertype.RenderType renderType)
      Controls how this quad should be rendered after buffering in item contexts. The atlas texture used by the set render type must match this quad's atlas.

      Only the following values are allowed:

      • Sheets.cutoutItemSheet()
      • Sheets.translucentItemSheet()
      • Sheets.cutoutBlockItemSheet()
      • Sheets.translucentBlockItemSheet()

      The behavior is undefined if this method is invoked with any value not in the above list.

      The default value is Sheets.cutoutBlockItemSheet().

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

    • 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.

    • foilType

      MutableQuadView foilType(@Nullable net.minecraft.client.renderer.item.ItemStackRenderState.FoilType foilType)
      Controls how foil (also known as glint) should be applied.

      If set to null, foil will be applied in item contexts based on the foil 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:
    • animated

      MutableQuadView animated(boolean animated)
      Whether the sprite associated with this quad is animated.

      The default value is false.

    • 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.

    • fromBakedQuad

      MutableQuadView fromBakedQuad(net.minecraft.client.resources.model.geometry.BakedQuad quad)
      Sets all applicable data and properties of this quad as specified by the given BakedQuad. In addition, this quad's vertex colors and vertex normals will be reset. This quad's existing lightmap values will be ignored and overwritten.

      Calling this method does not emit this quad.

    • clear

      Resets all vertex data and properties of this quad to their default values.
    • square

      default MutableQuadView square(net.minecraft.core.Direction nominalFace, float left, float bottom, float right, float top, float depth)
      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 CULL_FACE_EPSILON.

      All coordinates should be normalized (0-1).