Skip to content

Instantly share code, notes, and snippets.

@pironic
Created April 20, 2011 16:46
Show Gist options
  • Save pironic/931871 to your computer and use it in GitHub Desktop.
Save pironic/931871 to your computer and use it in GitHub Desktop.
minecraft server weather... mcr
<?php
require("nbt.class.php");
$nbt = new nbt();
// change to point to your world's level.dat file
$nbt->loadFile("E:/cc/level.dat");
$a=array();
foreach($nbt->root[0]['value'][0]['value'] as $dat) {
$t = $dat['value'];
if ($dat['name'] === "raining") {
$a['raining'] = $dat['value'] == 0 ? false : true;
}
if ($dat['name'] === "rainTime") {
$a['rainTime'] = $dat['value'];
}
if ($dat['name'] === "thundering") {
$a['thundering'] = $dat['value'] == 0 ? false : true;
}
if ($dat['name'] === "thunderTime") {
$a['thunderTime'] = $dat['value'];
}
if ($dat['name'] === 'Time') {
$a['Time'] = (int)$dat['value'];
}
//print_r($dat);
}
// sunrise is at 22800, noon at 6000, sunset at 13200, and midnight at 18000
//if x > 13200 && x < 22800 = night
echo json_encode($a);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment