Skip to content

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.

2 participants