Skip to content

Implement writing structure files - #5

Open
inxomnyaa wants to merge 16 commits into
mcstructurefrom
feature/read-write
Open

Implement writing structure files#5
inxomnyaa wants to merge 16 commits into
mcstructurefrom
feature/read-write

Conversation

@inxomnyaa

Copy link
Copy Markdown
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);
```
@inxomnyaainxomnyaa self-assigned this Oct 20, 2022
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancementNew feature or requesthacktoberfest-accepted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@inxomnyaa