GithubHelp home page GithubHelp logo

pyblock's People

Contributors

alex4200 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pyblock's Issues

Fails to write changes when only block entities have been changed

Hello! Thank you for your library!

I am trying to migrate a modpack and my situation is that capitalization has changed on some NBT data.

In other words, I am searching through all inventories in a Minecraft world, and trying to replace the lowercase "items" tags with the proper "Items" tags.

Player inventories are already corrected, so what remains is to search block entities. Your library looked ideal for that.

My strategy is to try and get every chunk to load, by requesting a block from every chunk:

world = pyblock.Editor('')

# Force load all chunks
for x_pos in range(-25000, 25000, 16):
    for z_pos in range(-25000, 25000, 16):
        world.get_block(x_pos, 0, z_pos)

Next, I search through all loaded block entities, and of course check for an inventory, etc. If I find a tag that needs to be corrected, I write the change and then add the entity to the list of entities that need updated:

if str(entity['Items'][i]['id']) == 'simple_backpack:backpack':
    # Change capitalization
    entity['Items'][i]['tag']['backpack']['Items'] = entity['Items'][i]['tag']['backpack']['items']
    # Save to list of pending updates
    region_coords, chunk_coords, _, _ = pyblock.tools.block_to_id_index(entity['x'].value, entity['y'].value, entity['z'].value)
    key = (region_coords, chunk_coords)
    world.entities[key].append(entity)

(This is simplified; my code recursively checks tags in case inventories are nested.)

Then of course when I'm done, I call world.done() to write all changes.

The Issue

Calling world.done() in my code does not save any changes, because world.done() is looking for changes in world.blocks_map. I haven't created any such changes, because I didn't move or copy block entities, I only wanted to make changes to their tags.

Expected Behavior

I would like to suggest that the library should save changes in these cases. What's tricky (from my uninformed POV) is actually changing the block entity rather than adding a duplicate.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.