Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to set value for Compound #162

Open
alex4200 opened this issue Mar 12, 2022 · 1 comment
Open

Unable to set value for Compound #162

alex4200 opened this issue Mar 12, 2022 · 1 comment

Comments

@alex4200
Copy link

When I just want to copy data, I usually can do something like this

block_entities = nbt.TAG_List(name="block_entitites", value=self.nbt_data["block_entities"])

except for the type "compound":

heightmaps = nbt.TAG_Compound(name="Heightmaps", value=self.nbt_data["Heightmaps"])

where I get an error

    heightmaps = nbt.TAG_Compound(name="Heightmaps", value=self.nbt_data["Heightmaps"])
TypeError: __init__() got an unexpected keyword argument 'value'

Why is that? Why can't I copy the data as for all the other data types?

And how to best copy data like that?

@twoolie
Copy link
Owner

twoolie commented Feb 14, 2023

TAG_Compound doesn't have a single value, it's a collection of other tags. The following code should work.

    heightmaps = nbt.TAG_Compound(name="Heightmaps")
    heightmaps.tags = self.nbt_data["Heightmaps"]

I'll probably add a values kwarg to TAG_Compound to make it behave like the other tags. good idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants