Jump to content

The Celestial Model of Minecraft (Including day/night)


Recommended Posts

Since minecraft modding is mainly focused on the blocks, items, entities, and GUIs,

The simple celestial mechanism of the minecraft is largely unknown.

So I'd like to introduce the celestial model of minecraft, on how it controls and manages the celestial motion.


I'll start from the fact that everyone playing minecraft would know.


1. Basic Model of Universe of Minecraft



In the universe of vanilla minecraft, the 'Celestial Sphere' rotates around the polar axis like the oldest model on cosmology.

There is no planet on the sphere, so every celestial object just 'sticks' to the sphere.

Yes, the only celestial motion in the vanilla minecraft is the Rotation.

  (Note: This is not true with ours! The celestial sphere is only conceptional,

    which is caused by the limit of the binocular parallax of our eyes)




2. The holy, Celestial Angle



Since there is only 'Celestial Sphere' that moves on the sky, The angle is very important; It controls the day and night; It controls the position of sun and moon and stars; It controls nearly everything!


The holy angle is called 'Celestial Angle'!


It is specified on the each world, and calculated in WorldProvider. So if you have your own custom dimension, you can change the day and night however you want!


So you might want to know how it is calculated and how you can modify that.

First, all entries getting celestial angle calls this method: World#getCelstialAngle(float partialTicks).

The method just returns WorldProvider#calculateCelestialAngle(long tick, float partialTicks).

You can override the method, and change the celestial angle.


NOTE: The angle is in range from 0.0F to 1.0F

NOTE2: The angle is 0.0F on the noon, 0.25F on the sunset, 0.5F on the midnight, and 0.75F on the sunrise.




3. Phase of the Moon



Every entries getting the phase of the moon call WorldProvider#getMoonPhase(),

So you can override the method to change phase of the moon.

  (The phase varies from 0.0F(New moon) to 1.0F(Next New Moon))

Also, WorldProvider#moonPhaseFactors gives the moon phase factor per phase index of the moon.

(From New moon to last phase of the moon)

The moon phase factor seems to change the slime spawn rate.


PS. You can override WorldProvider#getCurrentMoonPhaseFactor on the latter version of 1.7.10




4. Rendering mechanism of Sun and Moon



Sun and moon are rendered on RenderGlobal#renderSky(). Before they are rendered, celestial rotation is applied.

Then sun is just rendered on the top of the sky, and moon on the bottom.


You can change the rendering using WorldProvider#setSkyRenderer(IRenderHandler renderer).

Call the method to change the sky renderer with your custom renderer on World Load Event.

You just need to override the IRenderHandler#render(float partialTicks) and input your own sky rendering code.

(But it would be really hard; see RenderGlobal#renderSky() multiple times, and how it works, since it is so hard work)




5. Rendering mechanism of Stars



Stars are rendered before everything happens. Actually, they are just some random 'dots' with fixed seed(10842L).

  See RenderGlobal#renderStars() (on 1.7.10), It lets you know how they are drawn.

When they are drawn, they are saved on rendering buffer.

When sky is getting rendered in RenderGlobal#renderSky(),

  the buffer just displayed on the sky with celestial rotation is applied.


So if you want to change the arrangement of the stars,

you should code the star rendering code on your own in the custom sky renderer.



I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in

Sign In Now

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.