Minecraft Modding: Sky and Weather

Changing The Sky and Weather

The "sky" in Minecraft consists of the sun, moon/star textures plus the clouds. To change these, you should make a custom dimension (look up tutorials on that but basically the idea is you register a WorldProvider class to a dimension ID) and then in your custom WorldProvider class you can override the following methods to change the sky rendering:
  • getSunTexture()-- @Override this to return your own texture resource
  • getMoonTexture()-- @Override this to return your own texture resource
  • setSkyRenderer()
  • setCloudRenderer()
  • setWeatherRenderer()
For each of these renderer methods, you could return your own renderers (which should extend IRenderHandler).

Other interesting stuff related to sky in WorldProvider class (you could extend the class and @Override these to customize them):
  • getHasNoSky() -- if true, then weather isn't used and sky-based lighting is not calculated.
  • calcSunriseSunsetColors() can use the celestial angle to add a tint to the sky.
  • getSkyColor()
  • isSkyColored()
  • getSunBrightness()
  • getStarBrightness()
  • getCloudHeight()
  • drawClouds()
  • updateWeather()
  • canDoLightning() and canDoRainSnowIce() tell whether those weather effects should be allowed.
  • canSnowAt() controls whether the snow is allowed at a specific location.
Anyway, you can see that there is a lot of control over the sky, clouds and weather possible by combining these various methods.

Changing The Frequency That Sky "Time" Is Updated

Many people update the sky time on the server (e.g. in WorldTickEvent) every tick but the server only syncs time with the client once every 20 ticks = 1 second. If for some reason you need immediate or different interval of update you can have the server send an SPacketTimeUpdate to all players in the dimension manually, or also update the time on the client.

No comments:

Post a Comment