Comments (4)
I don't have time to look into it, but I suspect it has to do with this line:
Villages = TAG_List(type=TAG_Compound)
I would replace it with:
Villages = TAG_List(name = "Villages", type=TAG_Compound)
Let me know if this works,
from nbt.
When an unnamed TAG_Compound object is serialized with _render_buffer()
, it raises the following exception:
Traceback (most recent call last):
method <module> in test.py at line 69
villages.write_file("villages.dat")
method write_file in test.py at line 575
self._render_buffer(self.file)
method _render_buffer in test.py at line 401
tag._render_buffer(buffer)
method _render_buffer in test.py at line 400
TAG_String(tag.name)._render_buffer(buffer)
method _render_buffer in test.py at line 268
save_val = self.value.encode("utf-8")
AttributeError: 'NoneType' object has no attribute 'encode'
A quick fix is to assume name
is "" when it is not set (or simply set it to "" instead of None as the default).
Braindump: I don't think this leads to unexpected problems, but it does point to what I nowadays consider a design flaw in the NBT library: there is no clear distinction between a TAG and a Named TAG object. This distinction is only made by the calling function, not by the object itself. E.g., there is no clear distinction between a Named TAG with the name set to "", or a (unnamed) TAG with the name attribute set to None.
from nbt.
Well, you are right. I totally forgot to name that list, because I thought it has no name in the "villages.dat" minecraft file.
Also it turns out that I don't need, this lines:
Players = TAG_List(type=TAG_End, name="Players")
compound.tags.append(Players)
Since the file that the program wrote works fine, minecraft is actually doing this line for me.
At first i was scared that the order of the tags matters but it doesn't.
Thanks.
from nbt.
@Omeganx good to hear, you got it fixed. Thanks for reporting it.
I'll keep this open for a while; even when you don't name a TAG_Compound, it should not raise this error. If it is allowed in a NBT file, it should just serialize it. If it is not allowed in a NBT, it should raise a decent exception.
from nbt.
Related Issues (20)
- get_region should limit the number of open files
- ImportError in Python 3.10: cannot import name 'MutableMapping' from 'collections' HOT 9
- [Question, Potential Bug Report]: _render_buffer recursion when trying to modify region files in entities folder HOT 1
- [Question] How to get block data from blockstates
- (Question) Trying to modify region binary to replace stuff in minecraft world using blockdata
- KeyError: Tag Level does not exist when using Minecraft 1.18.1 worlds. HOT 3
- Can someone add support for 1.18 world height. Chunk section range should support -4 to 19, not 0 to 15. Thanks!
- Error while creating data: "struct.error: int too large to convert" HOT 1
- Unable to set value for Compound HOT 1
- Writing a compound tag to a file HOT 1
- 'TAG_End' is not defined HOT 3
- Using the map example with a 1.8 world renders nothing but black. HOT 2
- Can't save .mca HOT 2
- Get uncompressed NBT data to variable
- SNBT parser in/out
- Use of TAG_Int_Array unclear/undocumented HOT 2
- `Sample_World.tar.gz` missing? HOT 1
- Continuous integration setup HOT 1
- Policy on compatibility with old Minecraft versions HOT 2
- Opening servers.dat.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nbt.