Interface QuadEmitter

All Superinterfaces:
MutableQuadView, QuadView

public interface QuadEmitter extends MutableQuadView
Specialized MutableQuadView that supports transformers and sends quads to some destination, such as a mesh builder or rendering.

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

Only the renderer should implement or extend this interface.

  • Method Details

    • pos

      QuadEmitter pos(int vertexIndex, float x, float y, float z)
      Description copied from interface: MutableQuadView
      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.

      Specified by:
      pos in interface MutableQuadView
    • pos

      default QuadEmitter pos(int vertexIndex, org.joml.Vector3f pos)
      Description copied from interface: MutableQuadView
      Sets the geometric position for the given vertex. Only use this method if you already have a Vector3f. Otherwise, use MutableQuadView.pos(int, float, float, float).
      Specified by:
      pos in interface MutableQuadView
    • pos

      default QuadEmitter pos(int vertexIndex, org.joml.Vector3fc pos)
      Description copied from interface: MutableQuadView
      Sets the geometric position for the given vertex. Only use this method if you already have a Vector3fc. Otherwise, use MutableQuadView.pos(int, float, float, float).
      Specified by:
      pos in interface MutableQuadView
    • translate

      default QuadEmitter translate(float x, float y, float z)
      Description copied from interface: MutableQuadView
      Translates the geometric positions of all vertices of this quad by the given offset.
      Specified by:
      translate in interface MutableQuadView
    • color

      QuadEmitter color(int vertexIndex, int color)
      Description copied from interface: MutableQuadView
      Sets the color in ARGB format (0xAARRGGBB) for the given vertex.

      The default value for all vertices is 0xFFFFFFFF.

      Specified by:
      color in interface MutableQuadView
    • color

      default QuadEmitter color(int c0, int c1, int c2, int c3)
      Description copied from interface: MutableQuadView
      Sets the color in ARGB format (0xAARRGGBB) for all vertices at once.
      Specified by:
      color in interface MutableQuadView
      See Also:
    • multiplyColor

      default QuadEmitter multiplyColor(int color)
      Description copied from interface: MutableQuadView
      Multiplies all components of each of this quad's vertex colors by the given color in ARGB format (0xAARRGGBB).
      Specified by:
      multiplyColor in interface MutableQuadView
      Parameters:
      color - the color in ARGB format (0xAARRGGBB) to multiply by
    • uv

      QuadEmitter uv(int vertexIndex, float u, float v)
      Description copied from interface: MutableQuadView
      Sets the texture coordinates for the given vertex.

      The default value for all vertices is 0.0f.

      Specified by:
      uv in interface MutableQuadView
    • uv

      default QuadEmitter uv(int vertexIndex, org.joml.Vector2f uv)
      Description copied from interface: MutableQuadView
      Sets the texture coordinates for the given vertex. Only use this method if you already have a Vector2f. Otherwise, use MutableQuadView.uv(int, float, float).
      Specified by:
      uv in interface MutableQuadView
    • uv

      default QuadEmitter uv(int vertexIndex, org.joml.Vector2fc uv)
      Description copied from interface: MutableQuadView
      Sets the texture coordinates for the given vertex. Only use this method if you already have a Vector2fc. Otherwise, use MutableQuadView.uv(int, float, float).
      Specified by:
      uv in interface MutableQuadView
    • uvUnitSquare

      default MutableQuadView uvUnitSquare()
      Specified by:
      uvUnitSquare in interface MutableQuadView
    • materialBake

      default QuadEmitter materialBake(net.minecraft.client.resources.model.sprite.Material.Baked material, int bakeFlags)
      Description copied from interface: MutableQuadView
      Sets the texture coordinates for all vertices using the given material's sprite, then invokes MutableQuadView.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.
      Specified by:
      materialBake in interface MutableQuadView
    • postMaterialBake

      default QuadEmitter postMaterialBake(net.minecraft.client.resources.model.sprite.Material.Baked material)
      Description copied from interface: MutableQuadView
      Sets this quad's atlas, MutableQuadView.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 MutableQuadView.materialBake(Material.Baked, int) as mods frequently transform texture coordinates in ways that are based on a material, but do not want to use MutableQuadView.materialBake(Material.Baked, int); for example, interpolating sprites for connected textures.
      Specified by:
      postMaterialBake in interface MutableQuadView
    • lightmap

      QuadEmitter lightmap(int vertexIndex, int lightmap)
      Description copied from interface: MutableQuadView
      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 MutableQuadView.emissive(boolean).

      The default value for all vertices is 0.

      Specified by:
      lightmap in interface MutableQuadView
    • lightmap

      default QuadEmitter lightmap(int l0, int l1, int l2, int l3)
      Description copied from interface: MutableQuadView
      Sets the lightmap value for all vertices at once.

      For emissive rendering, prefer using MutableQuadView.emissive(boolean).

      Specified by:
      lightmap in interface MutableQuadView
      See Also:
    • minLightmap

      default QuadEmitter minLightmap(int lightmap)
      Description copied from interface: MutableQuadView
      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.
      Specified by:
      minLightmap in interface MutableQuadView
      Parameters:
      lightmap - the minimum lightmap value
    • normal

      QuadEmitter normal(int vertexIndex, float x, float y, float z)
      Description copied from interface: MutableQuadView
      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.
      Specified by:
      normal in interface MutableQuadView
    • normal

      default QuadEmitter normal(int vertexIndex, org.joml.Vector3f normal)
      Description copied from interface: MutableQuadView
      Sets the normal vector for the given vertex. Only use this method if you already have a Vector3f. Otherwise, use MutableQuadView.normal(int, float, float, float).
      Specified by:
      normal in interface MutableQuadView
    • normal

      default QuadEmitter normal(int vertexIndex, org.joml.Vector3fc normal)
      Description copied from interface: MutableQuadView
      Sets the normal vector for the given vertex. Only use this method if you already have a Vector3fc. Otherwise, use MutableQuadView.normal(int, float, float, float).
      Specified by:
      normal in interface MutableQuadView
    • nominalFace

      QuadEmitter nominalFace(@Nullable net.minecraft.core.Direction face)
      Description copied from interface: MutableQuadView
      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 MutableQuadView.materialBake(Material.Baked, int) with MutableQuadView.BAKE_LOCK_UV.

      When MutableQuadView.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.

      Specified by:
      nominalFace in interface MutableQuadView
    • cullFace

      QuadEmitter cullFace(@Nullable net.minecraft.core.Direction face)
      Description copied from interface: MutableQuadView
      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 MutableQuadView.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.

      Specified by:
      cullFace in interface MutableQuadView
    • atlas

      QuadEmitter atlas(QuadAtlas quadAtlas)
      Description copied from interface: MutableQuadView
      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.

      Specified by:
      atlas in interface MutableQuadView
      See Also:
    • chunkLayer

      QuadEmitter chunkLayer(net.minecraft.client.renderer.chunk.ChunkSectionLayer layer)
      Description copied from interface: MutableQuadView
      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.

      Specified by:
      chunkLayer in interface MutableQuadView
    • itemRenderType

      QuadEmitter itemRenderType(net.minecraft.client.renderer.rendertype.RenderType renderType)
      Description copied from interface: MutableQuadView
      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.

      Specified by:
      itemRenderType in interface MutableQuadView
    • emissive

      QuadEmitter emissive(boolean emissive)
      Description copied from interface: MutableQuadView
      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 MutableQuadView.diffuseShade(boolean) and MutableQuadView.ambientOcclusion(TriState).

      The default value is false.

      Specified by:
      emissive in interface MutableQuadView
    • diffuseShade

      QuadEmitter diffuseShade(boolean shade)
      Description copied from interface: MutableQuadView
      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.

      Specified by:
      diffuseShade in interface MutableQuadView
    • ambientOcclusion

      QuadEmitter ambientOcclusion(TriState ao)
      Description copied from interface: MutableQuadView
      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.

      Specified by:
      ambientOcclusion in interface MutableQuadView
    • foilType

      QuadEmitter foilType(@Nullable net.minecraft.client.renderer.item.ItemStackRenderState.FoilType foilType)
      Description copied from interface: MutableQuadView
      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.

      Specified by:
      foilType in interface MutableQuadView
    • shadeMode

      QuadEmitter shadeMode(ShadeMode mode)
      Description copied from interface: MutableQuadView
      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.

      Specified by:
      shadeMode in interface MutableQuadView
      See Also:
    • animated

      QuadEmitter animated(boolean animated)
      Description copied from interface: MutableQuadView
      Whether the sprite associated with this quad is animated.

      The default value is false.

      Specified by:
      animated in interface MutableQuadView
    • tintIndex

      QuadEmitter tintIndex(int tintIndex)
      Description copied from interface: MutableQuadView
      Sets the tint index, which is used to retrieve the tint color.

      The default value is -1.

      Specified by:
      tintIndex in interface MutableQuadView
    • tag

      QuadEmitter tag(int tag)
      Description copied from interface: MutableQuadView
      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.

      Specified by:
      tag in interface MutableQuadView
    • copyFrom

      QuadEmitter copyFrom(QuadView quad)
      Description copied from interface: MutableQuadView
      Copies all quad data and properties from the given QuadView to this quad.

      Calling this method does not emit this quad.

      Specified by:
      copyFrom in interface MutableQuadView
    • fromBakedQuad

      QuadEmitter fromBakedQuad(net.minecraft.client.resources.model.geometry.BakedQuad quad)
      Description copied from interface: MutableQuadView
      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.

      Specified by:
      fromBakedQuad in interface MutableQuadView
    • clear

      QuadEmitter clear()
      Description copied from interface: MutableQuadView
      Resets all vertex data and properties of this quad to their default values.
      Specified by:
      clear in interface MutableQuadView
    • square

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

      All coordinates should be normalized (0-1).

      Specified by:
      square in interface MutableQuadView
    • pushTransform

      void pushTransform(QuadTransform transform)
      Pushed transforms will be applied immediately after every call to emit() and before the quad data is delivered to its destination. If any transform returns false, the emitted quad will be discarded and will not be delivered to its destination.

      You MUST call popTransform() once you are done using this emitter in the current scope.

      More than one transformer can be pushed. Transformers are applied in reverse order. (Last pushed is applied first.)

      Using this emitter from inside the pushed quad transform is not supported.

    • popTransform

      void popTransform()
      Removes the transformer added by the last call to pushTransform(QuadTransform). MUST be called once you are done using this emitter in the current scope.
    • emit

      QuadEmitter emit()
      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.