1190 Commits

Author SHA1 Message Date
David Vierra
124e3389cd Refactor: Change chunk.save() into chunk.getSavedData(). Remove world._saveChunk.
World.saveInPlace now checks chunk.dirty before saving the chunk.
2012-10-27 15:40:23 -10:00
David Vierra
75ae4a35e6 AnvilChunk no longer calls world._loadChunk. Instead, the world passes the chunk's root_tag to the chunk's initializer. 2012-10-27 15:33:51 -10:00
David Vierra
78f473e22c Fixed: Change dtype of HeightMap in newly created chunks to uint32 2012-10-27 15:22:04 -10:00
David Vierra
428a95088a Refactor: Simplify ZipSchematic code and move it to schematic.py
Upon loading, extract the zip file to a temporary folder and load that as an Anvil world
Upon saving, recreate the zip file from the temporary folder.
Register an atexit func to remove the temp folder.
2012-10-27 15:05:12 -10:00
David Vierra
36e7972b22 Fixed: AnvilWorldFolder.getRegionFilename calls getFolderPath to ensure the folder exists 2012-10-27 15:05:12 -10:00
David Vierra
208ba76efb Fixed: Call sanitizeBlocks when saving a chunk. 2012-10-27 15:05:11 -10:00
David Vierra
85d79d6203 Normalized line endings 2012-10-27 15:05:11 -10:00
David Vierra
28209fe262 Refactor: Move chunk and region loading code out of MCInfdevOldLevel into a new class.
AnvilWorldFolder is responsible for computing filesystem paths, caching MCRegionFiles, and loading and saving uncompressed chunk data.
2012-10-27 15:05:10 -10:00
David Vierra
8d0f6c014f Change pocket_test to load an Anvil world instead of an MCR world. 2012-10-27 15:05:10 -10:00
David Vierra
89c535fea1 Refactor: Change TagProperty to accept either a value or a function for the default value. 2012-10-27 15:05:10 -10:00
David Vierra
81f5bbfbb8 Test: testServerGen asserts that the newly created chunk contains any non-air blocks.
Exposes bugs in server gen where block data doesn't get copied from the temporary level.
2012-10-27 15:05:09 -10:00
David Vierra
38cd052bb0 Refactor: Reorder members and methods of MCInfdevOldLevel to place related methods closer together.
Change version to use TagProperty. Remove some backward compatibility from MCServerChunkGenerator
Add # --- Subheaders --- to mark related method groups
Fix whitespace according to pep8
2012-10-27 15:05:09 -10:00
David Vierra
f4b40912a3 Fixed: Statement seems to have no effect
Change several strings-in-void-context into comments like they ought to be.
Change member accesses in void context into assertions or prints.
2012-10-27 15:05:08 -10:00
David Vierra
b7ce019c43 Fixed: Remove redundant parentheses 2012-10-27 15:05:08 -10:00
David Vierra
55c23697df Fixed: Incorrect call arguments
Inspector assumed TagProperty was instance method
Classmethod should have cls as first argument, not self.
2012-10-27 15:05:07 -10:00
David Vierra
bca5e1866b Fixed: Default argument value is mutable 2012-10-27 15:05:07 -10:00
David Vierra
6fa9249a8c Refactor: Remove dead class members. 2012-10-27 15:05:06 -10:00
David Vierra
79f4e1a8f6 Refactor: Remove dead function. 2012-10-27 15:05:06 -10:00
David Vierra
a749389bba Fixed: Comparison with None performed with equality operators 2012-10-27 15:05:05 -10:00
David Vierra
670bb46d8a Refactor: Move MCServerChunkGenerator and related classes and functions to a new file minecraft_server.py 2012-10-27 15:05:05 -10:00
David Vierra
0b55db744c Refactor: Remove tag names statically declared as string constants. 2012-10-27 15:05:02 -10:00
David Vierra
50f9ee5147 Add .gitattributes with core.autocrlf 2012-10-27 15:04:35 -10:00
David Vierra
78e45aedfb Refactor: Remove compressedChunks and related methods and data from MCInfdevOldLevel and AnvilChunk
Move MCRegionFile to its own source file.
Remove knowledge of chunk structure from MCRegionFile. Rename loadChunk to readChunk.
Remove compress, decompress, unload, isLoaded, compressedSize methods.
Remove compressedTag, dataIsPacked, loadedChunkQueue/Limit, decompressedChunkQueue/Limit members.
Rename InfdevChunk to AnvilChunk. Keep in place the conversion to old-style chunks until all client code is updated.
Remove most checks for self.version and keep only the VERSION_ANVIL code in place
Rename Alpha tests to Anvil tests.
Change several tests to load the AnvilWorld test data.
Change ZipSchematic test to export an area from the center of the world instead of from hard-coded coordinates.
2012-10-27 15:04:28 -10:00
David Vierra
7c4296675a TempLevel raises an error when the file isn't found, and doesn't raise AttributeErrors during __del__() 2012-10-26 01:04:36 -10:00
David Vierra
419a403eab Remove last remnant of old NBT code.
saveGzipped is gone, tag.save now saves as gzipped by default. Pass compressed=False to save as uncompressed.
2012-10-18 14:09:52 -10:00
David Vierra
fde247b651 Change data type of computed heightmap arrays to signed integer to avoid unsigned overflow.
Code that works with heightmaps such as filters/smooth.py will subtract two heights expecting to get a negative integer. Getting a very large positive one usually causes an error, so make sure signed int arithmetic gets used.
2012-10-17 12:19:01 -10:00
David Vierra
14967d46da Increase default height of MCInfdevOldLevel to 256 2012-10-17 12:16:04 -10:00
David Vierra
9e9fbc02a9 Improve test coverage somewhat.
Make sure all tag types are saved and loaded. Call repr and str on several types. Create a TAG_Compound and a TAG_List with an initial list of tags.
2012-10-15 17:24:20 -10:00
David Vierra
7972bb8a0d Rename pynbt.py to nbt.py, remove old nbt.py 2012-10-15 15:31:27 -10:00
David Vierra
a83821cd13 Clean up NBT modules.
Simplify the load and save interfaces. Replace the (data, data_cursor) tuples with a load_ctx object. Add an option to skip decoding tag names to unicode, improving speed and memory use if tag names are assumed to be ASCII. Make nbt.py and _nbt.pyx more consistent with each other. Use a similar method to import from _nbt.pyx as is seen in the standard library. Move pretty-print code to its own file and share it between implementations.
2012-10-10 23:28:27 -10:00
David Vierra
87b97ab157 Fix server generator when using MC Server 1.3.2.
MCServerChunkGenerator.copyChunkAtPosition copies the compressed chunk data instead of the uncompressed tag. This is because AnvilChunk removes parts of the tag when emulating the older chunk format.
2012-10-08 19:08:27 -10:00
David Vierra
7696ff9dfa Split up tests into separate files
Because they're in a subfolder, we need to add pymclevel's folder to PYTHONPATH when running tests. See run_tests.sh
2012-10-08 18:39:11 -10:00
David Vierra
5e69394db3 Correctly chain exception tracebacks when raising ChunkMalformed.
Makes debugging easier.
2012-10-08 17:18:00 -10:00
David Vierra
61017d6751 Fix MCInfdevOldLevel.getWorldBounds returning incorrect bounds.
Function assumed that chunk 0,0 is always present, causing it to return enormous world bounds in many cases.
2012-10-07 16:57:11 -10:00
David Vierra
5740ea3324 TestServerGen: Change to test against AnvilWorld to avoid a format mismatch between the server and the test world. 2012-10-07 16:36:27 -10:00
Tyler Kennedy
a1830fee05 Merge pull request #110 from dcoshea/sign_coding_and_mem_leak
Fixes for Anvil memory leak and UTF-8 coding in sign text
2012-10-07 07:36:06 -07:00
Tyler Kennedy
f6376d70b8 Merge pull request #112 from Dezlad/master
Update to add new Blocks and Entities
2012-10-07 07:24:41 -07:00
Derry Coffey
f96f9fd6a0 Updated to add some newer blocks. 2012-10-06 14:43:52 +01:00
David O'Shea
4378e6af26 Fix memory leak for Anvil chunks
When compressing a chunk, the uncompressed tag structure in
self.root_tag is thrown away, but an AnvilChunk stores uncompressed
data in four other member variables (_Blocks, _Data, _BlockLight and
_SkyLight) too.

