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

      public static final int SECTION_SIZE
      See Also:
    • HALF_SECTION_SIZE

      public static final int HALF_SECTION_SIZE
      See Also:
    • SKY_DISC_RADIUS

      private static final float SKY_DISC_RADIUS
      See Also:
    • MIN_FOG_DISTANCE

      private static final int MIN_FOG_DISTANCE
      See Also:
    • RAIN_RADIUS

      private static final int RAIN_RADIUS
      See Also:
    • RAIN_DIAMETER

      private static final int RAIN_DIAMETER
      See Also:
    • TRANSPARENT_SORT_COUNT

      private static final int TRANSPARENT_SORT_COUNT
      See Also:
    • MOON_LOCATION

      private static final ResourceLocation MOON_LOCATION
    • SUN_LOCATION

      private static final ResourceLocation SUN_LOCATION
    • CLOUDS_LOCATION

      protected static final ResourceLocation CLOUDS_LOCATION
    • END_SKY_LOCATION

      private static final ResourceLocation END_SKY_LOCATION
    • FORCEFIELD_LOCATION

      private static final ResourceLocation FORCEFIELD_LOCATION
    • RAIN_LOCATION

      private static final ResourceLocation RAIN_LOCATION
    • SNOW_LOCATION

      private static final ResourceLocation SNOW_LOCATION
    • DIRECTIONS

      public static final Direction[] DIRECTIONS
    • minecraft

      private final Minecraft minecraft
    • entityRenderDispatcher

      private final EntityRenderDispatcher entityRenderDispatcher
    • blockEntityRenderDispatcher

      private final BlockEntityRenderDispatcher blockEntityRenderDispatcher
    • renderBuffers

      private final RenderBuffers renderBuffers
    • level

      @Nullable private ClientLevel level
    • sectionOcclusionGraph

      private final SectionOcclusionGraph sectionOcclusionGraph
    • visibleSections

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

      private final Set<BlockEntity> globalBlockEntities
      Global block entities; these are always rendered, even if off-screen. Any block entity is added to this if BlockEntityRenderer.shouldRenderOffScreen(net.minecraft.world.level.block.entity.BlockEntity) returns true.
    • viewArea

      @Nullable private ViewArea viewArea
    • starBuffer

      @Nullable private VertexBuffer starBuffer
    • skyBuffer

      @Nullable private VertexBuffer skyBuffer
    • darkBuffer

      @Nullable private VertexBuffer darkBuffer
    • generateClouds

      private boolean generateClouds
    • cloudBuffer

      @Nullable private VertexBuffer cloudBuffer
    • frameTimes

      private final RunningTrimmedMean frameTimes
    • 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
    • playingJukeboxSongs

      private final Map<BlockPos,SoundInstance> playingJukeboxSongs
    • entityTarget

      @Nullable private RenderTarget entityTarget
    • entityEffect

      @Nullable private PostChain entityEffect
    • translucentTarget

      @Nullable private RenderTarget translucentTarget
    • itemEntityTarget

      @Nullable private RenderTarget itemEntityTarget
    • particlesTarget

      @Nullable private RenderTarget particlesTarget
    • weatherTarget

      @Nullable private RenderTarget weatherTarget
    • cloudsTarget

      @Nullable private RenderTarget cloudsTarget
    • transparencyChain

      @Nullable private PostChain transparencyChain
    • 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
    • prevCloudX

      private int prevCloudX
    • prevCloudY

      private int prevCloudY
    • prevCloudZ

      private int prevCloudZ
    • prevCloudColor

      private Vec3 prevCloudColor
    • prevCloudsType

      @Nullable private CloudStatus prevCloudsType
    • sectionRenderDispatcher

      @Nullable private SectionRenderDispatcher sectionRenderDispatcher
    • lastViewDistance

      private int lastViewDistance
    • renderedEntities

      private int renderedEntities
    • culledEntities

      private int culledEntities
    • cullingFrustum

      private Frustum cullingFrustum
    • captureFrustum

      private boolean captureFrustum
    • capturedFrustum

      @Nullable private Frustum capturedFrustum
    • frustumPoints

      private final org.joml.Vector4f[] frustumPoints
    • frustumPos

      private final org.joml.Vector3d frustumPos
    • xTransparentOld

      private double xTransparentOld
    • yTransparentOld

      private double yTransparentOld
    • zTransparentOld

      private double zTransparentOld
    • rainSoundTime

      private int rainSoundTime
    • rainSizeX

      private final float[] rainSizeX
    • rainSizeZ

      private final float[] rainSizeZ
    • outlineEffectRequested

      private boolean outlineEffectRequested
      Neo: Indicates whether outline effect post-processing was requested for the current frame outside of vanilla codepaths
  • Constructor Details

  • Method Details

    • renderSnowAndRain

      private void renderSnowAndRain(LightTexture pLightTexture, float pPartialTick, double pCamX, double pCamY, double pCamZ)
    • tickRain

      public void tickRain(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()
    • initTransparency

      private void initTransparency()
    • deinitTransparency

      private void deinitTransparency()
    • doEntityOutline

      public void doEntityOutline()
    • shouldShowEntityOutlines

      public boolean shouldShowEntityOutlines()
    • createDarkSky

      private void createDarkSky()
    • createLightSky

      private void createLightSky()
    • buildSkyDisc

      private static MeshData buildSkyDisc(Tesselator pTesselator, float pY)
    • createStars

      private void createStars()
    • drawStars

      private MeshData drawStars(Tesselator pTesselator)
    • setLevel

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

      public void graphicsChanged()
    • 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)
    • captureFrustum

      private void captureFrustum(org.joml.Matrix4f p_253756_, org.joml.Matrix4f p_253787_, double p_254187_, double p_253833_, double p_254547_, Frustum p_253954_)
    • prepareCullFrustum

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

      public void renderLevel(DeltaTracker p_348530_, boolean p_109603_, Camera p_109604_, GameRenderer p_109605_, LightTexture p_109606_, org.joml.Matrix4f p_254120_, org.joml.Matrix4f p_323920_)
    • checkPoseStack

      private void checkPoseStack(PoseStack pPoseStack)
      Asserts that the specified poseStack is 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)
    • renderSectionLayer

      private void renderSectionLayer(RenderType p_294513_, double p_295577_, double p_294761_, double p_294297_, org.joml.Matrix4f p_294782_, org.joml.Matrix4f p_324517_)
    • renderDebug

      private void renderDebug(PoseStack pPoseStack, MultiBufferSource pBuffer, Camera pCamera)
    • addFrustumVertex

      private void addFrustumVertex(VertexConsumer p_270950_, org.joml.Matrix4f p_270118_, int p_270865_)
    • addFrustumQuad

      private void addFrustumQuad(VertexConsumer p_270858_, org.joml.Matrix4f p_270341_, int p_270702_, int p_270959_, int p_270732_, int p_270363_, int p_270273_, int p_270934_, int p_270916_)
    • captureFrustum

      public void captureFrustum()
    • killFrustum

      public void killFrustum()
    • tick

      public void tick()
    • removeProgress

      private void removeProgress(BlockDestructionProgress pProgress)
    • renderEndSky

      private void renderEndSky(PoseStack pPoseStack)
    • renderSky

      public void renderSky(org.joml.Matrix4f p_254034_, org.joml.Matrix4f p_324386_, float p_202426_, Camera p_202427_, boolean p_202428_, Runnable p_202429_)
    • doesMobEffectBlockSky

      private boolean doesMobEffectBlockSky(Camera pCamera)
    • renderClouds

      public void renderClouds(PoseStack p_254145_, org.joml.Matrix4f p_254537_, org.joml.Matrix4f p_324366_, float p_254364_, double p_253843_, double p_253663_, double p_253795_)
    • buildClouds

      private MeshData buildClouds(Tesselator pTesselator, double pX, double pY, double pZ, Vec3 pCloudColor)
    • compileSections

      private void compileSections(Camera pCamera)
    • renderWorldBorder

      private void renderWorldBorder(Camera pCamera)
    • renderHitOutline

      private void renderHitOutline(PoseStack pPoseStack, VertexConsumer pConsumer, Entity pEntity, double pCamX, double pCamY, double pCamZ, BlockPos pPos, BlockState pState)
    • mixColor

      private static Vec3 mixColor(float pHue)
    • shiftHue

      private static Vec3 shiftHue(float pRed, float pGreen, float pBlue, float pHue)
    • renderVoxelShape

      public static void renderVoxelShape(PoseStack pPoseStack, VertexConsumer pConsumer, VoxelShape pShape, double pX, double pY, double pZ, float pRed, float pGreen, float pBlue, float pAlpha, boolean p_286443_)
    • renderShape

      private static void renderShape(PoseStack pPoseStack, VertexConsumer pConsumer, VoxelShape pShape, double pX, double pY, double pZ, float pRed, float pGreen, float pBlue, float pAlpha)
    • renderLineBox

      public static void renderLineBox(VertexConsumer pConsumer, double pMinX, double pMinY, double pMinZ, double pMaxX, double pMaxY, double pMaxZ, float pRed, float pGreen, float pBlue, float pAlpha)
    • renderLineBox

      public static void renderLineBox(PoseStack pPoseStack, VertexConsumer pBuffer, AABB pBox, float pRed, float pGreen, float pBlue, float pAlpha)
    • renderLineBox

      public static void renderLineBox(PoseStack pPoseStack, VertexConsumer pConsumer, double pMinX, double pMinY, double pMinZ, double pMaxX, double pMaxY, double pMaxZ, float pRed, float pGreen, float pBlue, float pAlpha)
    • renderLineBox

      public static void renderLineBox(PoseStack pPoseStack, VertexConsumer pConsumer, double pMinX, double pMinY, double pMinZ, double pMaxX, double pMaxY, double pMaxZ, float pRed, float pGreen, float pBlue, float pAlpha, float pRed2, float pGreen2, float pBlue2)
    • addChainedFilledBoxVertices

      public static void addChainedFilledBoxVertices(PoseStack pPoseStack, VertexConsumer pConsumer, double pMinX, double pMinY, double pMinZ, double pMaxX, double pMaxY, double pMaxZ, float pRed, float pGreen, float pBlue, float pAlpha)
    • addChainedFilledBoxVertices

      public static void addChainedFilledBoxVertices(PoseStack pPoseStack, VertexConsumer pConsumer, float pMinX, float pMinY, float pMinZ, float pMaxX, float pMaxY, float pMaxZ, float pRed, float pGreen, float pBlue, float pAlpha)
    • renderFace

      public static void renderFace(PoseStack pPoseStack, VertexConsumer pBuffer, Direction pFace, float pX1, float pY1, float pZ1, float pX2, float pY2, float pZ2, float pRed, float pGreen, float pBlue, float pAlpha)
    • 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)
    • setSectionDirty

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

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

      public Frustum getFrustum()
    • getTicks

      public int getTicks()
    • iterateVisibleBlockEntities

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

      public void requestOutlineEffect()
      Neo: Request outline effect post-processing to be enabled for the current frame. Must be called before block entities are done rendering, ideally early during the frame
    • playJukeboxSong

      public void playJukeboxSong(Holder<JukeboxSong> pSong, BlockPos pPos)
    • stopJukeboxSong

      private void stopJukeboxSong(BlockPos pPos)
    • stopJukeboxSongAndNotifyNearby

      public void stopJukeboxSongAndNotifyNearby(BlockPos pPos)
    • notifyNearbyEntities

      private void notifyNearbyEntities(Level pLevel, BlockPos pPos, boolean pPlaying)
      Notifies living entities in a 3 block range of the specified pos that a record is or isn't playing nearby, dependent on the specified playing parameter. This is used to make parrots start or stop partying.
    • 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

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

      @Nullable private 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)
      Calculates the level of particles to use based on the particles option and the specified decreased parameter. This leads to randomly generating more or less particles than the set option.
      Parameters:
      pDecreased - if true, and the particles option is set to minimal, has a 1 in 10 chance to return a decreased level and a further 1 in 3 chance to minimise it
    • clear

      public void clear()
    • globalLevelEvent

      public void globalLevelEvent(int pType, BlockPos pPos, int pData)
      Handles a global level event. This includes playing sounds that should be heard by any player, regardless of position and dimension, such as the Wither spawning.
      Parameters:
      pType - the type of level event to handle. This method only handles invalid input: '{@' linkplain net.minecraft.world.level.block.LevelEvent# SOUND_WITHER_BOSS_SPAWN the wither boss spawn sound}, the dragon's death sound, and the end portal spawn sound.
    • levelEvent

      public void levelEvent(int pType, BlockPos pPos, int pData)
    • destroyBlockProgress

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

      public boolean hasRenderedAllSections()
    • onChunkLoaded

      public void onChunkLoaded(ChunkPos pChunkPos)
    • needsUpdate

      public void needsUpdate()
    • updateGlobalBlockEntities

      public void updateGlobalBlockEntities(Collection<BlockEntity> pBlockEntitiesToRemove, Collection<BlockEntity> pBlockEntitiesToAdd)
    • getLightColor

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

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

      public boolean isSectionCompiled(BlockPos pPos)
    • entityTarget

      @Nullable public RenderTarget entityTarget()
    • 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()
    • shootParticles

      private void shootParticles(int pDirection, BlockPos pPos, RandomSource pRandom, SimpleParticleType pParticleType)