Class WorldRenderEvents
LevelRenderer.renderLevel(com.mojang.blaze3d.resource.GraphicsResourceAllocator, net.minecraft.client.DeltaTracker, boolean, net.minecraft.client.Camera, org.joml.Matrix4f, org.joml.Matrix4f, org.joml.Matrix4f, com.mojang.blaze3d.buffers.GpuBufferSlice, org.joml.Vector4f, boolean)
without adding complicated and conflict-prone injections there. Using these events also enables 3rd-party renderers
that make large-scale rendering changes to maintain compatibility by calling any broken event invokers directly.
These events can be separated into two categories, the "extraction" events and the "drawing" events, reflecting the respective vanilla phases. All data needed for rendering should be prepared in the "extraction" phase and drawn to the frame buffer during the "drawing" phase. All "extraction" events have the suffix "Extraction". All events without the "Extraction" suffix are "drawing" events. All "drawing" events support OpenGL calls.
To attach modded data to vanilla render states, see FabricRenderState.
Only attach the minimum data needed for rendering. Do not attach objects that are not thread-safe such as ClientLevel.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interface -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Event<WorldRenderEvents.AfterBlockOutlineExtraction> Called after the block outline render state is extracted, before it is drawn.static final Event<WorldRenderEvents.AfterEntities> Called after entities and block entities are drawn to the framebuffer.static final Event<WorldRenderEvents.BeforeBlockOutline> Called after block outline render checks are made and before the default block outline is drawn to the framebuffer.static final Event<WorldRenderEvents.DebugRender> Called after entities, block breaking, and most non-translucent objects are drawn to the framebuffer, before vanilla debug renderers and translucency are drawn to the framebuffer.static final Event<WorldRenderEvents.BeforeEntities> Called after theSOLID,CUTOUT, andCUTOUT_MIPPEDterrain layers are drawn to the framebuffer, before entity and block entities are submitted and drawn to the framebuffer.static final Event<WorldRenderEvents.BeforeTranslucent> Called after entities and block entities are drawn to the framebuffer, before translucent terrain is drawn to the framebuffer, and before translucency combine has happened in fabulous mode.static final Event<WorldRenderEvents.EndExtraction> Called after all render states are extracted, before any is drawn.static final Event<WorldRenderEvents.EndMain> Called at the end of the main render pass, after entities, block entities, terrain, and translucent terrain are drawn to the framebuffer, before particles, clouds, weather, and late debug are drawn to the framebuffer.static final Event<WorldRenderEvents.StartMain> Called after all chunks to be rendered are uploaded to GPU, before any chunks are drawn to the framebuffer. -
Method Summary
-
Field Details
-
AFTER_BLOCK_OUTLINE_EXTRACTION
public static final Event<WorldRenderEvents.AfterBlockOutlineExtraction> AFTER_BLOCK_OUTLINE_EXTRACTIONCalled after the block outline render state is extracted, before it is drawn. Can optionally cancel the default rendering by setting the outline render state to null but all handlers for this event will always be called.Use this to extract custom data needed when decorating or replacing the default block outline rendering for specific modded blocks or when normally, the block outline would not be extracted to be rendered. Normally, outline rendering will not happen for entities, fluids, or other game objects that do not register a block-type hit.
To attach modded data to vanilla render states, see
FabricRenderState. Only attach the minimum data needed for rendering. Do not attach objects that are not thread-safe such asClientLevel.Setting the outline render state to null by any event subscriber will cancel the default block outline render and suppress the
BEFORE_BLOCK_OUTLINEevent. This has no effect on other subscribers to this event - all subscribers will always be called. Setting outline render state to null here is appropriate when there is still a valid block hit (with a fluid, for example) and you don't want the block outline render to appear.This event should NOT be used for general-purpose replacement of the default block outline rendering because it will interfere with mod-specific renders. Mods that replace the default block outline for specific blocks should instead subscribe to
BEFORE_BLOCK_OUTLINE. -
END_EXTRACTION
Called after all render states are extracted, before any is drawn. Use this to extract general custom data needed for rendering.To attach modded data to vanilla render states, see
FabricRenderState. Only attach the minimum data needed for rendering. Do not attach objects that are not thread-safe such asClientLevel. -
START_MAIN
Called after all chunks to be rendered are uploaded to GPU, before any chunks are drawn to the framebuffer. -
BEFORE_ENTITIES
Called after theSOLID,CUTOUT, andCUTOUT_MIPPEDterrain layers are drawn to the framebuffer, before entity and block entities are submitted and drawn to the framebuffer.Use to render non-translucent terrain to the framebuffer.
Note that 3rd-party renderers may combine these passes or otherwise alter the rendering pipeline for sake of performance or features. This can break direct writes to the framebuffer. Use this event for cases that cannot be satisfied by FabricBakedModel, BlockEntityRenderer or other existing abstraction. If at all possible, use an existing terrain RenderLayer instead of outputting to the framebuffer directly with GL calls.
The consumer is responsible for setup and tear down of GL state appropriate for the intended output.
Because solid and cutout quads are depth-tested, order of output does not matter except to improve culling performance, which should not be significant after primary terrain rendering. This means mods that currently hook calls to individual render layers can simply execute them all at once when the event is called. However, you should not access any data outside the provided render states. If more data is needed, extract them during
END_EXTRACTION. -
AFTER_ENTITIES
Called after entities and block entities are drawn to the framebuffer. -
BEFORE_DEBUG_RENDER
Called after entities, block breaking, and most non-translucent objects are drawn to the framebuffer, before vanilla debug renderers and translucency are drawn to the framebuffer.Use to drawn lines, overlays and other content similar to vanilla debug renders.
-
BEFORE_TRANSLUCENT
Called after entities and block entities are drawn to the framebuffer, before translucent terrain is drawn to the framebuffer, and before translucency combine has happened in fabulous mode.Use to draw on top of the main and entity framebuffer targets before clouds and weather are drawn.
-
BEFORE_BLOCK_OUTLINE
Called after block outline render checks are made and before the default block outline is drawn to the framebuffer. This will NOT be called if the default outline render state was set to null inAFTER_BLOCK_OUTLINE_EXTRACTION.Use this to replace the default block outline rendering for specific blocks that need special outline rendering or to add information that doesn't replace the block outline. Subscribers cannot affect each other or detect if another subscriber is also handling a specific block. If two subscribers render for the same block, both renders will appear.
Returning false from any event subscriber will cancel the default block outline render. This has no effect on other subscribers to this event - all subscribers will always be called. Canceling is appropriate when the subscriber replacing the default block outline render for a specific block.
-
END_MAIN
Called at the end of the main render pass, after entities, block entities, terrain, and translucent terrain are drawn to the framebuffer, before particles, clouds, weather, and late debug are drawn to the framebuffer.Use to draw on top of the world before hand and GUI are drawn.
-