Skip to content

Instantly share code, notes, and snippets.

@schoentoon
Created October 29, 2013 15:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schoentoon/7216533 to your computer and use it in GitHub Desktop.
Save schoentoon/7216533 to your computer and use it in GitHub Desktop.
Simple python script to print the weather/day state of a minecraft world for https://github.com/schoentoon/Minecraft-Overviewer
#!/usr/bin/python
print "Content-Type: application/json"
print
from nbt import * # https://github.com/twoolie/NBT
import json
nbtfile = nbt.NBTFile("/complete/path/to/world/data/scoreboard.dat", 'rb')
day = (int(str(nbtfile["Data"]["DayTime"])) % 24000) < 12000
rain = int(str(nbtfile["Data"]["raining"])) == 1
thunder = int(str(nbtfile["Data"]["thundering"])) == 1
if (thunder):
weather_url = "weather/weather_thunder_day.png" if day else "weather/weather_thunder_night.png"
elif (rain):
weather_url = "weather/weather_stormy_day.png" if day else "weather/weather_stormy_night.png"
else:
weather_url = "weather/weather_sunny_day.png" if day else "weather/weather_sunny_night.png"
print json.dumps({"src":weather_url})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment