-
-
Notifications
You must be signed in to change notification settings - Fork 145
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
Support for schematics file format #263
Open
MrlnHi
wants to merge
26
commits into
valence-rs:main
Choose a base branch
from
MrlnHi:feat/sponge_schem
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 22 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
bc6d058
initial sponge schematic version 2 implementation
MrlnHi dbe79ab
upgrade to sponge schematic version 3
MrlnHi 8ee6c3f
add entities to schematics
MrlnHi b7d671a
Implement schem saving
MrlnHi 86f7b9c
Make setup not exclusive systems
MrlnHi 2a96178
Make select pos1 not break block
MrlnHi 4ae80ba
Improve saving
MrlnHi 314eb0c
Fix BlockEntityKind::from_ident
MrlnHi 4c37f60
Add example schematic to assets
MrlnHi ada8da4
Fixed test
MrlnHi a2e32be
fix rebase
MrlnHi 8f474ee
Implement version 1 and 2
MrlnHi a076977
add module documentation
MrlnHi 8c0054c
Fix unit tests
MrlnHi 953a851
Fix formatting
MrlnHi 58001c9
Fix schem_loading example
MrlnHi ae387ff
Allow type complexity in schem_saving example because of bevy queries
MrlnHi 9bf5af0
Merge branch 'main' into HEAD
MrlnHi 13e0594
Fix after merge
MrlnHi 1c5c8fa
Merge branch 'main' into feat/sponge_schem
MrlnHi d4eb42d
Fix unit test
MrlnHi 32f20ca
Merge branch 'main' into feat/sponge_schem
dyc3 e4c20b9
Use chunk layers instead of instances
MrlnHi 3c7a2b2
Merge branch 'main' into feat/sponge_schem
MrlnHi e646c63
Fix after merge
MrlnHi b24fb5a
Fix unit test and formatting
MrlnHi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[package] | ||
name = "valence_schem" | ||
description = "A library for the Sponge Schematic Format." | ||
documentation.workspace = true | ||
repository = "https://github.com/valence-rs/valence/tree/main/crates/valence_schem" | ||
readme = "README.md" | ||
license.workspace = true | ||
keywords = ["schematics", "minecraft", "deserialization"] | ||
version.workspace = true | ||
edition.workspace = true | ||
|
||
[dependencies] | ||
flate2.workspace = true | ||
glam.workspace = true | ||
thiserror.workspace = true | ||
valence_biome.workspace = true | ||
valence_block.workspace = true | ||
valence_core.workspace = true | ||
valence_instance.workspace = true | ||
valence_nbt.workspace = true | ||
|
||
[dev-dependencies] | ||
valence.workspace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,43 @@ | ||||||||||||
# valence_schem | ||||||||||||
|
||||||||||||
Support for the [Sponge schematic file format](https://github.com/SpongePowered/Schematic-Specification). | ||||||||||||
|
||||||||||||
This crate implements [Sponge schematics] | ||||||||||||
|
||||||||||||
Loading schematics (version 1 through 3) from [`Compounds`](Compound) is | ||||||||||||
supported. Saving schematics to [`Compounds`](Compound) (version 3 only) is | ||||||||||||
supported. | ||||||||||||
|
||||||||||||
# Examples | ||||||||||||
|
||||||||||||
An example that shows how to load and save [schematics] from and to the | ||||||||||||
filesystem | ||||||||||||
|
||||||||||||
```rust | ||||||||||||
# use valence_schem::Schematic; | ||||||||||||
use flate2::Compression; | ||||||||||||
Comment on lines
+17
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
fn schem_from_file(path: &str) -> Schematic { | ||||||||||||
Schematic::load(path).unwrap() | ||||||||||||
} | ||||||||||||
fn schem_to_file(schematic: &Schematic, path: &str) { | ||||||||||||
schematic.save(path); | ||||||||||||
} | ||||||||||||
``` | ||||||||||||
|
||||||||||||
There are also methods to serialize and deserialize [schematics] from and to | ||||||||||||
[`Compounds`](Compound): | ||||||||||||
```rust | ||||||||||||
# use valence_schem::Schematic; | ||||||||||||
use valence_nbt::Compound; | ||||||||||||
Comment on lines
+30
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
fn schem_from_compound(compound: &Compound) { | ||||||||||||
let schematic = Schematic::deserialize(compound).unwrap(); | ||||||||||||
let comp = schematic.serialize(); | ||||||||||||
} | ||||||||||||
``` | ||||||||||||
|
||||||||||||
### See also | ||||||||||||
|
||||||||||||
Examples in the `examples/` directory | ||||||||||||
|
||||||||||||
[Sponge schematics]: <https://github.com/SpongePowered/Schematic-Specification> | ||||||||||||
[schematics]: Schematic |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is redundant.