Interface QuadEmitter
- All Superinterfaces:
MutableQuadView, QuadView
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.
-
Field Summary
Fields inherited from interface MutableQuadView
BAKE_FLIP_U, BAKE_FLIP_V, BAKE_LOCK_UV, BAKE_NORMALIZED, BAKE_ROTATE_180, BAKE_ROTATE_270, BAKE_ROTATE_90, BAKE_ROTATE_NONE, CULL_FACE_EPSILON -
Method Summary
Modifier and TypeMethodDescriptionControls whether vertex colors should be modified for ambient occlusion.animated(boolean animated) Whether the sprite associated with this quad is animated.Sets the atlas texture used by this quad.chunkLayer(net.minecraft.client.renderer.chunk.ChunkSectionLayer layer) Controls how this quad should be rendered after buffering in block contexts.clear()Resets all vertex data and properties of this quad to their default values.color(int vertexIndex, int color) Sets the color in ARGB format (0xAARRGGBB) for the given vertex.default QuadEmittercolor(int c0, int c1, int c2, int c3) Sets the color in ARGB format (0xAARRGGBB) for all vertices at once.Copies all quad data and properties from the givenQuadViewto this quad.cullFace(@Nullable net.minecraft.core.Direction face) Sets the cull face.diffuseShade(boolean shade) Controls whether vertex colors should be modified for diffuse shading.emissive(boolean emissive) When true, this quad will be rendered at full brightness.emit()In static mesh building, causes quad to be appended to the mesh being built.foilType(@Nullable net.minecraft.client.renderer.item.ItemStackRenderState.FoilType foilType) Controls how foil (also known as glint) should be applied.fromBakedQuad(net.minecraft.client.resources.model.geometry.BakedQuad quad) Sets all applicable data and properties of this quad as specified by the givenBakedQuad.itemRenderType(net.minecraft.client.renderer.rendertype.RenderType renderType) Controls how this quad should be rendered after buffering in item contexts.lightmap(int vertexIndex, int lightmap) Sets the minimum lightmap value for the given vertex.default QuadEmitterlightmap(int l0, int l1, int l2, int l3) Sets the lightmap value for all vertices at once.default QuadEmittermaterialBake(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 invokesMutableQuadView.postMaterialBake(Material.Baked).default QuadEmitterminLightmap(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.default QuadEmittermultiplyColor(int color) Multiplies all components of each of this quad's vertex colors by the given color in ARGB format (0xAARRGGBB).nominalFace(@Nullable net.minecraft.core.Direction face) Sets the nominal face, which provides a hint to the renderer about the facing of this quad.normal(int vertexIndex, float x, float y, float z) Sets the normal vector for the given vertex.default QuadEmitternormal(int vertexIndex, org.joml.Vector3f normal) Sets the normal vector for the given vertex.default QuadEmitternormal(int vertexIndex, org.joml.Vector3fc normal) Sets the normal vector for the given vertex.voidRemoves the transformer added by the last call topushTransform(QuadTransform).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).default QuadEmitterpos(int vertexIndex, org.joml.Vector3f pos) Sets the geometric position for the given vertex.default QuadEmitterpos(int vertexIndex, org.joml.Vector3fc pos) Sets the geometric position for the given vertex.default QuadEmitterpostMaterialBake(net.minecraft.client.resources.model.sprite.Material.Baked material) 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.voidpushTransform(QuadTransform transform) Pushed transforms will be applied immediately after every call toemit()and before the quad data is delivered to its destination.A hint to the renderer about how this quad is intended to be shaded, for example through ambient occlusion and diffuse shading.default QuadEmittersquare(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.tag(int tag) Sets the tag, which is an arbitrary integer that is meant to be encoded intoMeshes to later allow performing conditional transformation or filtering on their quads.tintIndex(int tintIndex) Sets the tint index, which is used to retrieve the tint color.default QuadEmittertranslate(float x, float y, float z) Translates the geometric positions of all vertices of this quad by the given offset.uv(int vertexIndex, float u, float v) Sets the texture coordinates for the given vertex.default QuadEmitteruv(int vertexIndex, org.joml.Vector2f uv) Sets the texture coordinates for the given vertex.default QuadEmitteruv(int vertexIndex, org.joml.Vector2fc uv) Sets the texture coordinates for the given vertex.default MutableQuadViewMethods inherited from interface QuadView
ambientOcclusion, animated, atlas, buffer, buffer, chunkLayer, color, copyNormal, copyPos, copyUv, cullFace, diffuseShade, emissive, faceNormal, foilType, hasNormal, itemRenderType, lightFace, lightmap, nominalFace, normalX, normalY, normalZ, posByIndex, shadeMode, tag, tintIndex, toBakedQuad, u, v, x, y, z
-
Method Details
-
pos
Description copied from interface:MutableQuadViewSets 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:
posin interfaceMutableQuadView
-
pos
Description copied from interface:MutableQuadViewSets the geometric position for the given vertex. Only use this method if you already have aVector3f. Otherwise, useMutableQuadView.pos(int, float, float, float).- Specified by:
posin interfaceMutableQuadView
-
pos
Description copied from interface:MutableQuadViewSets the geometric position for the given vertex. Only use this method if you already have aVector3fc. Otherwise, useMutableQuadView.pos(int, float, float, float).- Specified by:
posin interfaceMutableQuadView
-
translate
Description copied from interface:MutableQuadViewTranslates the geometric positions of all vertices of this quad by the given offset.- Specified by:
translatein interfaceMutableQuadView
-
color
Description copied from interface:MutableQuadViewSets the color in ARGB format (0xAARRGGBB) for the given vertex.The default value for all vertices is
0xFFFFFFFF.- Specified by:
colorin interfaceMutableQuadView
-
color
Description copied from interface:MutableQuadViewSets the color in ARGB format (0xAARRGGBB) for all vertices at once.- Specified by:
colorin interfaceMutableQuadView- See Also:
-
multiplyColor
Description copied from interface:MutableQuadViewMultiplies all components of each of this quad's vertex colors by the given color in ARGB format (0xAARRGGBB).- Specified by:
multiplyColorin interfaceMutableQuadView- Parameters:
color- the color in ARGB format (0xAARRGGBB) to multiply by
-
uv
Description copied from interface:MutableQuadViewSets the texture coordinates for the given vertex.The default value for all vertices is
0.0f.- Specified by:
uvin interfaceMutableQuadView
-
uv
Description copied from interface:MutableQuadViewSets the texture coordinates for the given vertex. Only use this method if you already have aVector2f. Otherwise, useMutableQuadView.uv(int, float, float).- Specified by:
uvin interfaceMutableQuadView
-
uv
Description copied from interface:MutableQuadViewSets the texture coordinates for the given vertex. Only use this method if you already have aVector2fc. Otherwise, useMutableQuadView.uv(int, float, float).- Specified by:
uvin interfaceMutableQuadView
-
uvUnitSquare
- Specified by:
uvUnitSquarein interfaceMutableQuadView
-
materialBake
default QuadEmitter materialBake(net.minecraft.client.resources.model.sprite.Material.Baked material, int bakeFlags) Description copied from interface:MutableQuadViewSets the texture coordinates for all vertices using the given material's sprite, then invokesMutableQuadView.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:
materialBakein interfaceMutableQuadView
-
postMaterialBake
default QuadEmitter postMaterialBake(net.minecraft.client.resources.model.sprite.Material.Baked material) Description copied from interface:MutableQuadViewSets 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 fromMutableQuadView.materialBake(Material.Baked, int)as mods frequently transform texture coordinates in ways that are based on a material, but do not want to useMutableQuadView.materialBake(Material.Baked, int); for example, interpolating sprites for connected textures.- Specified by:
postMaterialBakein interfaceMutableQuadView
-
lightmap
Description copied from interface:MutableQuadViewSets 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:
lightmapin interfaceMutableQuadView
-
lightmap
Description copied from interface:MutableQuadViewSets the lightmap value for all vertices at once.For emissive rendering, prefer using
MutableQuadView.emissive(boolean).- Specified by:
lightmapin interfaceMutableQuadView- See Also:
-
minLightmap
Description copied from interface:MutableQuadViewSets 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:
minLightmapin interfaceMutableQuadView- Parameters:
lightmap- the minimum lightmap value
-
normal
Description copied from interface:MutableQuadViewSets 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:
normalin interfaceMutableQuadView
-
normal
Description copied from interface:MutableQuadViewSets the normal vector for the given vertex. Only use this method if you already have aVector3f. Otherwise, useMutableQuadView.normal(int, float, float, float).- Specified by:
normalin interfaceMutableQuadView
-
normal
Description copied from interface:MutableQuadViewSets the normal vector for the given vertex. Only use this method if you already have aVector3fc. Otherwise, useMutableQuadView.normal(int, float, float, float).- Specified by:
normalin interfaceMutableQuadView
-
nominalFace
Description copied from interface:MutableQuadViewSets 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 ofQuadView.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)withMutableQuadView.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:
nominalFacein interfaceMutableQuadView
-
cullFace
Description copied from interface:MutableQuadViewSets 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 toQuadView.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:
cullFacein interfaceMutableQuadView
-
atlas
Description copied from interface:MutableQuadViewSets 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:
atlasin interfaceMutableQuadView- See Also:
-
chunkLayer
Description copied from interface:MutableQuadViewControls 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:
chunkLayerin interfaceMutableQuadView
-
itemRenderType
Description copied from interface:MutableQuadViewControls 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:
itemRenderTypein interfaceMutableQuadView
-
emissive
Description copied from interface:MutableQuadViewWhen true, this quad will be rendered at full brightness. Lightmap values provided viaQuadView.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)andMutableQuadView.ambientOcclusion(TriState).The default value is
false.- Specified by:
emissivein interfaceMutableQuadView
-
diffuseShade
Description copied from interface:MutableQuadViewControls 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:
diffuseShadein interfaceMutableQuadView
-
ambientOcclusion
Description copied from interface:MutableQuadViewControls 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 toTriState.TRUEorTriState.FALSEto override this behavior.TriState.TRUEwill 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:
ambientOcclusionin interfaceMutableQuadView
-
foilType
QuadEmitter foilType(@Nullable net.minecraft.client.renderer.item.ItemStackRenderState.FoilType foilType) Description copied from interface:MutableQuadViewControls 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:
foilTypein interfaceMutableQuadView
-
shadeMode
Description copied from interface:MutableQuadViewA 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:
shadeModein interfaceMutableQuadView- See Also:
-
animated
Description copied from interface:MutableQuadViewWhether the sprite associated with this quad is animated.The default value is
false.- Specified by:
animatedin interfaceMutableQuadView
-
tintIndex
Description copied from interface:MutableQuadViewSets the tint index, which is used to retrieve the tint color.The default value is
-1.- Specified by:
tintIndexin interfaceMutableQuadView
-
tag
Description copied from interface:MutableQuadViewSets the tag, which is an arbitrary integer that is meant to be encoded intoMeshes to later allow performing conditional transformation or filtering on their quads.The default value is
0.- Specified by:
tagin interfaceMutableQuadView
-
copyFrom
Description copied from interface:MutableQuadViewCopies all quad data and properties from the givenQuadViewto this quad.Calling this method does not emit this quad.
- Specified by:
copyFromin interfaceMutableQuadView
-
fromBakedQuad
Description copied from interface:MutableQuadViewSets all applicable data and properties of this quad as specified by the givenBakedQuad. 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:
fromBakedQuadin interfaceMutableQuadView
-
clear
QuadEmitter clear()Description copied from interface:MutableQuadViewResets all vertex data and properties of this quad to their default values.- Specified by:
clearin interfaceMutableQuadView
-
square
default QuadEmitter square(net.minecraft.core.Direction nominalFace, float left, float bottom, float right, float top, float depth) Description copied from interface:MutableQuadViewHelper 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:
squarein interfaceMutableQuadView
-
pushTransform
Pushed transforms will be applied immediately after every call toemit()and before the quad data is delivered to its destination. If any transform returnsfalse, 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
thisemitter from inside the pushed quad transform is not supported. -
popTransform
void popTransform()Removes the transformer added by the last call topushTransform(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.
-