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

Implement writing structure files #5

Open
wants to merge 16 commits into
base: mcstructure
Choose a base branch
from

Conversation

inxomnyaa
Copy link
Owner

Currently structures can only be read as readonly.
In order to implement rotation in MWE2, write mode is needed.

This PR additionally has:

  • Support for palette filters (i.e. get only "stone" blocks from a structure)
  • Faster parsing of structures
  • Less memory footprint of structures in RAM
  • File validity checks
  • Lazy loading of structures (parsed when needed)
  • Palette switching and writing
  • Improved errors
  • Infinite block layer support

In hindsight the PR should have been split up into multiple parts, but due to time constraints and code restructuring this was barely possible in a clean way.

- palette switch now possible
- open up ways to write structure files
- extract MCStructureData for raw file data parsing, i.e. palettes, nbt, blockIndices..
- added file validity checks
- split parse into read() (raw file loading) and parse() (data converting) methods to allow lazy loading
- Vector3s are BlockPosition instead now
TODO remove blockEntity hack
Also ::writePalette() used by fromStructure()
Example:
```php
(new MCStructure(MCStructureData::fromStructure($structure),$structure->getSize(),$structure->getStructureWorldOrigin()))->write("structure".MCStructure::EXTENSION_MCSTRUCTURE);
```
@inxomnyaa inxomnyaa self-assigned this Oct 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant