Package net.minecraft.client.renderer
Class LevelRenderer
java.lang.Object
net.minecraft.client.renderer.LevelRenderer
- All Implemented Interfaces:
AutoCloseable,PreparableReloadListener,ResourceManagerReloadListener
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface net.minecraft.server.packs.resources.PreparableReloadListener
PreparableReloadListener.PreparationBarrier -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final BlockEntityRenderDispatcherprivate Frustumprivate booleanprivate VertexBufferprotected static final ResourceLocationprivate RenderTargetprivate intprivate Frustumprivate VertexBufferprivate final it.unimi.dsi.fastutil.ints.Int2ObjectMap<BlockDestructionProgress> private final it.unimi.dsi.fastutil.longs.Long2ObjectMap<SortedSet<BlockDestructionProgress>> static final Direction[]private static final ResourceLocationprivate PostChainprivate final EntityRenderDispatcherprivate RenderTargetprivate static final ResourceLocationprivate final RunningTrimmedMeanprivate final org.joml.Vector4f[]private final org.joml.Vector3dprivate booleanprivate final Set<BlockEntity> Global block entities; these are always rendered, even if off-screen.static final intprivate RenderTargetprivate intprivate intprivate intprivate intprivate ClientLevelprivate static final org.slf4j.Loggerprivate static final intprivate final Minecraftprivate static final ResourceLocationprivate booleanNeo: Indicates whether outline effect post-processing was requested for the current frame outside of vanilla codepathsprivate RenderTargetprivate final Map<BlockPos, SoundInstance> private doubleprivate doubleprivate doubleprivate doubleprivate doubleprivate Vec3private CloudStatusprivate intprivate intprivate intprivate static final intprivate static final ResourceLocationprivate static final intprivate final float[]private final float[]private intprivate final RenderBuffersprivate intstatic final intprivate final SectionOcclusionGraphprivate SectionRenderDispatcherprivate static final floatprivate VertexBufferprivate static final ResourceLocationprivate VertexBufferprivate static final ResourceLocationprivate intprivate RenderTargetprivate PostChainprivate static final intprivate ViewAreaprivate final it.unimi.dsi.fastutil.objects.ObjectArrayList<SectionRenderDispatcher.RenderSection> private RenderTargetprivate doubleprivate doubleprivate double -
Constructor Summary
ConstructorsConstructorDescriptionLevelRenderer(Minecraft minecraft, EntityRenderDispatcher entityRenderDispatcher, BlockEntityRenderDispatcher blockEntityRenderDispatcher, RenderBuffers renderBuffers) -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddChainedFilledBoxVertices(PoseStack poseStack, VertexConsumer consumer, double minX, double minY, double minZ, double maxX, double maxY, double maxZ, float red, float green, float blue, float alpha) static voidaddChainedFilledBoxVertices(PoseStack poseStack, VertexConsumer consumer, float minX, float minY, float minZ, float maxX, float maxY, float maxZ, float red, float green, float blue, float alpha) private voidaddFrustumQuad(VertexConsumer consumer, org.joml.Matrix4f matrix, int index1, int index2, int index3, int index4, int red, int green, int blue) private voidaddFrustumVertex(VertexConsumer consumer, org.joml.Matrix4f matrix, int vertexIndex) voidaddParticle(ParticleOptions options, boolean force, boolean decreased, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) voidaddParticle(ParticleOptions options, boolean force, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) private <T extends ParticleOptions>
voidaddParticle(T options, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) private ParticleaddParticleInternal(ParticleOptions options, boolean force, boolean decreased, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) private ParticleaddParticleInternal(ParticleOptions options, boolean force, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) voidaddRecentlyCompiledSection(SectionRenderDispatcher.RenderSection renderSection) voidprivate voidapplyFrustum(Frustum frustum) voidblockChanged(BlockGetter level, BlockPos pos, BlockState oldState, BlockState newState, int flags) private MeshDatabuildClouds(Tesselator tesselator, double x, double y, double z, Vec3 cloudColor) private static MeshDatabuildSkyDisc(Tesselator tesselator, float y) private ParticleStatuscalculateParticleLevel(boolean decreased) Calculates the level of particles to use based on the particles option and the specifieddecreasedparameter.voidprivate voidcaptureFrustum(org.joml.Matrix4f viewMatrix, org.joml.Matrix4f projectionMatrix, double camX, double camY, double camZ, Frustum capturedFrustrum) private voidcheckPoseStack(PoseStack poseStack) Asserts that the specifiedposeStackis clear.voidclear()voidclose()private voidcompileSections(Camera camera) intprivate voidprivate voidprivate voidprivate voidvoiddestroyBlockProgress(int breakerId, BlockPos pos, int progress) voidprivate booleandoesMobEffectBlockSky(Camera camera) private MeshDatadrawStars(Tesselator tesselator) doublestatic intgetLightColor(BlockAndTintGetter level, BlockPos pos) static intgetLightColor(BlockAndTintGetter level, BlockState state, BlockPos pos) intgetTicks()doublevoidglobalLevelEvent(int type, BlockPos pos, int data) Handles a global level event.voidbooleanvoidprivate voidbooleanvoiditerateVisibleBlockEntities(Consumer<BlockEntity> blockEntityConsumer) voidvoidlevelEvent(int type, BlockPos pos, int data) private static Vec3mixColor(float hue) voidprivate voidnotifyNearbyEntities(Level level, BlockPos pos, boolean playing) Notifies living entities in a 3 block range of the specifiedposthat a record is or isn't playing nearby, dependent on the specifiedplayingparameter.static FrustumoffsetFrustum(Frustum frustum) voidonChunkLoaded(ChunkPos chunkPos) voidonResourceManagerReload(ResourceManager resourceManager) voidplayJukeboxSong(Holder<JukeboxSong> song, BlockPos pos) voidprepareCullFrustum(Vec3 cameraPosition, org.joml.Matrix4f frustumMatrix, org.joml.Matrix4f projectionMatrix) private voidremoveProgress(BlockDestructionProgress progress) voidrenderClouds(PoseStack poseStack, org.joml.Matrix4f frustumMatrix, org.joml.Matrix4f projectionMatrix, float partialTick, double camX, double camY, double camZ) private voidrenderDebug(PoseStack poseStack, MultiBufferSource buffer, Camera camera) private voidrenderEndSky(PoseStack poseStack) private voidrenderEntity(Entity entity, double camX, double camY, double camZ, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource) static voidrenderFace(PoseStack poseStack, VertexConsumer buffer, Direction face, float x1, float y1, float z1, float x2, float y2, float z2, float red, float green, float blue, float alpha) private voidrenderHitOutline(PoseStack poseStack, VertexConsumer consumer, Entity entity, double camX, double camY, double camZ, BlockPos pos, BlockState state) voidrenderLevel(DeltaTracker deltaTracker, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, org.joml.Matrix4f frustumMatrix, org.joml.Matrix4f projectionMatrix) static voidrenderLineBox(PoseStack poseStack, VertexConsumer consumer, double minX, double minY, double minZ, double maxX, double maxY, double maxZ, float red, float green, float blue, float alpha) static voidrenderLineBox(PoseStack poseStack, VertexConsumer consumer, double minX, double minY, double minZ, double maxX, double maxY, double maxZ, float red, float green, float blue, float alpha, float red2, float green2, float blue2) static voidrenderLineBox(PoseStack poseStack, VertexConsumer buffer, AABB box, float red, float green, float blue, float alpha) static voidrenderLineBox(VertexConsumer consumer, double minX, double minY, double minZ, double maxX, double maxY, double maxZ, float red, float green, float blue, float alpha) private voidrenderSectionLayer(RenderType renderType, double x, double y, double z, org.joml.Matrix4f frustrumMatrix, org.joml.Matrix4f projectionMatrix) private static voidrenderShape(PoseStack poseStack, VertexConsumer consumer, VoxelShape shape, double x, double y, double z, float red, float green, float blue, float alpha) voidrenderSky(org.joml.Matrix4f frustumMatrix, org.joml.Matrix4f projectionMatrix, float partialTick, Camera camera, boolean isFoggy, Runnable skyFogSetup) private voidrenderSnowAndRain(LightTexture lightTexture, float partialTick, double camX, double camY, double camZ) static voidrenderVoxelShape(PoseStack poseStack, VertexConsumer consumer, VoxelShape shape, double x, double y, double z, float red, float green, float blue, float alpha, boolean p_286443_) private voidrenderWorldBorder(Camera camera) voidNeo: Request outline effect post-processing to be enabled for the current frame.voidresize(int width, int height) private voidsetBlockDirty(BlockPos pos, boolean reRenderOnMainThread) voidsetBlockDirty(BlockPos pos, BlockState oldState, BlockState newState) voidsetBlocksDirty(int minX, int minY, int minZ, int maxX, int maxY, int maxZ) Re-renders all blocks in the specified range.voidsetLevel(ClientLevel level) voidsetSectionDirty(int sectionX, int sectionY, int sectionZ) private voidsetSectionDirty(int sectionX, int sectionY, int sectionZ, boolean reRenderOnMainThread) voidsetSectionDirtyWithNeighbors(int sectionX, int sectionY, int sectionZ) private voidsetupRender(Camera camera, Frustum frustum, boolean hasCapturedFrustum, boolean isSpectator) private static Vec3shiftHue(float red, float green, float blue, float hue) private voidshootParticles(int p_direction, BlockPos pos, RandomSource random, SimpleParticleType particleType) booleanprivate voidstopJukeboxSong(BlockPos pos) voidvoidtick()voidvoidupdateGlobalBlockEntities(Collection<BlockEntity> blockEntitiesToRemove, Collection<BlockEntity> blockEntitiesToAdd) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.minecraft.server.packs.resources.PreparableReloadListener
getNameMethods inherited from interface net.minecraft.server.packs.resources.ResourceManagerReloadListener
reload
-
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
-
SUN_LOCATION
-
CLOUDS_LOCATION
-
END_SKY_LOCATION
-
FORCEFIELD_LOCATION
-
RAIN_LOCATION
-
SNOW_LOCATION
-
DIRECTIONS
-
minecraft
-
entityRenderDispatcher
-
blockEntityRenderDispatcher
-
renderBuffers
-
level
-
sectionOcclusionGraph
-
visibleSections
private final it.unimi.dsi.fastutil.objects.ObjectArrayList<SectionRenderDispatcher.RenderSection> visibleSections -
globalBlockEntities
Global block entities; these are always rendered, even if off-screen. Any block entity is added to this ifBlockEntityRenderer.shouldRenderOffScreen(net.minecraft.world.level.block.entity.BlockEntity)returnstrue. -
viewArea
-
starBuffer
-
skyBuffer
-
darkBuffer
-
generateClouds
private boolean generateClouds -
cloudBuffer
-
frameTimes
-
ticks
private int ticks -
destroyingBlocks
-
destructionProgress
private final it.unimi.dsi.fastutil.longs.Long2ObjectMap<SortedSet<BlockDestructionProgress>> destructionProgress -
playingJukeboxSongs
-
entityTarget
-
entityEffect
-
translucentTarget
-
itemEntityTarget
-
particlesTarget
-
weatherTarget
-
cloudsTarget
-
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
-
prevCloudsType
-
sectionRenderDispatcher
-
lastViewDistance
private int lastViewDistance -
renderedEntities
private int renderedEntities -
culledEntities
private int culledEntities -
cullingFrustum
-
captureFrustum
private boolean captureFrustum -
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 outlineEffectRequestedNeo: Indicates whether outline effect post-processing was requested for the current frame outside of vanilla codepaths
-
-
Constructor Details
-
LevelRenderer
public LevelRenderer(Minecraft minecraft, EntityRenderDispatcher entityRenderDispatcher, BlockEntityRenderDispatcher blockEntityRenderDispatcher, RenderBuffers renderBuffers)
-
-
Method Details
-
renderSnowAndRain
private void renderSnowAndRain(LightTexture lightTexture, float partialTick, double camX, double camY, double camZ) -
tickRain
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
onResourceManagerReload
- Specified by:
onResourceManagerReloadin interfaceResourceManagerReloadListener
-
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
-
createStars
private void createStars() -
drawStars
-
setLevel
- Parameters:
level- the level to set, ornullto clear
-
graphicsChanged
public void graphicsChanged() -
allChanged
public void allChanged() -
resize
public void resize(int width, int height) -
getSectionStatistics
-
getSectionRenderDispatcher
-
getTotalSections
public double getTotalSections() -
getLastViewDistance
public double getLastViewDistance() -
countRenderedSections
public int countRenderedSections() -
getEntityStatistics
-
setupRender
-
offsetFrustum
-
applyFrustum
-
addRecentlyCompiledSection
-
captureFrustum
private void captureFrustum(org.joml.Matrix4f viewMatrix, org.joml.Matrix4f projectionMatrix, double camX, double camY, double camZ, Frustum capturedFrustrum) -
prepareCullFrustum
public void prepareCullFrustum(Vec3 cameraPosition, org.joml.Matrix4f frustumMatrix, org.joml.Matrix4f projectionMatrix) -
renderLevel
public void renderLevel(DeltaTracker deltaTracker, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, org.joml.Matrix4f frustumMatrix, org.joml.Matrix4f projectionMatrix) -
checkPoseStack
Asserts that the specifiedposeStackis clear.- Throws:
IllegalStateException- if the specifiedposeStackis not clear
-
renderEntity
private void renderEntity(Entity entity, double camX, double camY, double camZ, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource) -
renderSectionLayer
private void renderSectionLayer(RenderType renderType, double x, double y, double z, org.joml.Matrix4f frustrumMatrix, org.joml.Matrix4f projectionMatrix) -
renderDebug
-
addFrustumVertex
-
addFrustumQuad
private void addFrustumQuad(VertexConsumer consumer, org.joml.Matrix4f matrix, int index1, int index2, int index3, int index4, int red, int green, int blue) -
captureFrustum
public void captureFrustum() -
killFrustum
public void killFrustum() -
tick
public void tick() -
removeProgress
-
renderEndSky
-
renderSky
-
doesMobEffectBlockSky
-
renderClouds
public void renderClouds(PoseStack poseStack, org.joml.Matrix4f frustumMatrix, org.joml.Matrix4f projectionMatrix, float partialTick, double camX, double camY, double camZ) -
buildClouds
-
compileSections
-
renderWorldBorder
-
renderHitOutline
private void renderHitOutline(PoseStack poseStack, VertexConsumer consumer, Entity entity, double camX, double camY, double camZ, BlockPos pos, BlockState state) -
mixColor
-
shiftHue
-
renderVoxelShape
public static void renderVoxelShape(PoseStack poseStack, VertexConsumer consumer, VoxelShape shape, double x, double y, double z, float red, float green, float blue, float alpha, boolean p_286443_) -
renderShape
private static void renderShape(PoseStack poseStack, VertexConsumer consumer, VoxelShape shape, double x, double y, double z, float red, float green, float blue, float alpha) -
renderLineBox
public static void renderLineBox(VertexConsumer consumer, double minX, double minY, double minZ, double maxX, double maxY, double maxZ, float red, float green, float blue, float alpha) -
renderLineBox
public static void renderLineBox(PoseStack poseStack, VertexConsumer buffer, AABB box, float red, float green, float blue, float alpha) -
renderLineBox
public static void renderLineBox(PoseStack poseStack, VertexConsumer consumer, double minX, double minY, double minZ, double maxX, double maxY, double maxZ, float red, float green, float blue, float alpha) -
renderLineBox
public static void renderLineBox(PoseStack poseStack, VertexConsumer consumer, double minX, double minY, double minZ, double maxX, double maxY, double maxZ, float red, float green, float blue, float alpha, float red2, float green2, float blue2) -
addChainedFilledBoxVertices
public static void addChainedFilledBoxVertices(PoseStack poseStack, VertexConsumer consumer, double minX, double minY, double minZ, double maxX, double maxY, double maxZ, float red, float green, float blue, float alpha) -
addChainedFilledBoxVertices
public static void addChainedFilledBoxVertices(PoseStack poseStack, VertexConsumer consumer, float minX, float minY, float minZ, float maxX, float maxY, float maxZ, float red, float green, float blue, float alpha) -
renderFace
public static void renderFace(PoseStack poseStack, VertexConsumer buffer, Direction face, float x1, float y1, float z1, float x2, float y2, float z2, float red, float green, float blue, float alpha) -
blockChanged
public void blockChanged(BlockGetter level, BlockPos pos, BlockState oldState, BlockState newState, int flags) -
setBlockDirty
-
setBlocksDirty
public void setBlocksDirty(int minX, int minY, int minZ, int maxX, int maxY, int maxZ) Re-renders all blocks in the specified range. -
setBlockDirty
-
setSectionDirtyWithNeighbors
public void setSectionDirtyWithNeighbors(int sectionX, int sectionY, int sectionZ) -
setSectionDirty
public void setSectionDirty(int sectionX, int sectionY, int sectionZ) -
setSectionDirty
private void setSectionDirty(int sectionX, int sectionY, int sectionZ, boolean reRenderOnMainThread) -
getFrustum
-
getTicks
public int getTicks() -
iterateVisibleBlockEntities
-
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
-
stopJukeboxSong
-
stopJukeboxSongAndNotifyNearby
-
notifyNearbyEntities
Notifies living entities in a 3 block range of the specifiedposthat a record is or isn't playing nearby, dependent on the specifiedplayingparameter. This is used to make parrots start or stop partying. -
addParticle
public void addParticle(ParticleOptions options, boolean force, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) - Parameters:
force- iftrue, the particle will be created regardless of its distance from the camera and thecalculateParticleLevel(boolean) calculated particle level}invalid @linkplain
{@linkplain #
-
addParticle
public void addParticle(ParticleOptions options, boolean force, boolean decreased, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) - Parameters:
force- iftrue, the particle will be created regardless of its distance from the camera and thecalculateParticleLevel(boolean) calculated particle level}invalid @linkplain
{@linkplain #decreased- iftrue, 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 options, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) -
addParticleInternal
@Nullable private Particle addParticleInternal(ParticleOptions options, boolean force, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) - Parameters:
force- iftrue, the particle will be created regardless of its distance from the camera and thecalculateParticleLevel(boolean) calculated particle level}invalid @linkplain
{@linkplain #
-
addParticleInternal
@Nullable private Particle addParticleInternal(ParticleOptions options, boolean force, boolean decreased, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) - Parameters:
force- iftrue, the particle will be created regardless of its distance from the camera and thecalculateParticleLevel(boolean) calculated particle level}invalid @linkplain
{@linkplain #decreased- iftrue, and the particles option is set to minimal, attempts to spawn the particle at a decreased level
-
calculateParticleLevel
Calculates the level of particles to use based on the particles option and the specifieddecreasedparameter. This leads to randomly generating more or less particles than the set option.- Parameters:
decreased- iftrue, 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
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:
type- 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
-
destroyBlockProgress
-
hasRenderedAllSections
public boolean hasRenderedAllSections() -
onChunkLoaded
-
needsUpdate
public void needsUpdate() -
updateGlobalBlockEntities
public void updateGlobalBlockEntities(Collection<BlockEntity> blockEntitiesToRemove, Collection<BlockEntity> blockEntitiesToAdd) -
getLightColor
-
getLightColor
-
isSectionCompiled
-
entityTarget
-
getTranslucentTarget
-
getItemEntityTarget
-
getParticlesTarget
-
getWeatherTarget
-
getCloudsTarget
-
shootParticles
private void shootParticles(int p_direction, BlockPos pos, RandomSource random, SimpleParticleType particleType)
-