Mirror von
https://github.com/Chaoscaot/schemsearch
synchronisiert 2024-11-16 17:00:14 +01:00
Commits vergleichen
14 Commits
a1b5449f06
...
9cca860db3
Autor | SHA1 | Datum | |
---|---|---|---|
|
9cca860db3 | ||
|
80f5191ae8 | ||
|
3f20cbc17f | ||
|
733aaa9e72 | ||
|
14866df17d | ||
|
00e3d6fd0f | ||
|
fb8f935617 | ||
|
2a112ac49c | ||
|
e7c1fd1ef7 | ||
|
80eeaad5d5 | ||
|
64158cf45b | ||
|
e4b26755ea | ||
|
5607dcc72c | ||
|
5c9bcfc2ec |
6
.github/dependabot.yml
vendored
Normale Datei
6
.github/dependabot.yml
vendored
Normale Datei
@ -0,0 +1,6 @@
|
|||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: "cargo"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
24
.github/workflows/master-build.yml
vendored
24
.github/workflows/master-build.yml
vendored
@ -19,32 +19,36 @@ jobs:
|
|||||||
- name: Cache Cargo modules
|
- name: Cache Cargo modules
|
||||||
id: cache-cargo
|
id: cache-cargo
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
env:
|
continue-on-error: false
|
||||||
cache-name: cache-cargo-target-debug
|
|
||||||
with:
|
with:
|
||||||
path: target
|
path: |
|
||||||
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/Cargo.lock') }}
|
~/.cargo/registry
|
||||||
|
~/.cargo/git
|
||||||
|
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-${{ env.cache-name }}-
|
${{ runner.os }}-cargo-
|
||||||
- name: Build
|
- name: Build
|
||||||
run: make debug
|
run: make debug
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: cargo test --verbose -p schemsearch-lib
|
run: cargo test --verbose -p schemsearch-lib
|
||||||
|
|
||||||
build-release:
|
build-release:
|
||||||
|
needs:
|
||||||
|
- build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Cache Cargo modules
|
- name: Cache Cargo modules
|
||||||
id: cache-cargo
|
id: cache-cargo
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
env:
|
continue-on-error: false
|
||||||
cache-name: cache-cargo-target-release
|
|
||||||
with:
|
with:
|
||||||
path: target
|
path: |
|
||||||
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/Cargo.lock') }}
|
~/.cargo/registry
|
||||||
|
~/.cargo/git
|
||||||
|
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-${{ env.cache-name }}-
|
${{ runner.os }}-cargo-
|
||||||
- name: Build
|
- name: Build
|
||||||
run: make
|
run: make
|
||||||
- name: Upload a Build Artifact
|
- name: Upload a Build Artifact
|
||||||
|
11
.github/workflows/release-build.yml
vendored
11
.github/workflows/release-build.yml
vendored
@ -22,13 +22,14 @@ jobs:
|
|||||||
- name: Cache Cargo modules
|
- name: Cache Cargo modules
|
||||||
id: cache-cargo
|
id: cache-cargo
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
env:
|
continue-on-error: false
|
||||||
cache-name: cache-cargo-target-release
|
|
||||||
with:
|
with:
|
||||||
path: target
|
path: |
|
||||||
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/Cargo.lock') }}
|
~/.cargo/registry
|
||||||
|
~/.cargo/git
|
||||||
|
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-${{ env.cache-name }}-
|
${{ runner.os }}-cargo-
|
||||||
- name: Build
|
- name: Build
|
||||||
run: make
|
run: make
|
||||||
- name: Create Tarball
|
- name: Create Tarball
|
||||||
|
128
CODE_OF_CONDUCT.md
Normale Datei
128
CODE_OF_CONDUCT.md
Normale Datei
@ -0,0 +1,128 @@
|
|||||||
|
# Contributor Covenant Code of Conduct
|
||||||
|
|
||||||
|
## Our Pledge
|
||||||
|
|
||||||
|
We as members, contributors, and leaders pledge to make participation in our
|
||||||
|
community a harassment-free experience for everyone, regardless of age, body
|
||||||
|
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
||||||
|
identity and expression, level of experience, education, socio-economic status,
|
||||||
|
nationality, personal appearance, race, religion, or sexual identity
|
||||||
|
and orientation.
|
||||||
|
|
||||||
|
We pledge to act and interact in ways that contribute to an open, welcoming,
|
||||||
|
diverse, inclusive, and healthy community.
|
||||||
|
|
||||||
|
## Our Standards
|
||||||
|
|
||||||
|
Examples of behavior that contributes to a positive environment for our
|
||||||
|
community include:
|
||||||
|
|
||||||
|
* Demonstrating empathy and kindness toward other people
|
||||||
|
* Being respectful of differing opinions, viewpoints, and experiences
|
||||||
|
* Giving and gracefully accepting constructive feedback
|
||||||
|
* Accepting responsibility and apologizing to those affected by our mistakes,
|
||||||
|
and learning from the experience
|
||||||
|
* Focusing on what is best not just for us as individuals, but for the
|
||||||
|
overall community
|
||||||
|
|
||||||
|
Examples of unacceptable behavior include:
|
||||||
|
|
||||||
|
* The use of sexualized language or imagery, and sexual attention or
|
||||||
|
advances of any kind
|
||||||
|
* Trolling, insulting or derogatory comments, and personal or political attacks
|
||||||
|
* Public or private harassment
|
||||||
|
* Publishing others' private information, such as a physical or email
|
||||||
|
address, without their explicit permission
|
||||||
|
* Other conduct which could reasonably be considered inappropriate in a
|
||||||
|
professional setting
|
||||||
|
|
||||||
|
## Enforcement Responsibilities
|
||||||
|
|
||||||
|
Community leaders are responsible for clarifying and enforcing our standards of
|
||||||
|
acceptable behavior and will take appropriate and fair corrective action in
|
||||||
|
response to any behavior that they deem inappropriate, threatening, offensive,
|
||||||
|
or harmful.
|
||||||
|
|
||||||
|
Community leaders have the right and responsibility to remove, edit, or reject
|
||||||
|
comments, commits, code, wiki edits, issues, and other contributions that are
|
||||||
|
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
||||||
|
decisions when appropriate.
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
This Code of Conduct applies within all community spaces, and also applies when
|
||||||
|
an individual is officially representing the community in public spaces.
|
||||||
|
Examples of representing our community include using an official e-mail address,
|
||||||
|
posting via an official social media account, or acting as an appointed
|
||||||
|
representative at an online or offline event.
|
||||||
|
|
||||||
|
## Enforcement
|
||||||
|
|
||||||
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||||
|
reported to the community leaders responsible for enforcement at
|
||||||
|
chaoscaot@zohomail.eu.
|
||||||
|
All complaints will be reviewed and investigated promptly and fairly.
|
||||||
|
|
||||||
|
All community leaders are obligated to respect the privacy and security of the
|
||||||
|
reporter of any incident.
|
||||||
|
|
||||||
|
## Enforcement Guidelines
|
||||||
|
|
||||||
|
Community leaders will follow these Community Impact Guidelines in determining
|
||||||
|
the consequences for any action they deem in violation of this Code of Conduct:
|
||||||
|
|
||||||
|
### 1. Correction
|
||||||
|
|
||||||
|
**Community Impact**: Use of inappropriate language or other behavior deemed
|
||||||
|
unprofessional or unwelcome in the community.
|
||||||
|
|
||||||
|
**Consequence**: A private, written warning from community leaders, providing
|
||||||
|
clarity around the nature of the violation and an explanation of why the
|
||||||
|
behavior was inappropriate. A public apology may be requested.
|
||||||
|
|
||||||
|
### 2. Warning
|
||||||
|
|
||||||
|
**Community Impact**: A violation through a single incident or series
|
||||||
|
of actions.
|
||||||
|
|
||||||
|
**Consequence**: A warning with consequences for continued behavior. No
|
||||||
|
interaction with the people involved, including unsolicited interaction with
|
||||||
|
those enforcing the Code of Conduct, for a specified period of time. This
|
||||||
|
includes avoiding interactions in community spaces as well as external channels
|
||||||
|
like social media. Violating these terms may lead to a temporary or
|
||||||
|
permanent ban.
|
||||||
|
|
||||||
|
### 3. Temporary Ban
|
||||||
|
|
||||||
|
**Community Impact**: A serious violation of community standards, including
|
||||||
|
sustained inappropriate behavior.
|
||||||
|
|
||||||
|
**Consequence**: A temporary ban from any sort of interaction or public
|
||||||
|
communication with the community for a specified period of time. No public or
|
||||||
|
private interaction with the people involved, including unsolicited interaction
|
||||||
|
with those enforcing the Code of Conduct, is allowed during this period.
|
||||||
|
Violating these terms may lead to a permanent ban.
|
||||||
|
|
||||||
|
### 4. Permanent Ban
|
||||||
|
|
||||||
|
**Community Impact**: Demonstrating a pattern of violation of community
|
||||||
|
standards, including sustained inappropriate behavior, harassment of an
|
||||||
|
individual, or aggression toward or disparagement of classes of individuals.
|
||||||
|
|
||||||
|
**Consequence**: A permanent ban from any sort of public interaction within
|
||||||
|
the community.
|
||||||
|
|
||||||
|
## Attribution
|
||||||
|
|
||||||
|
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||||
|
version 2.0, available at
|
||||||
|
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
||||||
|
|
||||||
|
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
||||||
|
enforcement ladder](https://github.com/mozilla/diversity).
|
||||||
|
|
||||||
|
[homepage]: https://www.contributor-covenant.org
|
||||||
|
|
||||||
|
For answers to common questions about this code of conduct, see the FAQ at
|
||||||
|
https://www.contributor-covenant.org/faq. Translations are available at
|
||||||
|
https://www.contributor-covenant.org/translations.
|
4
Makefile
4
Makefile
@ -2,6 +2,10 @@ default:
|
|||||||
@echo "Building (Release)...";
|
@echo "Building (Release)...";
|
||||||
cargo rustc --release --color=always -p schemsearch-cli -- -C target-feature=+avx2
|
cargo rustc --release --color=always -p schemsearch-cli -- -C target-feature=+avx2
|
||||||
|
|
||||||
|
sql:
|
||||||
|
@echo "Building (Release)...";
|
||||||
|
cargo rustc --release --color=always -p schemsearch-cli --features sql -- -C target-feature=+avx2
|
||||||
|
|
||||||
debug:
|
debug:
|
||||||
@echo "Building (Debug)...";
|
@echo "Building (Debug)...";
|
||||||
cargo build -p schemsearch-cli
|
cargo build -p schemsearch-cli
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "schemsearch-cli"
|
name = "schemsearch-cli"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
mod types;
|
mod types;
|
||||||
mod json_output;
|
mod json_output;
|
||||||
mod sinks;
|
mod sinks;
|
||||||
|
mod stderr;
|
||||||
|
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
@ -40,6 +41,7 @@ use crate::types::SqlSchematicSupplier;
|
|||||||
use indicatif::*;
|
use indicatif::*;
|
||||||
use schemsearch_files::{SchematicVersioned};
|
use schemsearch_files::{SchematicVersioned};
|
||||||
use crate::sinks::{OutputFormat, OutputSink};
|
use crate::sinks::{OutputFormat, OutputSink};
|
||||||
|
use crate::stderr::MaschineStdErr;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
#[allow(unused_mut)]
|
#[allow(unused_mut)]
|
||||||
@ -139,6 +141,24 @@ fn main() {
|
|||||||
.default_value("0")
|
.default_value("0")
|
||||||
.value_parser(|s: &str| s.parse::<usize>().map_err(|e| e.to_string())),
|
.value_parser(|s: &str| s.parse::<usize>().map_err(|e| e.to_string())),
|
||||||
)
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::new("machine")
|
||||||
|
.help("Output for machines")
|
||||||
|
.short('m')
|
||||||
|
.long("machine")
|
||||||
|
.action(ArgAction::Set)
|
||||||
|
.default_value("0")
|
||||||
|
.value_parser(|s: &str| s.parse::<u16>().map_err(|e| e.to_string()))
|
||||||
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::new("limit")
|
||||||
|
.help("The maximum number of matches to return [0 = Unlimited]")
|
||||||
|
.short('l')
|
||||||
|
.long("limit")
|
||||||
|
.action(ArgAction::Set)
|
||||||
|
.default_value("50")
|
||||||
|
.value_parser(|s: &str| s.parse::<usize>().map_err(|e| e.to_string())),
|
||||||
|
)
|
||||||
.about("Searches for a pattern in a schematic")
|
.about("Searches for a pattern in a schematic")
|
||||||
.bin_name("schemsearch");
|
.bin_name("schemsearch");
|
||||||
|
|
||||||
@ -246,9 +266,14 @@ fn main() {
|
|||||||
|
|
||||||
ThreadPoolBuilder::new().num_threads(*matches.get_one::<usize>("threads").expect("Could not get threads")).build_global().unwrap();
|
ThreadPoolBuilder::new().num_threads(*matches.get_one::<usize>("threads").expect("Could not get threads")).build_global().unwrap();
|
||||||
|
|
||||||
let bar = ProgressBar::new(schematics.len() as u64);
|
let bar = ProgressBar::new(schematics.len() as u64); // "maschine"
|
||||||
bar.set_style(ProgressStyle::with_template("[{elapsed}, ETA: {eta}] {wide_bar} {pos}/{len} {per_sec}").unwrap());
|
bar.set_style(ProgressStyle::with_template("[{elapsed}, ETA: {eta}] {wide_bar} {pos}/{len} {per_sec}").unwrap());
|
||||||
bar.set_draw_target(ProgressDrawTarget::stderr_with_hz(5));
|
let term_size = *matches.get_one::<u16>("machine").expect("Could not get machine");
|
||||||
|
if term_size != 0 {
|
||||||
|
bar.set_draw_target(ProgressDrawTarget::term_like(Box::new(MaschineStdErr { size: term_size })))
|
||||||
|
}
|
||||||
|
|
||||||
|
let max_matching = *matches.get_one::<usize>("limit").expect("Could not get max-matching");
|
||||||
|
|
||||||
let matches: Vec<SearchResult> = schematics.par_iter().progress_with(bar).map(|schem| {
|
let matches: Vec<SearchResult> = schematics.par_iter().progress_with(bar).map(|schem| {
|
||||||
match schem {
|
match schem {
|
||||||
@ -286,13 +311,19 @@ fn main() {
|
|||||||
}
|
}
|
||||||
}).collect();
|
}).collect();
|
||||||
|
|
||||||
for matching in matches {
|
let mut matches_count = 0;
|
||||||
|
|
||||||
|
'outer: for matching in matches {
|
||||||
let schem_name = matching.name;
|
let schem_name = matching.name;
|
||||||
let matching = matching.matches;
|
let matching = matching.matches;
|
||||||
for x in matching {
|
for x in matching {
|
||||||
for out in &mut output {
|
for out in &mut output {
|
||||||
write!(out.1, "{}", out.0.found_match(&schem_name, x)).unwrap();
|
write!(out.1, "{}", out.0.found_match(&schem_name, x)).unwrap();
|
||||||
}
|
}
|
||||||
|
matches_count += 1;
|
||||||
|
if max_matching != 0 && matches_count >= max_matching {
|
||||||
|
break 'outer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,8 +49,8 @@ impl FromStr for OutputSink {
|
|||||||
impl OutputSink {
|
impl OutputSink {
|
||||||
pub fn output(&self) -> Box<dyn Write> {
|
pub fn output(&self) -> Box<dyn Write> {
|
||||||
match self {
|
match self {
|
||||||
OutputSink::Stdout => Box::new(std::io::stdout().lock()),
|
OutputSink::Stdout => Box::new(std::io::stdout()),
|
||||||
OutputSink::Stderr => Box::new(std::io::stderr().lock()),
|
OutputSink::Stderr => Box::new(std::io::stderr()),
|
||||||
OutputSink::File(path) => Box::new(BufWriter::new(File::create(path).unwrap()))
|
OutputSink::File(path) => Box::new(BufWriter::new(File::create(path).unwrap()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
44
schemsearch-cli/src/stderr.rs
Normale Datei
44
schemsearch-cli/src/stderr.rs
Normale Datei
@ -0,0 +1,44 @@
|
|||||||
|
use std::fmt::Debug;
|
||||||
|
use std::io::Write;
|
||||||
|
use indicatif::TermLike;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct MaschineStdErr { pub(crate) size: u16}
|
||||||
|
|
||||||
|
impl TermLike for MaschineStdErr {
|
||||||
|
fn width(&self) -> u16 {
|
||||||
|
self.size
|
||||||
|
}
|
||||||
|
|
||||||
|
fn move_cursor_up(&self, _: usize) -> std::io::Result<()> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn move_cursor_down(&self, _: usize) -> std::io::Result<()> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn move_cursor_right(&self, _: usize) -> std::io::Result<()> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn move_cursor_left(&self, _: usize) -> std::io::Result<()> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn write_line(&self, s: &str) -> std::io::Result<()> {
|
||||||
|
writeln!(std::io::stderr(), "{}", s)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn write_str(&self, s: &str) -> std::io::Result<()> {
|
||||||
|
write!(std::io::stderr(), "{}", s)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn clear_line(&self) -> std::io::Result<()> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn flush(&self) -> std::io::Result<()> {
|
||||||
|
std::io::stderr().flush()
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "schemsearch-files"
|
name = "schemsearch-files"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
@ -10,3 +10,5 @@ flate2 = "1.0.25"
|
|||||||
hematite-nbt = "0.5.2"
|
hematite-nbt = "0.5.2"
|
||||||
serde = "1.0.152"
|
serde = "1.0.152"
|
||||||
serde-this-or-that = "0.4.2"
|
serde-this-or-that = "0.4.2"
|
||||||
|
serde_repr = "0.1.12"
|
||||||
|
|
||||||
|
@ -21,18 +21,97 @@ use nbt::{Error, from_gzip_reader, Map, Value};
|
|||||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||||
use serde_this_or_that::as_i64;
|
use serde_this_or_that::as_i64;
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Clone, Serialize, Deserialize, Debug)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged, rename_all = "PascalCase")]
|
||||||
pub enum SchematicVersioned {
|
pub enum SchematicVersioned {
|
||||||
V1,
|
V1(SpongeV1Schematic),
|
||||||
V2(SpongeV2Schematic),
|
V2(SpongeV2Schematic),
|
||||||
V3(SpongeV3Schematic),
|
V3(SpongeV3Schematic),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
impl SchematicVersioned {
|
||||||
|
#[inline]
|
||||||
|
pub fn get_width(&self) -> u16 {
|
||||||
|
return match self {
|
||||||
|
SchematicVersioned::V1(schematic) => schematic.width,
|
||||||
|
SchematicVersioned::V2(schematic) => schematic.width,
|
||||||
|
SchematicVersioned::V3(schematic) => schematic.width,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn get_height(&self) -> u16 {
|
||||||
|
return match self {
|
||||||
|
SchematicVersioned::V1(schematic) => schematic.height,
|
||||||
|
SchematicVersioned::V2(schematic) => schematic.height,
|
||||||
|
SchematicVersioned::V3(schematic) => schematic.height,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn get_length(&self) -> u16 {
|
||||||
|
return match self {
|
||||||
|
SchematicVersioned::V1(schematic) => schematic.length,
|
||||||
|
SchematicVersioned::V2(schematic) => schematic.length,
|
||||||
|
SchematicVersioned::V3(schematic) => schematic.length,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn get_palette_max(&self) -> i32 {
|
||||||
|
return match self {
|
||||||
|
SchematicVersioned::V1(schematic) => schematic.palette_max,
|
||||||
|
SchematicVersioned::V2(schematic) => schematic.palette_max,
|
||||||
|
SchematicVersioned::V3(schematic) => schematic.blocks.palette.len() as i32,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn get_palette(&self) -> &Map<String, i32> {
|
||||||
|
return match self {
|
||||||
|
SchematicVersioned::V1(schematic) => &schematic.palette,
|
||||||
|
SchematicVersioned::V2(schematic) => &schematic.palette,
|
||||||
|
SchematicVersioned::V3(schematic) => &schematic.blocks.palette,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn get_block_data(&self) -> &Vec<i32> {
|
||||||
|
return match self {
|
||||||
|
SchematicVersioned::V1(schematic) => &schematic.block_data,
|
||||||
|
SchematicVersioned::V2(schematic) => &schematic.block_data,
|
||||||
|
SchematicVersioned::V3(schematic) => &schematic.blocks.block_data,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn get_block_entities(&self) -> &Vec<BlockEntity> {
|
||||||
|
return match self {
|
||||||
|
SchematicVersioned::V1(schematic) => &schematic.tile_entities,
|
||||||
|
SchematicVersioned::V2(schematic) => &schematic.block_entities,
|
||||||
|
SchematicVersioned::V3(schematic) => &schematic.blocks.block_entities,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Serialize, Deserialize, Debug)]
|
||||||
|
#[serde(rename_all = "PascalCase")]
|
||||||
|
pub struct SpongeV1Schematic {
|
||||||
|
pub metadata: Map<String, Value>,
|
||||||
|
pub width: u16,
|
||||||
|
pub height: u16,
|
||||||
|
pub length: u16,
|
||||||
|
pub offset: [i32; 3],
|
||||||
|
pub palette_max: i32,
|
||||||
|
pub palette: Map<String, i32>,
|
||||||
|
#[serde(deserialize_with = "read_blockdata")]
|
||||||
|
pub block_data: Vec<i32>,
|
||||||
|
pub tile_entities: Vec<BlockEntity>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Serialize, Deserialize, Debug)]
|
||||||
#[serde(rename_all = "PascalCase")]
|
#[serde(rename_all = "PascalCase")]
|
||||||
pub struct SpongeV2Schematic {
|
pub struct SpongeV2Schematic {
|
||||||
pub version: i32,
|
|
||||||
pub data_version: i32,
|
pub data_version: i32,
|
||||||
pub metadata: Map<String, Value>,
|
pub metadata: Map<String, Value>,
|
||||||
pub width: u16,
|
pub width: u16,
|
||||||
@ -47,7 +126,7 @@ pub struct SpongeV2Schematic {
|
|||||||
pub entities: Option<Vec<Entity>>,
|
pub entities: Option<Vec<Entity>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Clone, Serialize, Deserialize, Debug)]
|
||||||
#[serde(rename_all = "PascalCase")]
|
#[serde(rename_all = "PascalCase")]
|
||||||
pub struct SpongeV3Schematic {
|
pub struct SpongeV3Schematic {
|
||||||
pub data_version: i32,
|
pub data_version: i32,
|
||||||
@ -56,12 +135,17 @@ pub struct SpongeV3Schematic {
|
|||||||
pub height: u16,
|
pub height: u16,
|
||||||
pub length: u16,
|
pub length: u16,
|
||||||
pub offset: [i32; 3],
|
pub offset: [i32; 3],
|
||||||
pub palette_max: i32,
|
pub blocks: BlockContainer,
|
||||||
|
pub entities: Option<Vec<Entity>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Serialize, Deserialize, Debug)]
|
||||||
|
#[serde(rename_all = "PascalCase")]
|
||||||
|
pub struct BlockContainer {
|
||||||
pub palette: Map<String, i32>,
|
pub palette: Map<String, i32>,
|
||||||
#[serde(deserialize_with = "read_blockdata")]
|
#[serde(deserialize_with = "read_blockdata")]
|
||||||
pub block_data: Vec<i32>,
|
pub block_data: Vec<i32>,
|
||||||
pub block_entities: Vec<BlockEntity>,
|
pub block_entities: Vec<BlockEntity>,
|
||||||
pub entities: Option<Vec<Entity>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_blockdata<'de, D>(deserializer: D) -> Result<Vec<i32>, D::Error>
|
fn read_blockdata<'de, D>(deserializer: D) -> Result<Vec<i32>, D::Error>
|
||||||
@ -73,18 +157,24 @@ fn read_blockdata<'de, D>(deserializer: D) -> Result<Vec<i32>, D::Error>
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
|
#[serde(rename_all = "PascalCase")]
|
||||||
pub struct BlockEntity {
|
pub struct BlockEntity {
|
||||||
#[serde(rename = "Id")]
|
|
||||||
pub id: String,
|
pub id: String,
|
||||||
#[serde(rename = "Pos")]
|
|
||||||
pub pos: [i32; 3],
|
pub pos: [i32; 3],
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
pub struct Entity {
|
#[serde(rename_all = "PascalCase")]
|
||||||
#[serde(rename = "Id")]
|
pub struct BlockEntityV3 {
|
||||||
|
pub id: String,
|
||||||
|
pub pos: [i32; 3],
|
||||||
|
pub data: Map<String, Value>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
|
#[serde(rename_all = "PascalCase")]
|
||||||
|
pub struct Entity {
|
||||||
pub id: String,
|
pub id: String,
|
||||||
#[serde(rename = "Pos")]
|
|
||||||
pub pos: [i32; 3],
|
pub pos: [i32; 3],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "schemsearch-lib"
|
name = "schemsearch-lib"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
pub mod pattern_mapper;
|
pub mod pattern_mapper;
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use nbt::Map;
|
||||||
use pattern_mapper::match_palette;
|
use pattern_mapper::match_palette;
|
||||||
use schemsearch_files::{SchematicVersioned, SpongeV2Schematic};
|
use schemsearch_files::{SchematicVersioned, SpongeV2Schematic};
|
||||||
use schemsearch_files::SchematicVersioned::V2;
|
use schemsearch_files::SchematicVersioned::V2;
|
||||||
@ -38,19 +39,11 @@ pub fn search(
|
|||||||
pattern_schem: &SchematicVersioned,
|
pattern_schem: &SchematicVersioned,
|
||||||
search_behavior: SearchBehavior,
|
search_behavior: SearchBehavior,
|
||||||
) -> Vec<Match> {
|
) -> Vec<Match> {
|
||||||
let schem = match schem {
|
if schem.get_width() < pattern_schem.get_width() || schem.get_height() < pattern_schem.get_height() || schem.get_length() < pattern_schem.get_length() {
|
||||||
V2(x) => x,
|
|
||||||
_ => return vec![],
|
|
||||||
};
|
|
||||||
let pattern_schem = match pattern_schem {
|
|
||||||
V2(schem) => schem,
|
|
||||||
_ => return vec![],
|
|
||||||
};
|
|
||||||
if schem.width < pattern_schem.width || schem.height < pattern_schem.height || schem.length < pattern_schem.length {
|
|
||||||
return vec![];
|
return vec![];
|
||||||
}
|
}
|
||||||
|
|
||||||
if pattern_schem.palette.len() > schem.palette.len() {
|
if pattern_schem.get_palette().len() > schem.get_palette().len() {
|
||||||
return vec![];
|
return vec![];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,27 +51,27 @@ pub fn search(
|
|||||||
|
|
||||||
let mut matches: Vec<Match> = Vec::new();
|
let mut matches: Vec<Match> = Vec::new();
|
||||||
|
|
||||||
let pattern_data = pattern_schem.block_data.as_slice();
|
let pattern_data = pattern_schem.get_block_data().as_slice();
|
||||||
|
|
||||||
let schem_data = if search_behavior.ignore_block_data {
|
let schem_data = if search_behavior.ignore_block_data {
|
||||||
match_palette_adapt(&schem, &pattern_schem.palette, search_behavior.ignore_block_data)
|
match_palette_adapt(&schem, &pattern_schem.get_palette(), search_behavior.ignore_block_data)
|
||||||
} else {
|
} else {
|
||||||
schem.block_data
|
schem.get_block_data().clone()
|
||||||
};
|
};
|
||||||
|
|
||||||
let schem_data = schem_data.as_slice();
|
let schem_data = schem_data.as_slice();
|
||||||
|
|
||||||
let air_id = if search_behavior.ignore_air || search_behavior.air_as_any { pattern_schem.palette.get("minecraft:air").unwrap_or(&-1) } else { &-1};
|
let air_id = if search_behavior.ignore_air || search_behavior.air_as_any { pattern_schem.get_palette().get("minecraft:air").unwrap_or(&-1) } else { &-1};
|
||||||
|
|
||||||
let pattern_blocks = (pattern_schem.width * pattern_schem.height * pattern_schem.length) as f32;
|
let pattern_blocks = pattern_data.len() as f32;
|
||||||
|
|
||||||
let pattern_width = pattern_schem.width as usize;
|
let pattern_width = pattern_schem.get_width() as usize;
|
||||||
let pattern_height = pattern_schem.height as usize;
|
let pattern_height = pattern_schem.get_height() as usize;
|
||||||
let pattern_length = pattern_schem.length as usize;
|
let pattern_length = pattern_schem.get_length() as usize;
|
||||||
|
|
||||||
let schem_width = schem.width as usize;
|
let schem_width = schem.get_width() as usize;
|
||||||
let schem_height = schem.height as usize;
|
let schem_height = schem.get_height() as usize;
|
||||||
let schem_length = schem.length as usize;
|
let schem_length = schem.get_length() as usize;
|
||||||
|
|
||||||
for y in 0..=schem_height - pattern_height {
|
for y in 0..=schem_height - pattern_height {
|
||||||
for z in 0..=schem_length - pattern_length {
|
for z in 0..=schem_length - pattern_length {
|
||||||
@ -145,6 +138,7 @@ pub fn normalize_data(data: &str, ignore_data: bool) -> &str {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
use serde::de::Unexpected::Map;
|
||||||
use schemsearch_files::SpongeV2Schematic;
|
use schemsearch_files::SpongeV2Schematic;
|
||||||
use crate::pattern_mapper::strip_data;
|
use crate::pattern_mapper::strip_data;
|
||||||
use super::*;
|
use super::*;
|
||||||
@ -154,7 +148,7 @@ mod tests {
|
|||||||
let schematic = SchematicVersioned::load(&PathBuf::from("../tests/simple.schem")).unwrap();
|
let schematic = SchematicVersioned::load(&PathBuf::from("../tests/simple.schem")).unwrap();
|
||||||
|
|
||||||
let schematic = match schematic {
|
let schematic = match schematic {
|
||||||
V2(schem) => schem,
|
V2 (schematic) => schematic,
|
||||||
_ => panic!("Invalid schematic version"),
|
_ => panic!("Invalid schematic version"),
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -167,7 +161,7 @@ mod tests {
|
|||||||
let schematic: SchematicVersioned = SchematicVersioned::load(&PathBuf::from("../tests/simple.schem")).unwrap();
|
let schematic: SchematicVersioned = SchematicVersioned::load(&PathBuf::from("../tests/simple.schem")).unwrap();
|
||||||
|
|
||||||
let schematic = match schematic {
|
let schematic = match schematic {
|
||||||
V2(schem) => schem,
|
V2 (schematic) => schematic,
|
||||||
_ => panic!("Invalid schematic version"),
|
_ => panic!("Invalid schematic version"),
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -178,13 +172,9 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_strip_schem() {
|
fn test_strip_schem() {
|
||||||
let schematic = SchematicVersioned::load(&PathBuf::from("../tests/simple.schem")).unwrap();
|
let schematic = SchematicVersioned::load(&PathBuf::from("../tests/simple.schem")).unwrap();
|
||||||
let schematic = match schematic {
|
|
||||||
V2(schem) => schem,
|
|
||||||
_ => panic!("Invalid schematic version"),
|
|
||||||
};
|
|
||||||
let stripped = strip_data(&schematic);
|
let stripped = strip_data(&schematic);
|
||||||
|
|
||||||
assert_eq!(stripped.palette.keys().any(|k| k.contains('[')), false);
|
assert_eq!(stripped.get_palette().keys().any(|k| k.contains('[')), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -192,16 +182,6 @@ mod tests {
|
|||||||
let schematic = SchematicVersioned::load(&PathBuf::from("../tests/simple.schem")).unwrap();
|
let schematic = SchematicVersioned::load(&PathBuf::from("../tests/simple.schem")).unwrap();
|
||||||
let endstone = SchematicVersioned::load(&PathBuf::from("../tests/endstone.schem")).unwrap();
|
let endstone = SchematicVersioned::load(&PathBuf::from("../tests/endstone.schem")).unwrap();
|
||||||
|
|
||||||
let schematic = match schematic {
|
|
||||||
V2(schem) => schem,
|
|
||||||
_ => panic!("Invalid schematic version"),
|
|
||||||
};
|
|
||||||
|
|
||||||
let endstone = match endstone {
|
|
||||||
V2(schem) => schem,
|
|
||||||
_ => panic!("Invalid schematic version"),
|
|
||||||
};
|
|
||||||
|
|
||||||
let _ = match_palette(&schematic, &endstone, true);
|
let _ = match_palette(&schematic, &endstone, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,16 +190,6 @@ mod tests {
|
|||||||
let schematic = SchematicVersioned::load(&PathBuf::from("../tests/simple.schem")).unwrap();
|
let schematic = SchematicVersioned::load(&PathBuf::from("../tests/simple.schem")).unwrap();
|
||||||
let endstone = SchematicVersioned::load(&PathBuf::from("../tests/endstone.schem")).unwrap();
|
let endstone = SchematicVersioned::load(&PathBuf::from("../tests/endstone.schem")).unwrap();
|
||||||
|
|
||||||
let schematic = match schematic {
|
|
||||||
V2(schem) => schem,
|
|
||||||
_ => panic!("Invalid schematic version"),
|
|
||||||
};
|
|
||||||
|
|
||||||
let endstone = match endstone {
|
|
||||||
V2(schem) => schem,
|
|
||||||
_ => panic!("Invalid schematic version"),
|
|
||||||
};
|
|
||||||
|
|
||||||
let _ = match_palette(&schematic, &endstone, false);
|
let _ = match_palette(&schematic, &endstone, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,24 +248,25 @@ mod tests {
|
|||||||
assert_eq!(matches.len(), 1);
|
assert_eq!(matches.len(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
pub fn sezitest() {
|
pub fn testsezi() {
|
||||||
let schem = V2(SpongeV2Schematic {
|
let schematic = SchematicVersioned::V2(SpongeV2Schematic {
|
||||||
version: 2,
|
|
||||||
data_version: 0,
|
data_version: 0,
|
||||||
metadata: Default::default(),
|
metadata: nbt::Map::new(),
|
||||||
width: 0,
|
width: 16,
|
||||||
height: 0,
|
height: 16,
|
||||||
length: 0,
|
length: 16,
|
||||||
offset: [1, 2, 3],
|
offset: [0; 3],
|
||||||
palette_max: 0,
|
palette_max: 0,
|
||||||
palette: Default::default(),
|
palette: nbt::Map::new(),
|
||||||
block_data: vec![],
|
block_data: vec![],
|
||||||
|
entities: Some(vec![]),
|
||||||
block_entities: vec![],
|
block_entities: vec![],
|
||||||
entities: None,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
println!("{:?}", schem);
|
println!("{:?}", schematic);
|
||||||
println!("{}", serde_json::to_string_pretty(&schem).unwrap());
|
println!("{}", serde_json::to_string_pretty(&schematic).unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,26 +16,26 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
use nbt::Map;
|
use nbt::Map;
|
||||||
use schemsearch_files::SpongeV2Schematic;
|
use schemsearch_files::{SchematicVersioned, SpongeV2Schematic};
|
||||||
use crate::normalize_data;
|
use crate::normalize_data;
|
||||||
|
|
||||||
fn create_reverse_palette(schem: &SpongeV2Schematic) -> Vec<&str> {
|
fn create_reverse_palette(schem: &SchematicVersioned) -> Vec<&str> {
|
||||||
let mut reverse_palette = Vec::with_capacity(schem.palette_max as usize);
|
let mut reverse_palette = Vec::with_capacity(schem.get_palette_max() as usize);
|
||||||
(0..schem.palette_max).for_each(|_| reverse_palette.push(""));
|
(0..schem.get_palette_max()).for_each(|_| reverse_palette.push(""));
|
||||||
for (key, value) in schem.palette.iter() {
|
for (key, value) in schem.get_palette().iter() {
|
||||||
reverse_palette[*value as usize] = key;
|
reverse_palette[*value as usize] = key;
|
||||||
}
|
}
|
||||||
reverse_palette
|
reverse_palette
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn strip_data(schem: &SpongeV2Schematic) -> SpongeV2Schematic {
|
pub fn strip_data(schem: &SchematicVersioned) -> SchematicVersioned {
|
||||||
let mut data: Vec<i32> = Vec::new();
|
let mut data: Vec<i32> = Vec::new();
|
||||||
|
|
||||||
let mut palette: Map<String, i32> = Map::new();
|
let mut palette: Map<String, i32> = Map::new();
|
||||||
let mut palette_max: i32 = 0;
|
let mut palette_max: i32 = 0;
|
||||||
let reverse_palette = create_reverse_palette(schem);
|
let reverse_palette = create_reverse_palette(schem);
|
||||||
|
|
||||||
for block in schem.block_data.iter() {
|
for block in schem.get_block_data().iter() {
|
||||||
let block_name = reverse_palette[*block as usize].clone();
|
let block_name = reverse_palette[*block as usize].clone();
|
||||||
let block_name = block_name.split('[').next().unwrap().to_string();
|
let block_name = block_name.split('[').next().unwrap().to_string();
|
||||||
|
|
||||||
@ -47,27 +47,28 @@ pub fn strip_data(schem: &SpongeV2Schematic) -> SpongeV2Schematic {
|
|||||||
data.push(*entry);
|
data.push(*entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
SpongeV2Schematic {
|
SchematicVersioned::V2(SpongeV2Schematic {
|
||||||
version: schem.version,
|
data_version: 1,
|
||||||
data_version: schem.data_version,
|
|
||||||
palette,
|
palette,
|
||||||
palette_max,
|
palette_max,
|
||||||
block_data: data,
|
block_data: data,
|
||||||
block_entities: schem.block_entities.clone(),
|
block_entities: schem.get_block_entities().clone(),
|
||||||
height: schem.height,
|
height: schem.get_height(),
|
||||||
length: schem.length,
|
length: schem.get_length(),
|
||||||
width: schem.width,
|
width: schem.get_width(),
|
||||||
metadata: schem.metadata.clone(),
|
metadata: Map::new(),
|
||||||
offset: schem.offset.clone(),
|
offset: [0; 3],
|
||||||
entities: None,
|
entities: None,
|
||||||
}
|
},)
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn match_palette_adapt(schem: &SpongeV2Schematic, matching_palette: &Map<String, i32>, ignore_data: bool) -> Vec<i32> {
|
pub fn match_palette_adapt(schem: &SchematicVersioned, matching_palette: &Map<String, i32>, ignore_data: bool) -> Vec<i32> {
|
||||||
let mut data: Vec<i32> = Vec::new();
|
let mut data: Vec<i32> = Vec::new();
|
||||||
let reverse_palette = create_reverse_palette(schem);
|
let reverse_palette = create_reverse_palette(schem);
|
||||||
|
|
||||||
for x in &schem.block_data {
|
for x in schem.get_block_data() {
|
||||||
let blockname = reverse_palette[*x as usize];
|
let blockname = reverse_palette[*x as usize];
|
||||||
let blockname = if ignore_data { normalize_data(blockname, ignore_data) } else { blockname };
|
let blockname = if ignore_data { normalize_data(blockname, ignore_data) } else { blockname };
|
||||||
let block_id = match matching_palette.get(&*blockname) {
|
let block_id = match matching_palette.get(&*blockname) {
|
||||||
@ -81,10 +82,10 @@ pub fn match_palette_adapt(schem: &SpongeV2Schematic, matching_palette: &Map<Str
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn match_palette(
|
pub fn match_palette(
|
||||||
schem: &SpongeV2Schematic,
|
schem: &SchematicVersioned,
|
||||||
pattern: &SpongeV2Schematic,
|
pattern: &SchematicVersioned,
|
||||||
ignore_data: bool,
|
ignore_data: bool,
|
||||||
) -> SpongeV2Schematic {
|
) -> SchematicVersioned {
|
||||||
if ignore_data {
|
if ignore_data {
|
||||||
match_palette_internal(&strip_data(schem), &strip_data(pattern), ignore_data)
|
match_palette_internal(&strip_data(schem), &strip_data(pattern), ignore_data)
|
||||||
} else {
|
} else {
|
||||||
@ -93,24 +94,23 @@ pub fn match_palette(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn match_palette_internal(
|
fn match_palette_internal(
|
||||||
schem: &SpongeV2Schematic,
|
schem: &SchematicVersioned,
|
||||||
pattern: &SpongeV2Schematic,
|
pattern: &SchematicVersioned,
|
||||||
ignore_data: bool,
|
ignore_data: bool,
|
||||||
) -> SpongeV2Schematic {
|
) -> SchematicVersioned {
|
||||||
let data_pattern: Vec<i32> = match_palette_adapt(&pattern, &schem.palette, ignore_data);
|
let data_pattern: Vec<i32> = match_palette_adapt(&pattern, schem.get_palette(), ignore_data);
|
||||||
|
|
||||||
SpongeV2Schematic {
|
SchematicVersioned::V2(SpongeV2Schematic {
|
||||||
version: pattern.version.clone(),
|
data_version: 0,
|
||||||
data_version: pattern.data_version.clone(),
|
palette: schem.get_palette().clone(),
|
||||||
palette: schem.palette.clone(),
|
palette_max: schem.get_palette_max(),
|
||||||
palette_max: schem.palette_max,
|
|
||||||
block_data: data_pattern,
|
block_data: data_pattern,
|
||||||
block_entities: pattern.block_entities.clone(),
|
block_entities: pattern.get_block_entities().clone(),
|
||||||
height: pattern.height.clone(),
|
height: pattern.get_height(),
|
||||||
length: pattern.length.clone(),
|
length: pattern.get_length(),
|
||||||
width: pattern.width.clone(),
|
width: pattern.get_width(),
|
||||||
metadata: pattern.metadata.clone(),
|
metadata: Map::new(),
|
||||||
offset: pattern.offset.clone(),
|
offset: [0; 3],
|
||||||
entities: None,
|
entities: None,
|
||||||
}
|
})
|
||||||
}
|
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren