1163 Commits

Author SHA1 Message Date
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
Guillaume Lemaître
b83b6d4ba7 Anvil worlds by default
This is necessary for MCServerChunkGeneratort.empWorldForLevel for example
2012-06-24 14:56:17 +02:00
Tyler Kennedy
bfba132452 Merge pull request #102 from zhuowei/penewmaterials
Update for the new Minecraft PE updates
2012-05-28 05:21:57 -07:00
Eric Wieser
6eb40b1e00 Line wrapped for readability. Converted comment to docstring 2012-05-28 00:02:54 +02:00
Eric Wieser
0a68c3d422 Added box.positions, to complement box.chunkPositions. 2012-05-27 21:48:50 +02:00
Zhuowei Zhang
b6a490f7f9 Added some stub methods to PocketChunk so that the analyze command doesn't crash 2012-04-29 14:34:08 -07:00
Zhuowei Zhang
b5decefa56 Added new Pocket Edition materials 2012-04-29 14:26:09 -07:00
Tyler Kennedy
253597f0f2 Don't create two additional lists when finding the bounding box. 2012-04-17 07:38:05 -04:00
Tyler Kennedy
416939edd3 Merge pull request #97 from FlukyPhoenix/master
Fix dimension command and sandstone slab texture mapping.
2012-04-15 10:02:40 -07:00
Tyler Kennedy
ebe96a0501 Merge pull request #91 from kamyu2/master
Adds rotation for upside down stairs.
2012-04-15 10:02:22 -07:00
FlukyPhoenix
e7fb36e812 Fixed Sandstone slab texture mapping.
Signed-off-by: FlukyPhoenix <git@flukyphoenix.com>
2012-04-13 00:37:50 +01:00
FlukyPhoenix
040e97547e Fix dimension not listing dimensions. Add dimension command to main help.
Signed-off-by: FlukyPhoenix <git@flukyphoenix.com>
2012-04-13 00:37:01 +01:00
Tyler Kennedy
bb8d1705b8 Merge pull request #95 from jedediah/master
fixes issue #92
2012-04-09 23:30:42 -07:00
Jedediah Smith
1c366dcba8 fix newly created region files getting the wrong extension 2012-04-10 01:58:00 -04:00
Tyler Kennedy
2574a93009 Merge pull request #94 from FlukyPhoenix/master
Update items to 1.2.4 .
2012-04-01 19:36:29 -07:00
FlukyPhoenix
4000cbb84c Update items to 1.2.4 .
Signed-off-by: FlukyPhoenix <git@flukyphoenix.com>
2012-04-02 01:38:32 +01:00
Tyler Kennedy
995bfebbad Removed enchantments, which pymclevel cannot handle. 2012-03-26 21:06:07 -04:00
Tyler Kennedy
7ea41f60da Merge branch 'master' of git://github.com/mcedit/pymclevel 2012-03-26 21:05:17 -04:00
kamyu2
42625e436e Adds vertical flipping for half slabs. 2012-03-19 15:21:00 -05:00
Tyler Kennedy
1dca3869ce Merge pull request #88 from hetmankp/dev
Synchronised leaves in materials.alphaMaterials with YAML data file
2012-03-18 03:11:18 -07:00
Tyler Kennedy
b91439a9dd Merge pull request #90 from Zap-12100/master
Update items.txt for MC 1.2
2012-03-18 03:10:59 -07:00
kamyu2
14dff4e787 Add rotation for upside down stairs. 2012-03-15 21:08:57 -05:00
Zap-12100
77677b7814 Updated items.txt for MC 1.2. Thanks, @copyboy! 2012-03-15 17:59:58 +13:00
przemyslaw
dd19c3b716 Synchronised leaves in materials.alphaMaterials with YAML data file 2012-03-13 21:25:37 +11:00
Tyler Kennedy
10fe26d372 Removing pointless dependency messages from nbt.py logging. Dependency instructions don't belong in logging calls :). Added a more informative error message to pyximport failing on a common case, and had it fall back. 2012-03-13 04:15:15 -04:00
David Vierra
3dc2b9e824 Merge pull request #86 from zothar/pyflakes
pyflakes related: add missing import to __init__.py
2012-03-11 17:39:14 -07:00
David Sowder
45a55661a1 pyflakes related: add ChunkNotPresent to imports from mclevelbase in __init__.py 2012-03-11 14:28:46 -05:00
Tyler Kennedy
17117c8671 Merge pull request #83 from zothar/pyflakes
fix the rest of the import alls, import order for logging in tests.py and a couple of .gitignore additions
2012-03-04 21:13:37 -08:00