Class LevelRenderer

java.lang.Object
net.minecraft.client.renderer.LevelRenderer
All Implemented Interfaces:
AutoCloseable, PreparableReloadListener, ResourceManagerReloadListener

public class LevelRenderer extends Object implements ResourceManagerReloadListener, AutoCloseable
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • TRANSPARENCY_POST_CHAIN_ID

      private static final ResourceLocation TRANSPARENCY_POST_CHAIN_ID
    • ENTITY_OUTLINE_POST_CHAIN_ID

      private static final ResourceLocation ENTITY_OUTLINE_POST_CHAIN_ID
    • SECTION_SIZE

      public static final int SECTION_SIZE
      See Also:
    • HALF_SECTION_SIZE

      public static final int HALF_SECTION_SIZE
      See Also:
    • NEARBY_SECTION_DISTANCE_IN_BLOCKS

      public static final int NEARBY_SECTION_DISTANCE_IN_BLOCKS
      See Also:
    • MINIMUM_TRANSPARENT_SORT_COUNT

      private static final int MINIMUM_TRANSPARENT_SORT_COUNT
      See Also:
    • ENTITY_COMPARATOR

      private static final Comparator<Entity> ENTITY_COMPARATOR
    • minecraft

      private final Minecraft minecraft
    • entityRenderDispatcher

      private final EntityRenderDispatcher entityRenderDispatcher
    • blockEntityRenderDispatcher

      private final BlockEntityRenderDispatcher blockEntityRenderDispatcher
    • renderBuffers

      private final RenderBuffers renderBuffers
    • skyRenderer

      private final SkyRenderer skyRenderer
    • cloudRenderer

      private final CloudRenderer cloudRenderer
    • worldBorderRenderer

      private final WorldBorderRenderer worldBorderRenderer
    • weatherEffectRenderer

      private final WeatherEffectRenderer weatherEffectRenderer
    • level

      @Nullable private ClientLevel level
    • sectionOcclusionGraph

      private final SectionOcclusionGraph sectionOcclusionGraph
    • visibleSections

      private final it.unimi.dsi.fastutil.objects.ObjectArrayList<SectionRenderDispatcher.RenderSection> visibleSections
    • nearbyVisibleSections

      private final it.unimi.dsi.fastutil.objects.ObjectArrayList<SectionRenderDispatcher.RenderSection> nearbyVisibleSections
    • viewArea

      @Nullable private ViewArea viewArea
    • ticks

      private int ticks
    • destroyingBlocks

      private final it.unimi.dsi.fastutil.ints.Int2ObjectMap<BlockDestructionProgress> destroyingBlocks
    • destructionProgress

      private final it.unimi.dsi.fastutil.longs.Long2ObjectMap<SortedSet<BlockDestructionProgress>> destructionProgress
    • entityOutlineTarget

      @Nullable private RenderTarget entityOutlineTarget
    • targets

      private final LevelTargetBundle targets
    • lastCameraSectionX

      private int lastCameraSectionX
    • lastCameraSectionY

      private int lastCameraSectionY
    • lastCameraSectionZ

      private int lastCameraSectionZ
    • prevCamX

      private double prevCamX
    • prevCamY

      private double prevCamY
    • prevCamZ

      private double prevCamZ
    • prevCamRotX

      private double prevCamRotX
    • prevCamRotY

      private double prevCamRotY
    • sectionRenderDispatcher

      @Nullable private SectionRenderDispatcher sectionRenderDispatcher
    • lastViewDistance

      private int lastViewDistance
    • visibleEntities

      private final List<Entity> visibleEntities
    • visibleEntityCount

      private int visibleEntityCount
    • cullingFrustum

      private Frustum cullingFrustum
    • captureFrustum

      private boolean captureFrustum
    • capturedFrustum

      @Nullable private Frustum capturedFrustum
    • lastTranslucentSortBlockPos

      @Nullable private BlockPos lastTranslucentSortBlockPos
    • translucencyResortIterationIndex

      private int translucencyResortIterationIndex
  • Constructor Details

  • Method Details

    • tickParticles

      public void tickParticles(Camera pCamera)
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • onResourceManagerReload

      public void onResourceManagerReload(ResourceManager pResourceManager)
      Specified by:
      onResourceManagerReload in interface ResourceManagerReloadListener
    • initOutline

      public void initOutline()
    • getTransparencyChain

      @Nullable private PostChain getTransparencyChain()
    • doEntityOutline

      public void doEntityOutline()
    • shouldShowEntityOutlines

      public boolean shouldShowEntityOutlines()
    • setLevel

      public void setLevel(@Nullable ClientLevel pLevel)
      Parameters:
      pLevel - the level to set, or null to clear
    • clearVisibleSections

      private void clearVisibleSections()
    • allChanged

      public void allChanged()
    • resize

      public void resize(int pWidth, int pHeight)
    • getSectionStatistics

      public String getSectionStatistics()
    • getSectionRenderDispatcher

      public SectionRenderDispatcher getSectionRenderDispatcher()
    • getTotalSections

      public double getTotalSections()
    • getLastViewDistance

      public double getLastViewDistance()
    • countRenderedSections

      public int countRenderedSections()
    • getEntityStatistics

      public String getEntityStatistics()
    • setupRender

      private void setupRender(Camera pCamera, Frustum pFrustum, boolean pHasCapturedFrustum, boolean pIsSpectator)
    • offsetFrustum

      public static Frustum offsetFrustum(Frustum pFrustum)
    • applyFrustum

      private void applyFrustum(Frustum pFrustum)
    • addRecentlyCompiledSection

      public void addRecentlyCompiledSection(SectionRenderDispatcher.RenderSection pRenderSection)
    • prepareCullFrustum

      public void prepareCullFrustum(Vec3 p_253766_, org.joml.Matrix4f p_254341_, org.joml.Matrix4f p_323487_)
    • renderLevel

      public void renderLevel(GraphicsResourceAllocator p_361796_, DeltaTracker p_348530_, boolean p_109603_, Camera p_109604_, org.joml.Matrix4f p_254120_, org.joml.Matrix4f p_323920_, GpuBufferSlice p_425977_, org.joml.Vector4f p_425544_, boolean p_426302_)
    • addMainPass

      private void addMainPass(FrameGraphBuilder p_361593_, Frustum p_366590_, Camera p_363453_, org.joml.Matrix4f p_362420_, GpuBufferSlice p_418185_, boolean p_363964_, boolean p_362137_, DeltaTracker p_360931_, ProfilerFiller p_362234_)
    • addParticlesPass

      @Deprecated private void addParticlesPass(FrameGraphBuilder pFrameGraphBuilder, Camera pCamera, float pPartialTick, GpuBufferSlice pShaderFog)
    • addParticlesPass

      private void addParticlesPass(FrameGraphBuilder pFrameGraphBuilder, Camera pCamera, float pPartialTick, GpuBufferSlice pShaderFog, Frustum frustum, org.joml.Matrix4f modelViewMatrix)
    • addCloudsPass

      @Deprecated private void addCloudsPass(FrameGraphBuilder pFrameGraphBuilder, CloudStatus pCloudStatus, Vec3 pCameraPosition, float pTicks, int pCloudColor, float pCloudHeight)
    • addCloudsPass

      private void addCloudsPass(FrameGraphBuilder pFrameGraphBuilder, CloudStatus pCloudStatus, Vec3 pCameraPosition, float pTicks, int pCloudColor, float pCloudHeight, org.joml.Matrix4f modelViewMatrix)
    • addWeatherPass

      @Deprecated private void addWeatherPass(FrameGraphBuilder pFrameGraphBuilder, Vec3 pCameraPosition, float pPartialTick, GpuBufferSlice pShaderFog)
    • addWeatherPass

      private void addWeatherPass(FrameGraphBuilder pFrameGraphBuilder, Vec3 pCameraPosition, float pPartialTick, GpuBufferSlice pShaderFog, org.joml.Matrix4f modelViewMatrix, Camera camera)
    • addLateDebugPass

      private void addLateDebugPass(FrameGraphBuilder pFrameGraphBuilder, Vec3 pCameraPosition, GpuBufferSlice pShaderFog)
    • collectVisibleEntities

      private boolean collectVisibleEntities(Camera pCamera, Frustum pFrustum, List<Entity> pOutput)
    • renderEntities

      private void renderEntities(PoseStack pPoseStack, MultiBufferSource.BufferSource pBufferSource, Camera pCamera, DeltaTracker pDeltaTracker, List<Entity> pEntities)
    • renderBlockEntities

      private void renderBlockEntities(PoseStack pPoseStack, MultiBufferSource.BufferSource pBufferSource, MultiBufferSource.BufferSource pCrumblingBufferSource, Camera pCamera, float pPartialTick)
    • renderBlockDestroyAnimation

      private void renderBlockDestroyAnimation(PoseStack pPoseStack, Camera pCamera, MultiBufferSource.BufferSource pBufferSource)
    • renderBlockOutline

      private void renderBlockOutline(Camera pCamera, MultiBufferSource.BufferSource pBufferSource, PoseStack pPoseStack, boolean pSort)
    • checkPoseStack

      private void checkPoseStack(PoseStack pPoseStack)
      Asserts that the specified poseStack is
      invalid reference
      clear
      .
      Throws:
      IllegalStateException - if the specified poseStack is not clear
    • renderEntity

      private void renderEntity(Entity pEntity, double pCamX, double pCamY, double pCamZ, float pPartialTick, PoseStack pPoseStack, MultiBufferSource pBufferSource)
    • scheduleTranslucentSectionResort

      private void scheduleTranslucentSectionResort(Vec3 pCameraPosition)
    • scheduleResort

      private void scheduleResort(SectionRenderDispatcher.RenderSection pSection, TranslucencyPointOfView pPointOfView, Vec3 pCameraPosition, boolean pForce, boolean pIgnoreAxisAlignment)
    • prepareChunkRenders

      private ChunkSectionsToRender prepareChunkRenders(org.joml.Matrix4fc p_428537_, double p_428258_, double p_428243_, double p_428448_)
    • endFrame

      public void endFrame()
    • captureFrustum

      public void captureFrustum()
    • killFrustum

      public void killFrustum()
    • tick

      public void tick()
    • removeProgress

      private void removeProgress(BlockDestructionProgress pProgress)
    • addSkyPass

      @Deprecated private void addSkyPass(FrameGraphBuilder pFrameGraphBuilder, Camera pCamera, float pPartialTick, GpuBufferSlice pShaderFog)
    • addSkyPass

      private void addSkyPass(FrameGraphBuilder pFrameGraphBuilder, Camera pCamera, float pPartialTick, GpuBufferSlice pShaderFog, org.joml.Matrix4f modelViewMatrix)
    • shouldRenderDarkDisc

      private boolean shouldRenderDarkDisc(float pPartialTick)
    • doesMobEffectBlockSky

      private boolean doesMobEffectBlockSky(Camera pCamera)
    • compileSections

      private void compileSections(Camera pCamera)
    • renderHitOutline

      private void renderHitOutline(PoseStack pPoseStack, VertexConsumer pBuffer, Entity pEntity, double pCamX, double pCamY, double pCamZ, BlockPos pPos, BlockState pState, int pColor)
    • blockChanged

      public void blockChanged(BlockGetter pLevel, BlockPos pPos, BlockState pOldState, BlockState pNewState, int pFlags)
    • setBlockDirty

      private void setBlockDirty(BlockPos pPos, boolean pReRenderOnMainThread)
    • setBlocksDirty

      public void setBlocksDirty(int pMinX, int pMinY, int pMinZ, int pMaxX, int pMaxY, int pMaxZ)
      Re-renders all blocks in the specified range.
    • setBlockDirty

      public void setBlockDirty(BlockPos pPos, BlockState pOldState, BlockState pNewState)
    • setSectionDirtyWithNeighbors

      public void setSectionDirtyWithNeighbors(int pSectionX, int pSectionY, int pSectionZ)
    • setSectionRangeDirty

      public void setSectionRangeDirty(int pMinY, int pMinX, int pMinZ, int pMaxY, int pMaxX, int pMaxZ)
    • setSectionDirty

      public void setSectionDirty(int pSectionX, int pSectionY, int pSectionZ)
    • setSectionDirty

      private void setSectionDirty(int pSectionX, int pSectionY, int pSectionZ, boolean pReRenderOnMainThread)
    • onSectionBecomingNonEmpty

      public void onSectionBecomingNonEmpty(long pSectionPos)
    • addParticle

      public void addParticle(ParticleOptions pOptions, boolean pForce, double pX, double pY, double pZ, double pXSpeed, double pYSpeed, double pZSpeed)
      Parameters:
      pForce - if true, the particle will be created regardless of its distance from the camera and the
      invalid @linkplain
      {@linkplain #
      calculateParticleLevel(boolean) calculated particle level}
    • addParticle

      public void addParticle(ParticleOptions pOptions, boolean pForce, boolean pDecreased, double pX, double pY, double pZ, double pXSpeed, double pYSpeed, double pZSpeed)
      Parameters:
      pForce - if true, the particle will be created regardless of its distance from the camera and the
      invalid @linkplain
      {@linkplain #
      calculateParticleLevel(boolean) calculated particle level}
      pDecreased - if true, and the particles option is set to minimal, attempts to spawn the particle at a decreased level
    • addParticle

      public <T extends ParticleOptions> void addParticle(T pOptions, double pX, double pY, double pZ, double pXSpeed, double pYSpeed, double pZSpeed)
    • addParticleInternal

      @Nullable Particle addParticleInternal(ParticleOptions pOptions, boolean pForce, double pX, double pY, double pZ, double pXSpeed, double pYSpeed, double pZSpeed)
      Parameters:
      pForce - if true, the particle will be created regardless of its distance from the camera and the
      invalid @linkplain
      {@linkplain #
      calculateParticleLevel(boolean) calculated particle level}
    • addParticleInternal

      @Nullable private Particle addParticleInternal(ParticleOptions pOptions, boolean pForce, boolean pDecreased, double pX, double pY, double pZ, double pXSpeed, double pYSpeed, double pZSpeed)
      Parameters:
      pForce - if true, the particle will be created regardless of its distance from the camera and the
      invalid @linkplain
      {@linkplain #
      calculateParticleLevel(boolean) calculated particle level}
      pDecreased - if true, and the particles option is set to minimal, attempts to spawn the particle at a decreased level
    • calculateParticleLevel

      private ParticleStatus calculateParticleLevel(boolean pDecreased)
    • destroyBlockProgress

      public void destroyBlockProgress(int pBreakerId, BlockPos pPos, int pProgress)
    • hasRenderedAllSections

      public boolean hasRenderedAllSections()
    • onChunkReadyToRender

      public void onChunkReadyToRender(ChunkPos pChunkPos)
    • needsUpdate

      public void needsUpdate()
    • getLightColor

      public static int getLightColor(BlockAndTintGetter pLevel, BlockPos pPos)
    • getLightColor

      public static int getLightColor(LevelRenderer.BrightnessGetter pBrightnessGetter, BlockAndTintGetter pLevel, BlockState pState, BlockPos pPos)
    • isSectionCompiled

      public boolean isSectionCompiled(BlockPos pPos)
    • entityOutlineTarget

      @Nullable public RenderTarget entityOutlineTarget()
    • getTranslucentTarget

      @Nullable public RenderTarget getTranslucentTarget()
    • getItemEntityTarget

      @Nullable public RenderTarget getItemEntityTarget()
    • getParticlesTarget

      @Nullable public RenderTarget getParticlesTarget()
    • getWeatherTarget

      @Nullable public RenderTarget getWeatherTarget()
    • getCloudsTarget

      @Nullable public RenderTarget getCloudsTarget()
    • getVisibleSections

      public it.unimi.dsi.fastutil.objects.ObjectArrayList<SectionRenderDispatcher.RenderSection> getVisibleSections()
    • getSectionOcclusionGraph

      public SectionOcclusionGraph getSectionOcclusionGraph()
    • getCapturedFrustum

      @Nullable public Frustum getCapturedFrustum()
    • getCloudRenderer

      public CloudRenderer getCloudRenderer()
    • getFrustum

      public Frustum getFrustum()
    • getTicks

      public int getTicks()
    • iterateVisibleBlockEntities

      public void iterateVisibleBlockEntities(Consumer<BlockEntity> blockEntityConsumer)
    • getRenderableSections

      @Internal public Iterable<? extends IRenderableSection> getRenderableSections()