master
Raw Download raw file
 1<?xml version="1.0" encoding="utf-8"?>
 2<feed xmlns="http://www.w3.org/2005/Atom">
 3
 4  <title><![CDATA[Category: Minecraft | BryFry]]></title>
 5  <link href="http://bryfry.github.com/blog/categories/minecraft/atom.xml" rel="self"/>
 6  <link href="http://bryfry.github.com/"/>
 7  <updated>2013-03-05T07:22:42-05:00</updated>
 8  <id>http://bryfry.github.com/</id>
 9  <author>
10    <name><![CDATA[bryfry]]></name>
11    
12  </author>
13  <generator uri="http://octopress.org/">Octopress</generator>
14
15  
16  <entry>
17    <title type="html"><![CDATA[Move Minecraft Spawn with Python]]></title>
18    <link href="http://bryfry.github.com/blog/2012/04/29/move-minecraft-spawn-with-python/"/>
19    <updated>2012-04-29T21:54:00-04:00</updated>
20    <id>http://bryfry.github.com/blog/2012/04/29/move-minecraft-spawn-with-python</id>
21    <content type="html"><![CDATA[<p><img class="right" src="http://i.imgur.com/uubl0.png" width="150" height="150" title="Minecraft" ></p>
22
23<p>The setup for this post is that in a vanilla Minecraft server there
24isn't a way to set the protection size to <code>0</code> (yes, I know bukkit can do
25this but, meh).  This makes having the spawn in the middle of a nice
26area with shared chests, smelting, etc. a pain.  So I wanted to move the
27spawn but I didn’t want to have to download the whole world, open it
28with a map editor, and then re-upload the whole thing again.  Especially
29since I know the values are just stored inside the level.dat.  So, below
30is how I used twoolie’s python NBT interface to move the spawn on our
31server.</p>
32
33<p>To install NBT, grab it from either <a
34href='https://github.com/twoolie/NBT'>github</a> or <a
35href='http://pypi.python.org/pypi/NBT'>pypi</a></p>
36
37<p><code>python spawn-move.py
38from nbt import *
39level = nbt.NBTFile('/&lt;insert.path.here&gt;/world/level.dat','rb')
40level["Data"]["SpawnX"].value = newx
41level["Data"]["SpawnY"].value = newy
42level["Data"]["SpawnZ"].value = newz
43print(level.pretty_tree())  # show changes
44level.write_file('/&lt;insert.path.here&gt;/world/level.dat')
45exit()
46</code></p>
47]]></content>
48  </entry>
49  
50</feed>