This fix factors out the discarding of self.root_tag into a new method
_discardUncompressed(), and overrides this method in AnvilChunk to
also throw away the Anvil-specific members.
2012-10-01 14:43:29 +09:30
David O'Shea
3f76761ec5 Don't turn a MemoryError into a ChunkMalformed exception
In a number of places, all exceptions were caught and a ChunkMalformed
exception raised in their place.  Some code, such as dumpSigns,
continues after a ChunkMalformed exception.  In the case where the
ChunkMalformed exception was a result of a MemoryError, this will most
likely result in a flood of error messages because the MemoryError is
not likely to go away by itself.

This fix causes MemoryError exceptions to not be transformed into
ChunkMalformed exceptions, and hopefully covers all cases where this
was done.  Now, when memory is exhausted, the only detail that is
output is "Exception during command: MemoryError()", rather than the
previous, more detailed output, such as:

"""
ERROR:Malformed NBT data in file: r.4.0.mca index 3776 sector 552 length 1 format deflate ()
ERROR:Incorrect chunk format in file: r.4.0.mca index 3776 sector 552 length 1 format deflate (((MemoryError(),), <traceback object at 0x1C927B98>))
"""

but the particular data that was being processed at the time of the
MemoryError is not likely to be useful information anyway.
2012-10-01 08:52:46 +09:30
David O'Shea
96c155909e Correct references to ChunkMalformed exception in dumpSigns/dumpChests
The exception handlers in the dumpSigns and dumpChests commands
referenced ChunkMalformed in the wrong package.

This fix corrects the references, but note that this by itself is not
desirable, as ChunkMalformed is raised when a MemoryError occurs, and
the exception handlers ignore the exception.  As a MemoryError is not
likely to go away by itself, this can result in a flood of error
messages being printed, instead of the existing behaviour where
execution of the command terminates due to the incorrect reference to
ChunkMalformed.
2012-09-29 23:37:20 +09:30
David O'Shea
0e4399b053 Use UTF-8 for decoding of sign text from world
When using the dumpSigns command, if non-ASCII characters were present
in the sign text, a UnicodeDecodeError exception would occur when
concatenating the text from the sign with 'u"\n"'.

This fix decodes the sign text as UTF-8, which appears to be
consistent with the behaviour of Minecraft 1.2.5 for the following
sign text as dumped in Python using repr():
'\xc2\xa3$\xc2\xa3$\xc2\xa3$\xc2\xa3$\xc2\xa3$\xc2\xa3$\xc2\xa3$\xc2\xa3'

Additionally, this fix ensures the output file includes a signature
which makes it easier for tools to work out that the file contains
UTF-8.
2012-09-29 23:19:08 +09:30
Tyler Kennedy
1a66d9e190 Merge pull request #108 from philippelatulippe/dni
Support dimensions with arbitrary directory names.
2012-09-18 02:07:30 -07:00
Philippe Latulippe
90460f89db Support dimensions with arbitrary directory names. 2012-09-09 18:54:37 -04:00
Tyler Kennedy
1f8463312e Merge pull request #107 from Dezlad/master
1.3.1 Update
2012-08-07 01:19:21 -07:00
Tyler Kennedy
16afdaffb8 Merge pull request #103 from eric-wieser/patch-1
Added `box.positions`, to complement `box.chunkPositions`.
2012-08-07 01:07:44 -07:00
Tyler Kennedy
2a28dab3f4 Merge pull request #105 from seventh/master
Ensure that filling worlds is done with the same kind of file format
2012-08-07 01:06:19 -07:00
Derry Coffey
c38127ed81 Fixed the yaml formatting 2012-08-06 16:28:03 +01:00
Derry Coffey
f9bdeee2f2 New Blocks
Adds 1.3.1 Blocks
2012-08-06 11:03:40 +01:00
Derry Coffey
fad40c4dfc New Blocks
Adds 1.3.1 Blocks
2012-08-06 10:59:16 +01:00