Fix rust 1.89 warns
This commit is contained in:
parent
9f94ce1d0d
commit
7e3a1c0972
@ -60,7 +60,7 @@ representative at an online or offline event.
|
|||||||
|
|
||||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||||
reported to the community leaders responsible for enforcement at
|
reported to the community leaders responsible for enforcement at
|
||||||
lilalexmed@proton.me.
|
<lilalexmed@proton.me>.
|
||||||
All complaints will be reviewed and investigated promptly and fairly.
|
All complaints will be reviewed and investigated promptly and fairly.
|
||||||
|
|
||||||
All community leaders are obligated to respect the privacy and security of the
|
All community leaders are obligated to respect the privacy and security of the
|
||||||
@ -116,7 +116,7 @@ the community.
|
|||||||
|
|
||||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||||
version 2.0, available at
|
version 2.0, available at
|
||||||
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
<https://www.contributor-covenant.org/version/2/0/code_of_conduct.html>.
|
||||||
|
|
||||||
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
||||||
enforcement ladder](https://github.com/mozilla/diversity).
|
enforcement ladder](https://github.com/mozilla/diversity).
|
||||||
@ -124,5 +124,5 @@ enforcement ladder](https://github.com/mozilla/diversity).
|
|||||||
[homepage]: https://www.contributor-covenant.org
|
[homepage]: https://www.contributor-covenant.org
|
||||||
|
|
||||||
For answers to common questions about this code of conduct, see the FAQ at
|
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/faq>. Translations are available at
|
||||||
https://www.contributor-covenant.org/translations.
|
<https://www.contributor-covenant.org/translations>.
|
||||||
|
|||||||
@ -47,10 +47,10 @@ Note: Pumpkin's clippy settings are relatively strict, this can be may frustrati
|
|||||||
- **No Clippy Warnings:** Address all warnings reported by the Clippy linter. You can check for warnings using `cargo clippy --all-targets`.
|
- **No Clippy Warnings:** Address all warnings reported by the Clippy linter. You can check for warnings using `cargo clippy --all-targets`.
|
||||||
- **Passing Unit Tests:** All existing unit tests must pass successfully. You can run the tests with `cargo test`.
|
- **Passing Unit Tests:** All existing unit tests must pass successfully. You can run the tests with `cargo test`.
|
||||||
|
|
||||||
**Best Practice**
|
#### Best Practice
|
||||||
|
|
||||||
- **Writing Unit Tests:** When adding new features or modifying existing code, consider adding unit tests to prevent regressions in the future. Refer to the Rust documentation for guidance on writing tests: https://doc.rust-lang.org/book/ch11-01-writing-tests.html
|
- **Writing Unit Tests:** When adding new features or modifying existing code, consider adding unit tests to prevent regressions in the future. Refer to the Rust documentation for guidance on writing tests: <https://doc.rust-lang.org/book/ch11-01-writing-tests.html>
|
||||||
- **Benchmarking:** If your changes might impact performance, consider adding benchmarks to track performance regressions or improvements. We use the Criterion library for benchmarking. Refer to their Quick Start guide for more information: https://github.com/bheisler/criterion.rs#quickstart
|
- **Benchmarking:** If your changes might impact performance, consider adding benchmarks to track performance regressions or improvements. We use the Criterion library for benchmarking. Refer to their Quick Start guide for more information: <https://github.com/bheisler/criterion.rs#quickstart>
|
||||||
- **Clear and Concise Commit Messages:** Use clear and concise commit messages that describe the changes you've made.
|
- **Clear and Concise Commit Messages:** Use clear and concise commit messages that describe the changes you've made.
|
||||||
- **Code Style:** Adhere to consistent coding style throughout your contributions.
|
- **Code Style:** Adhere to consistent coding style throughout your contributions.
|
||||||
- **Documentation:** If your changes introduce new functionality, consider updating the relevant documentation.
|
- **Documentation:** If your changes introduce new functionality, consider updating the relevant documentation.
|
||||||
|
|||||||
47
Cargo.lock
generated
47
Cargo.lock
generated
@ -419,7 +419,7 @@ version = "3.0.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fde0e0ec90c9dfb3b4b1a0891a7dcd0e2bffde2f7efed5fe7c9bb00e5bfb915e"
|
checksum = "fde0e0ec90c9dfb3b4b1a0891a7dcd0e2bffde2f7efed5fe7c9bb00e5bfb915e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -647,9 +647,9 @@ checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crypto-bigint"
|
name = "crypto-bigint"
|
||||||
version = "0.7.0-pre.7"
|
version = "0.7.0-rc.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "85ff38607b7ebe30e4715eeb0a0427ff42e3b6b47b2df55a775e767ef2658ccd"
|
checksum = "737a2363b81de8cc95d8780d84aecb4b3c6f41e4473759da6636072b5514c875"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"rand_core 0.9.3",
|
"rand_core 0.9.3",
|
||||||
@ -866,7 +866,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "778e2ac28f6c47af28e4907f13ffd1e1ddbd400980a9abd7c8df189bf578a5ad"
|
checksum = "778e2ac28f6c47af28e4907f13ffd1e1ddbd400980a9abd7c8df189bf578a5ad"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -1379,9 +1379,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "io-uring"
|
name = "io-uring"
|
||||||
version = "0.7.8"
|
version = "0.7.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b86e202f00093dcba4275d4636b93ef9dd75d025ae560d2521b45ea28ab49013"
|
checksum = "d93587f37623a1a17d94ef2bc9ada592f5465fe7732084ab7beefabe5c77c0c4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
@ -2362,9 +2362,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rsa"
|
name = "rsa"
|
||||||
version = "0.10.0-rc.3"
|
version = "0.10.0-rc.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7e8cb237ca3624409eda7d73de0d423815c9d91175ed5a62a8dd6549d2408cc2"
|
checksum = "b311b61ea276fd51ccb77f6995c5f70084db933bab9655ba51fe5d831ea25b39"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"const-oid",
|
"const-oid",
|
||||||
"crypto-bigint",
|
"crypto-bigint",
|
||||||
@ -2391,9 +2391,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc-demangle"
|
name = "rustc-demangle"
|
||||||
version = "0.1.25"
|
version = "0.1.26"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "989e6739f80c4ad5b13e0fd7fe89531180375b18520cc8c82080e4dc4035b84f"
|
checksum = "56f7d92ca342cea22a06f2121d944b4fd82af56988c270852495420f961d4ace"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc-hash"
|
name = "rustc-hash"
|
||||||
@ -2417,7 +2417,7 @@ dependencies = [
|
|||||||
"errno",
|
"errno",
|
||||||
"libc",
|
"libc",
|
||||||
"linux-raw-sys",
|
"linux-raw-sys",
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -2648,18 +2648,18 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "signal-hook-registry"
|
name = "signal-hook-registry"
|
||||||
version = "1.4.5"
|
version = "1.4.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9203b8055f63a2a00e2f593bb0510367fe707d7ff1e5c872de2f537b339e5410"
|
checksum = "b2a4719bff48cee6b39d12c020eeb490953ad2443b7055bd0b21fca26bd8c28b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "signature"
|
name = "signature"
|
||||||
version = "3.0.0-rc.1"
|
version = "3.0.0-rc.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b8852cecbd17ba45978bbbe43061ebe36a2ae376058c5c172e09f72888f8f7de"
|
checksum = "4835c3b5ecb10171941a4998a95a3a76ecac1c5ae8e6954f2ad030acd1c7e8ab"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"digest 0.11.0-rc.0",
|
"digest 0.11.0-rc.0",
|
||||||
"rand_core 0.9.3",
|
"rand_core 0.9.3",
|
||||||
@ -2804,7 +2804,7 @@ dependencies = [
|
|||||||
"fastrand",
|
"fastrand",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"rustix",
|
"rustix",
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -2916,9 +2916,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio"
|
name = "tokio"
|
||||||
version = "1.47.0"
|
version = "1.47.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "43864ed400b6043a4757a25c7a64a8efde741aed79a056a2fb348a406701bb35"
|
checksum = "89e49afdadebb872d3145a5638b59eb0691ea23e46ca484037cfab3b76b95038"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"backtrace",
|
"backtrace",
|
||||||
"bytes",
|
"bytes",
|
||||||
@ -2958,15 +2958,14 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio-util"
|
name = "tokio-util"
|
||||||
version = "0.7.15"
|
version = "0.7.16"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "66a539a9ad6d5d281510d5bd368c973d636c02dbf8a67300bfb6b950696ad7df"
|
checksum = "14307c986784f72ef81c89db7d9e28d6ac26d16213b109ea501696195e6e3ce5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytes",
|
"bytes",
|
||||||
"futures-core",
|
"futures-core",
|
||||||
"futures-sink",
|
"futures-sink",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"hashbrown 0.15.4",
|
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"tokio",
|
"tokio",
|
||||||
]
|
]
|
||||||
@ -3255,9 +3254,9 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "uuid"
|
name = "uuid"
|
||||||
version = "1.17.0"
|
version = "1.18.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3cf4199d1e5d15ddd86a694e4d0dffa9c323ce759fea589f00fef9d81cc1931d"
|
checksum = "f33196643e165781c20a5ead5582283a7dacbb87855d867fbc2df3f81eddc1be"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"getrandom 0.3.3",
|
"getrandom 0.3.3",
|
||||||
"js-sys",
|
"js-sys",
|
||||||
@ -3410,7 +3409,7 @@ version = "0.1.9"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
|
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|||||||
@ -51,7 +51,7 @@ futures = { version = "0.3", default-features = false, features = ["executor"] }
|
|||||||
rayon = "1.10"
|
rayon = "1.10"
|
||||||
crossbeam = "0.8"
|
crossbeam = "0.8"
|
||||||
|
|
||||||
uuid = { version = "1.17", features = ["serde", "v3", "v4"] }
|
uuid = { version = "1.18", features = ["serde", "v3", "v4"] }
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,6 @@
|
|||||||
[](https://opensource.org/licenses/MIT)
|
[](https://opensource.org/licenses/MIT)
|
||||||

|

|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
[Pumpkin](https://pumpkinmc.org/) is a Minecraft server built entirely in Rust, offering a fast, efficient,
|
[Pumpkin](https://pumpkinmc.org/) is a Minecraft server built entirely in Rust, offering a fast, efficient,
|
||||||
@ -113,7 +112,7 @@ Contributions are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md)
|
|||||||
|
|
||||||
## Docs
|
## Docs
|
||||||
|
|
||||||
Pumpkin's documentation can be found at https://pumpkinmc.org/
|
Pumpkin's documentation can be found at <https://pumpkinmc.org/>
|
||||||
|
|
||||||
## Communication
|
## Communication
|
||||||
|
|
||||||
|
|||||||
@ -83,8 +83,9 @@ pub fn send_cancellable(input: TokenStream) -> TokenStream {
|
|||||||
if let Stmt::Expr(expr, _) = stmt {
|
if let Stmt::Expr(expr, _) = stmt {
|
||||||
if event.is_none() {
|
if event.is_none() {
|
||||||
event = Some(expr);
|
event = Some(expr);
|
||||||
} else if let Expr::Block(b) = expr {
|
} else if let Expr::Block(b) = expr
|
||||||
if let Some(ref label) = b.label {
|
&& let Some(ref label) = b.label
|
||||||
|
{
|
||||||
if label.name.ident == "after" {
|
if label.name.ident == "after" {
|
||||||
after_block = Some(b);
|
after_block = Some(b);
|
||||||
} else if label.name.ident == "cancelled" {
|
} else if label.name.ident == "cancelled" {
|
||||||
@ -93,7 +94,6 @@ pub fn send_cancellable(input: TokenStream) -> TokenStream {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(event) = event {
|
if let Some(event) = event {
|
||||||
if let Some(after_block) = after_block {
|
if let Some(after_block) = after_block {
|
||||||
|
|||||||
@ -119,23 +119,21 @@ gen_from!(i16);
|
|||||||
gen_from!(u16);
|
gen_from!(u16);
|
||||||
gen_from!(u32);
|
gen_from!(u32);
|
||||||
|
|
||||||
macro_rules! gen_try_from {
|
macro_rules! gen_from {
|
||||||
($ty: ty) => {
|
($ty: ty) => {
|
||||||
impl TryFrom<$ty> for VarUInt {
|
impl From<$ty> for VarUInt {
|
||||||
type Error = <i32 as TryFrom<$ty>>::Error;
|
fn from(value: $ty) -> Self {
|
||||||
|
VarUInt(value as u32)
|
||||||
fn try_from(value: $ty) -> Result<Self, Self::Error> {
|
|
||||||
Ok(VarUInt(value as u32))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
gen_try_from!(i32);
|
gen_from!(i32);
|
||||||
gen_try_from!(i64);
|
gen_from!(i64);
|
||||||
gen_try_from!(u64);
|
gen_from!(u64);
|
||||||
gen_try_from!(isize);
|
gen_from!(isize);
|
||||||
gen_try_from!(usize);
|
gen_from!(usize);
|
||||||
|
|
||||||
impl Serialize for VarUInt {
|
impl Serialize for VarUInt {
|
||||||
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
|
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
|
||||||
|
|||||||
@ -339,13 +339,12 @@ impl<'de> serde::Deserialize<'de> for Vector3<i32> {
|
|||||||
self,
|
self,
|
||||||
mut seq: A,
|
mut seq: A,
|
||||||
) -> Result<Self::Value, A::Error> {
|
) -> Result<Self::Value, A::Error> {
|
||||||
if let Some(x) = seq.next_element::<i32>()? {
|
if let Some(x) = seq.next_element::<i32>()?
|
||||||
if let Some(y) = seq.next_element::<i32>()? {
|
&& let Some(y) = seq.next_element::<i32>()?
|
||||||
if let Some(z) = seq.next_element::<i32>()? {
|
&& let Some(z) = seq.next_element::<i32>()?
|
||||||
|
{
|
||||||
return Ok(Vector3::new(x, y, z));
|
return Ok(Vector3::new(x, y, z));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(serde::de::Error::custom("Failed to read Vector<i32>"))
|
Err(serde::de::Error::custom("Failed to read Vector<i32>"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -369,13 +368,12 @@ impl<'de> serde::Deserialize<'de> for Vector3<f32> {
|
|||||||
self,
|
self,
|
||||||
mut seq: A,
|
mut seq: A,
|
||||||
) -> Result<Self::Value, A::Error> {
|
) -> Result<Self::Value, A::Error> {
|
||||||
if let Some(x) = seq.next_element::<f32>()? {
|
if let Some(x) = seq.next_element::<f32>()?
|
||||||
if let Some(y) = seq.next_element::<f32>()? {
|
&& let Some(y) = seq.next_element::<f32>()?
|
||||||
if let Some(z) = seq.next_element::<f32>()? {
|
&& let Some(z) = seq.next_element::<f32>()?
|
||||||
|
{
|
||||||
return Ok(Vector3::new(x, y, z));
|
return Ok(Vector3::new(x, y, z));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(serde::de::Error::custom("Failed to read Vector<f32>"))
|
Err(serde::de::Error::custom("Failed to read Vector<f32>"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -399,13 +397,12 @@ impl<'de> serde::Deserialize<'de> for Vector3<f64> {
|
|||||||
self,
|
self,
|
||||||
mut seq: A,
|
mut seq: A,
|
||||||
) -> Result<Self::Value, A::Error> {
|
) -> Result<Self::Value, A::Error> {
|
||||||
if let Some(x) = seq.next_element::<f64>()? {
|
if let Some(x) = seq.next_element::<f64>()?
|
||||||
if let Some(y) = seq.next_element::<f64>()? {
|
&& let Some(y) = seq.next_element::<f64>()?
|
||||||
if let Some(z) = seq.next_element::<f64>()? {
|
&& let Some(z) = seq.next_element::<f64>()?
|
||||||
|
{
|
||||||
return Ok(Vector3::new(x, y, z));
|
return Ok(Vector3::new(x, y, z));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(serde::de::Error::custom("Failed to read Vector<f64>"))
|
Err(serde::de::Error::custom("Failed to read Vector<f64>"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -197,13 +197,13 @@ impl PermissionManager {
|
|||||||
|
|
||||||
// Check for inherited permissions from parent nodes
|
// Check for inherited permissions from parent nodes
|
||||||
for (node, value) in attachment.get_permissions() {
|
for (node, value) in attachment.get_permissions() {
|
||||||
if let Some(permission) = reg.get_permission(node) {
|
if let Some(permission) = reg.get_permission(node)
|
||||||
if permission.children.contains_key(permission_node) {
|
&& permission.children.contains_key(permission_node)
|
||||||
|
{
|
||||||
return *value && *permission.children.get(permission_node).unwrap();
|
return *value && *permission.children.get(permission_node).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Fall back to default permission value
|
// Fall back to default permission value
|
||||||
if let Some(permission) = reg.get_permission(permission_node) {
|
if let Some(permission) = reg.get_permission(permission_node) {
|
||||||
|
|||||||
@ -45,7 +45,7 @@ derive-getters = "0.5.0"
|
|||||||
thread_local = "1.1.9"
|
thread_local = "1.1.9"
|
||||||
lru = "0.16.0"
|
lru = "0.16.0"
|
||||||
|
|
||||||
tokio-util = { version = "0.7.15", features = ["rt"] }
|
tokio-util = { version = "0.7.16", features = ["rt"] }
|
||||||
rand = "0.9.2"
|
rand = "0.9.2"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
|||||||
@ -70,7 +70,7 @@ impl DropperBlockEntity {
|
|||||||
dirty: AtomicBool::new(false),
|
dirty: AtomicBool::new(false),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub async fn get_random_slot(&self) -> Option<MutexGuard<ItemStack>> {
|
pub async fn get_random_slot(&self) -> Option<MutexGuard<'_, ItemStack>> {
|
||||||
// this.unpackLootTable(null);
|
// this.unpackLootTable(null);
|
||||||
let mut ret = None;
|
let mut ret = None;
|
||||||
let mut j = 1;
|
let mut j = 1;
|
||||||
|
|||||||
@ -85,15 +85,13 @@ impl FurnaceBlockEntity {
|
|||||||
|
|
||||||
if let Some(recipe_output_item) =
|
if let Some(recipe_output_item) =
|
||||||
Item::from_registry_key(recipe.result.id.strip_prefix("minecraft:").unwrap())
|
Item::from_registry_key(recipe.result.id.strip_prefix("minecraft:").unwrap())
|
||||||
{
|
&& !is_top_items_empty
|
||||||
if !is_top_items_empty
|
|
||||||
&& recipe_output_item.id == side_item_stack.item.id
|
&& recipe_output_item.id == side_item_stack.item.id
|
||||||
&& side_item_stack.item_count < max_count
|
&& side_item_stack.item_count < max_count
|
||||||
&& side_item_stack.item_count < side_item_stack.get_max_stack_size()
|
&& side_item_stack.item_count < side_item_stack.get_max_stack_size()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -163,8 +163,9 @@ impl HopperBlockEntity {
|
|||||||
async fn suck_in_items(&self, world: &Arc<dyn SimpleWorld>) -> bool {
|
async fn suck_in_items(&self, world: &Arc<dyn SimpleWorld>) -> bool {
|
||||||
// TODO getEntityContainer
|
// TODO getEntityContainer
|
||||||
let pos_up = &self.position.up();
|
let pos_up = &self.position.up();
|
||||||
if let Some(entity) = world.get_block_entity(pos_up).await {
|
if let Some(entity) = world.get_block_entity(pos_up).await
|
||||||
if let Some(container) = entity.get_inventory() {
|
&& let Some(container) = entity.get_inventory()
|
||||||
|
{
|
||||||
// TODO check WorldlyContainer
|
// TODO check WorldlyContainer
|
||||||
for i in 0..container.size() {
|
for i in 0..container.size() {
|
||||||
let bind = container.get_stack(i).await;
|
let bind = container.get_stack(i).await;
|
||||||
@ -181,7 +182,6 @@ impl HopperBlockEntity {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
let (block, state) = world.get_block_and_state(pos_up).await;
|
let (block, state) = world.get_block_and_state(pos_up).await;
|
||||||
if !(state.is_solid()
|
if !(state.is_solid()
|
||||||
&& block
|
&& block
|
||||||
@ -200,8 +200,8 @@ impl HopperBlockEntity {
|
|||||||
if let Some(entity) = world
|
if let Some(entity) = world
|
||||||
.get_block_entity(&self.position.offset(to_offset(&self.facing)))
|
.get_block_entity(&self.position.offset(to_offset(&self.facing)))
|
||||||
.await
|
.await
|
||||||
|
&& let Some(container) = entity.get_inventory()
|
||||||
{
|
{
|
||||||
if let Some(container) = entity.get_inventory() {
|
|
||||||
// TODO check WorldlyContainer
|
// TODO check WorldlyContainer
|
||||||
let mut is_full = true;
|
let mut is_full = true;
|
||||||
for i in 0..container.size() {
|
for i in 0..container.size() {
|
||||||
@ -228,7 +228,6 @@ impl HopperBlockEntity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
pub async fn add_one_item(from: &dyn Inventory, to: &dyn Inventory, item: ItemStack) -> bool {
|
pub async fn add_one_item(from: &dyn Inventory, to: &dyn Inventory, item: ItemStack) -> bool {
|
||||||
@ -247,15 +246,14 @@ impl HopperBlockEntity {
|
|||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
if success {
|
if success {
|
||||||
if to_empty {
|
if to_empty
|
||||||
if let Some(hopper) = to.as_any().downcast_ref::<HopperBlockEntity>() {
|
&& let Some(hopper) = to.as_any().downcast_ref::<HopperBlockEntity>()
|
||||||
if hopper
|
&& hopper
|
||||||
.cooldown_time
|
.cooldown_time
|
||||||
.load(std::sync::atomic::Ordering::Relaxed)
|
.load(std::sync::atomic::Ordering::Relaxed)
|
||||||
<= 8
|
<= 8
|
||||||
{
|
{
|
||||||
if let Some(from_hopper) =
|
if let Some(from_hopper) = from.as_any().downcast_ref::<HopperBlockEntity>()
|
||||||
from.as_any().downcast_ref::<HopperBlockEntity>()
|
|
||||||
{
|
{
|
||||||
if from_hopper
|
if from_hopper
|
||||||
.cooldown_time
|
.cooldown_time
|
||||||
@ -278,8 +276,6 @@ impl HopperBlockEntity {
|
|||||||
.store(8, std::sync::atomic::Ordering::Relaxed);
|
.store(8, std::sync::atomic::Ordering::Relaxed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
to.mark_dirty();
|
to.mark_dirty();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,11 +28,11 @@ impl PlayerDataStorage {
|
|||||||
/// Creates a new `PlayerDataStorage` with the specified data path and cache expiration time.
|
/// Creates a new `PlayerDataStorage` with the specified data path and cache expiration time.
|
||||||
pub fn new(data_path: impl Into<PathBuf>) -> Self {
|
pub fn new(data_path: impl Into<PathBuf>) -> Self {
|
||||||
let path = data_path.into();
|
let path = data_path.into();
|
||||||
if !path.exists() {
|
if !path.exists()
|
||||||
if let Err(e) = create_dir_all(&path) {
|
&& let Err(e) = create_dir_all(&path)
|
||||||
|
{
|
||||||
log::error!("Failed to create player data directory at {path:?}: {e}");
|
log::error!("Failed to create player data directory at {path:?}: {e}");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
data_path: path,
|
data_path: path,
|
||||||
@ -126,12 +126,12 @@ impl PlayerDataStorage {
|
|||||||
let path = self.get_player_data_path(uuid);
|
let path = self.get_player_data_path(uuid);
|
||||||
|
|
||||||
// Ensure parent directory exists
|
// Ensure parent directory exists
|
||||||
if let Some(parent) = path.parent() {
|
if let Some(parent) = path.parent()
|
||||||
if let Err(e) = create_dir_all(parent) {
|
&& let Err(e) = create_dir_all(parent)
|
||||||
|
{
|
||||||
log::error!("Failed to create player data directory for {uuid}: {e}");
|
log::error!("Failed to create player data directory for {uuid}: {e}");
|
||||||
return Err(PlayerDataError::Io(e));
|
return Err(PlayerDataError::Io(e));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Create the file and write directly with GZip compression
|
// Create the file and write directly with GZip compression
|
||||||
match File::create(&path) {
|
match File::create(&path) {
|
||||||
|
|||||||
@ -63,11 +63,13 @@ pub trait Inventory: Send + Sync + Debug + Clearable {
|
|||||||
) {
|
) {
|
||||||
if let Some(inventory_list) = nbt.get_list("Items") {
|
if let Some(inventory_list) = nbt.get_list("Items") {
|
||||||
for tag in inventory_list {
|
for tag in inventory_list {
|
||||||
if let Some(item_compound) = tag.extract_compound() {
|
if let Some(item_compound) = tag.extract_compound()
|
||||||
if let Some(slot_byte) = item_compound.get_byte("Slot") {
|
&& let Some(slot_byte) = item_compound.get_byte("Slot")
|
||||||
|
{
|
||||||
let slot = slot_byte as usize;
|
let slot = slot_byte as usize;
|
||||||
if slot < stacks.len() {
|
if slot < stacks.len()
|
||||||
if let Some(item_stack) = ItemStack::read_item_stack(item_compound) {
|
&& let Some(item_stack) = ItemStack::read_item_stack(item_compound)
|
||||||
|
{
|
||||||
// This won't error cause it's only called on initialization
|
// This won't error cause it's only called on initialization
|
||||||
*stacks[slot].try_lock().unwrap() = item_stack;
|
*stacks[slot].try_lock().unwrap() = item_stack;
|
||||||
}
|
}
|
||||||
@ -75,8 +77,6 @@ pub trait Inventory: Send + Sync + Debug + Clearable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
boolean canPlayerUse(PlayerEntity player);
|
boolean canPlayerUse(PlayerEntity player);
|
||||||
|
|||||||
@ -50,7 +50,7 @@ num-bigint = "0.4"
|
|||||||
rustyline-async = "0.4.7"
|
rustyline-async = "0.4.7"
|
||||||
|
|
||||||
# encryption
|
# encryption
|
||||||
rsa = { version = "=0.10.0-rc.3", features = ["sha1"] }
|
rsa = { version = "=0.10.0-rc.4", features = ["sha1"] }
|
||||||
rsa-der = "0.3"
|
rsa-der = "0.3"
|
||||||
|
|
||||||
# authentication
|
# authentication
|
||||||
@ -77,7 +77,7 @@ libloading = "0.8"
|
|||||||
rustc-hash = "2.1.1"
|
rustc-hash = "2.1.1"
|
||||||
|
|
||||||
# Task handling
|
# Task handling
|
||||||
tokio-util = { version = "0.7.15", features = ["rt"] }
|
tokio-util = { version = "0.7.16", features = ["rt"] }
|
||||||
|
|
||||||
# Memory profiling
|
# Memory profiling
|
||||||
dhat = { version = "0.3.3", optional = true }
|
dhat = { version = "0.3.3", optional = true }
|
||||||
|
|||||||
@ -27,15 +27,15 @@ pub struct CandleBlock;
|
|||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl BlockBehaviour for CandleBlock {
|
impl BlockBehaviour for CandleBlock {
|
||||||
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
||||||
if args.player.get_entity().pose.load() != EntityPose::Crouching {
|
if args.player.get_entity().pose.load() != EntityPose::Crouching
|
||||||
if let BlockIsReplacing::Itself(state_id) = args.replacing {
|
&& let BlockIsReplacing::Itself(state_id) = args.replacing
|
||||||
|
{
|
||||||
let mut properties = CandleLikeProperties::from_state_id(state_id, args.block);
|
let mut properties = CandleLikeProperties::from_state_id(state_id, args.block);
|
||||||
if properties.candles.to_index() < 3 {
|
if properties.candles.to_index() < 3 {
|
||||||
properties.candles = Integer1To4::from_index(properties.candles.to_index() + 1);
|
properties.candles = Integer1To4::from_index(properties.candles.to_index() + 1);
|
||||||
}
|
}
|
||||||
return properties.to_state_id(args.block);
|
return properties.to_state_id(args.block);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
let mut properties = CandleLikeProperties::default(args.block);
|
let mut properties = CandleLikeProperties::default(args.block);
|
||||||
properties.waterlogged = args.replacing.water_source();
|
properties.waterlogged = args.replacing.water_source();
|
||||||
|
|||||||
@ -48,8 +48,8 @@ impl BlockBehaviour for ChiseledBookshelfBlock {
|
|||||||
|
|
||||||
if let Some(slot) = Self::get_slot_for_hit(args.hit, properties.facing) {
|
if let Some(slot) = Self::get_slot_for_hit(args.hit, properties.facing) {
|
||||||
if Self::is_slot_used(properties, slot) {
|
if Self::is_slot_used(properties, slot) {
|
||||||
if let Some(block_entity) = args.world.get_block_entity(args.position).await {
|
if let Some(block_entity) = args.world.get_block_entity(args.position).await
|
||||||
if let Some(block_entity) = block_entity
|
&& let Some(block_entity) = block_entity
|
||||||
.as_any()
|
.as_any()
|
||||||
.downcast_ref::<ChiseledBookshelfBlockEntity>()
|
.downcast_ref::<ChiseledBookshelfBlockEntity>()
|
||||||
{
|
{
|
||||||
@ -64,7 +64,6 @@ impl BlockBehaviour for ChiseledBookshelfBlock {
|
|||||||
.await;
|
.await;
|
||||||
return BlockActionResult::Success;
|
return BlockActionResult::Success;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return BlockActionResult::Consume;
|
return BlockActionResult::Consume;
|
||||||
}
|
}
|
||||||
@ -88,8 +87,8 @@ impl BlockBehaviour for ChiseledBookshelfBlock {
|
|||||||
if let Some(slot) = Self::get_slot_for_hit(args.hit, properties.facing) {
|
if let Some(slot) = Self::get_slot_for_hit(args.hit, properties.facing) {
|
||||||
if Self::is_slot_used(properties, slot) {
|
if Self::is_slot_used(properties, slot) {
|
||||||
return BlockActionResult::PassToDefaultBlockAction;
|
return BlockActionResult::PassToDefaultBlockAction;
|
||||||
} else if let Some(block_entity) = args.world.get_block_entity(args.position).await {
|
} else if let Some(block_entity) = args.world.get_block_entity(args.position).await
|
||||||
if let Some(block_entity) = block_entity
|
&& let Some(block_entity) = block_entity
|
||||||
.as_any()
|
.as_any()
|
||||||
.downcast_ref::<ChiseledBookshelfBlockEntity>()
|
.downcast_ref::<ChiseledBookshelfBlockEntity>()
|
||||||
{
|
{
|
||||||
@ -106,7 +105,6 @@ impl BlockBehaviour for ChiseledBookshelfBlock {
|
|||||||
return BlockActionResult::Success;
|
return BlockActionResult::Success;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
BlockActionResult::Pass
|
BlockActionResult::Pass
|
||||||
}
|
}
|
||||||
@ -117,14 +115,13 @@ impl BlockBehaviour for ChiseledBookshelfBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn get_comparator_output(&self, args: GetComparatorOutputArgs<'_>) -> Option<u8> {
|
async fn get_comparator_output(&self, args: GetComparatorOutputArgs<'_>) -> Option<u8> {
|
||||||
if let Some(block_entity) = args.world.get_block_entity(args.position).await {
|
if let Some(block_entity) = args.world.get_block_entity(args.position).await
|
||||||
if let Some(block_entity) = block_entity
|
&& let Some(block_entity) = block_entity
|
||||||
.as_any()
|
.as_any()
|
||||||
.downcast_ref::<ChiseledBookshelfBlockEntity>()
|
.downcast_ref::<ChiseledBookshelfBlockEntity>()
|
||||||
{
|
{
|
||||||
return Some((block_entity.last_interacted_slot.load(Ordering::Relaxed) + 1) as u8);
|
return Some((block_entity.last_interacted_slot.load(Ordering::Relaxed) + 1) as u8);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -74,20 +74,20 @@ impl BlockBehaviour for CommandBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn on_scheduled_tick(&self, args: OnScheduledTickArgs<'_>) {
|
async fn on_scheduled_tick(&self, args: OnScheduledTickArgs<'_>) {
|
||||||
if let Some(block_entity) = args.world.get_block_entity(args.position).await {
|
if let Some(block_entity) = args.world.get_block_entity(args.position).await
|
||||||
if block_entity.resource_location() != CommandBlockEntity::ID {
|
&& block_entity.resource_location() != CommandBlockEntity::ID
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
||||||
if let Some(player) = args.player {
|
if let Some(player) = args.player
|
||||||
if player.gamemode.load() == GameMode::Creative {
|
&& player.gamemode.load() == GameMode::Creative
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|||||||
@ -50,25 +50,17 @@ impl BlockBehaviour for ComposterBlock {
|
|||||||
self.clear_composter(args.world, args.position, state_id, args.block)
|
self.clear_composter(args.world, args.position, state_id, args.block)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
if level < 7 {
|
if level < 7
|
||||||
if let Some(chance) =
|
&& let Some(chance) =
|
||||||
get_composter_increase_chance_from_item_id(args.item_stack.lock().await.item.id)
|
get_composter_increase_chance_from_item_id(args.item_stack.lock().await.item.id)
|
||||||
|
&& (level == 0 || rand::rng().random_bool(f64::from(chance)))
|
||||||
{
|
{
|
||||||
if level == 0 || rand::rng().random_bool(f64::from(chance)) {
|
self.update_level_composter(args.world, args.position, state_id, args.block, level + 1)
|
||||||
self.update_level_composter(
|
|
||||||
args.world,
|
|
||||||
args.position,
|
|
||||||
state_id,
|
|
||||||
args.block,
|
|
||||||
level + 1,
|
|
||||||
)
|
|
||||||
.await;
|
.await;
|
||||||
args.world
|
args.world
|
||||||
.sync_world_event(WorldEvent::ComposterUsed, *args.position, 1)
|
.sync_world_event(WorldEvent::ComposterUsed, *args.position, 1)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
BlockActionResult::Consume
|
BlockActionResult::Consume
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -175,16 +175,14 @@ impl BlockBehaviour for FireBlock {
|
|||||||
|
|
||||||
let dimension = args.world.dimension_type;
|
let dimension = args.world.dimension_type;
|
||||||
// First lets check if we are in OverWorld or Nether, its not possible to place an Nether portal in other dimensions in Vanilla
|
// First lets check if we are in OverWorld or Nether, its not possible to place an Nether portal in other dimensions in Vanilla
|
||||||
if dimension == VanillaDimensionType::Overworld
|
if (dimension == VanillaDimensionType::Overworld
|
||||||
|| dimension == VanillaDimensionType::TheNether
|
|| dimension == VanillaDimensionType::TheNether)
|
||||||
{
|
&& let Some(portal) =
|
||||||
if let Some(portal) =
|
|
||||||
NetherPortal::get_new_portal(args.world, args.position, HorizontalAxis::X).await
|
NetherPortal::get_new_portal(args.world, args.position, HorizontalAxis::X).await
|
||||||
{
|
{
|
||||||
portal.create(args.world).await;
|
portal.create(args.world).await;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
args.world
|
args.world
|
||||||
.schedule_block_tick(
|
.schedule_block_tick(
|
||||||
|
|||||||
@ -61,14 +61,14 @@ impl BlockBehaviour for FurnaceBlock {
|
|||||||
&self,
|
&self,
|
||||||
args: crate::block::NormalUseArgs<'_>,
|
args: crate::block::NormalUseArgs<'_>,
|
||||||
) -> crate::block::registry::BlockActionResult {
|
) -> crate::block::registry::BlockActionResult {
|
||||||
if let Some(block_entity) = args.world.get_block_entity(args.position).await {
|
if let Some(block_entity) = args.world.get_block_entity(args.position).await
|
||||||
if let Some(inventory) = block_entity.clone().get_inventory() {
|
&& let Some(inventory) = block_entity.clone().get_inventory()
|
||||||
|
{
|
||||||
let furnace_screen_factory = FurnaceScreenFactory::new(inventory, block_entity);
|
let furnace_screen_factory = FurnaceScreenFactory::new(inventory, block_entity);
|
||||||
args.player
|
args.player
|
||||||
.open_handled_screen(&furnace_screen_factory)
|
.open_handled_screen(&furnace_screen_factory)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
crate::block::registry::BlockActionResult::Consume
|
crate::block::registry::BlockActionResult::Consume
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -52,13 +52,13 @@ type HopperLikeProperties = pumpkin_data::block_properties::HopperLikeProperties
|
|||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl BlockBehaviour for HopperBlock {
|
impl BlockBehaviour for HopperBlock {
|
||||||
async fn normal_use(&self, args: NormalUseArgs<'_>) -> BlockActionResult {
|
async fn normal_use(&self, args: NormalUseArgs<'_>) -> BlockActionResult {
|
||||||
if let Some(block_entity) = args.world.get_block_entity(args.position).await {
|
if let Some(block_entity) = args.world.get_block_entity(args.position).await
|
||||||
if let Some(inventory) = block_entity.get_inventory() {
|
&& let Some(inventory) = block_entity.get_inventory()
|
||||||
|
{
|
||||||
args.player
|
args.player
|
||||||
.open_handled_screen(&HopperBlockScreenFactory(inventory))
|
.open_handled_screen(&HopperBlockScreenFactory(inventory))
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
BlockActionResult::Success
|
BlockActionResult::Success
|
||||||
}
|
}
|
||||||
|
|||||||
@ -200,15 +200,15 @@ impl BlockBehaviour for PistonBlock {
|
|||||||
let pos = pos.offset_dir(dir.to_offset(), 2);
|
let pos = pos.offset_dir(dir.to_offset(), 2);
|
||||||
let (block, state) = world.get_block_and_state(&pos).await;
|
let (block, state) = world.get_block_and_state(&pos).await;
|
||||||
let mut bl2 = false;
|
let mut bl2 = false;
|
||||||
if block == &Block::MOVING_PISTON {
|
if block == &Block::MOVING_PISTON
|
||||||
if let Some(entity) = world.get_block_entity(&pos).await {
|
&& let Some(entity) = world.get_block_entity(&pos).await
|
||||||
|
{
|
||||||
let piston = entity.as_any().downcast_ref::<PistonBlockEntity>().unwrap();
|
let piston = entity.as_any().downcast_ref::<PistonBlockEntity>().unwrap();
|
||||||
if piston.facing == dir && piston.extending {
|
if piston.facing == dir && piston.extending {
|
||||||
piston.finish(world.clone()).await;
|
piston.finish(world.clone()).await;
|
||||||
bl2 = true;
|
bl2 = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if !bl2 {
|
if !bl2 {
|
||||||
if r#type == 1
|
if r#type == 1
|
||||||
&& !state.is_air()
|
&& !state.is_air()
|
||||||
@ -295,8 +295,9 @@ async fn try_move(world: &Arc<World>, block: &Block, block_pos: &BlockPos) {
|
|||||||
|
|
||||||
if new_block == &Block::MOVING_PISTON {
|
if new_block == &Block::MOVING_PISTON {
|
||||||
let new_props = MovingPistonLikeProperties::from_state_id(new_state, new_block);
|
let new_props = MovingPistonLikeProperties::from_state_id(new_state, new_block);
|
||||||
if new_props.facing == props.facing {
|
if new_props.facing == props.facing
|
||||||
if let Some(entity) = world.get_block_entity(&new_pos).await {
|
&& let Some(entity) = world.get_block_entity(&new_pos).await
|
||||||
|
{
|
||||||
let piston = entity.as_any().downcast_ref::<PistonBlockEntity>().unwrap();
|
let piston = entity.as_any().downcast_ref::<PistonBlockEntity>().unwrap();
|
||||||
if piston.extending && piston.current_progress.load() < 0.5
|
if piston.extending && piston.current_progress.load() < 0.5
|
||||||
// TODO: more stuff...
|
// TODO: more stuff...
|
||||||
@ -306,7 +307,6 @@ async fn try_move(world: &Arc<World>, block: &Block, block_pos: &BlockPos) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
world
|
world
|
||||||
.add_synced_block_event(*block_pos, r#type, dir.to_index())
|
.add_synced_block_event(*block_pos, r#type, dir.to_index())
|
||||||
.await;
|
.await;
|
||||||
|
|||||||
@ -107,8 +107,9 @@ impl BlockBehaviour for SeaPickleBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
||||||
if args.player.get_entity().pose.load() != EntityPose::Crouching {
|
if args.player.get_entity().pose.load() != EntityPose::Crouching
|
||||||
if let BlockIsReplacing::Itself(state_id) = args.replacing {
|
&& let BlockIsReplacing::Itself(state_id) = args.replacing
|
||||||
|
{
|
||||||
let mut sea_pickle_prop = SeaPickleProperties::from_state_id(state_id, args.block);
|
let mut sea_pickle_prop = SeaPickleProperties::from_state_id(state_id, args.block);
|
||||||
if sea_pickle_prop.pickles != Integer1To4::L4 {
|
if sea_pickle_prop.pickles != Integer1To4::L4 {
|
||||||
sea_pickle_prop.pickles = match sea_pickle_prop.pickles {
|
sea_pickle_prop.pickles = match sea_pickle_prop.pickles {
|
||||||
@ -119,7 +120,6 @@ impl BlockBehaviour for SeaPickleBlock {
|
|||||||
}
|
}
|
||||||
return sea_pickle_prop.to_state_id(args.block);
|
return sea_pickle_prop.to_state_id(args.block);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
let mut sea_pickle_prop = SeaPickleProperties::default(args.block);
|
let mut sea_pickle_prop = SeaPickleProperties::default(args.block);
|
||||||
sea_pickle_prop.waterlogged = args.replacing.water_source();
|
sea_pickle_prop.waterlogged = args.replacing.water_source();
|
||||||
|
|||||||
@ -136,15 +136,15 @@ impl RedstoneGateBlockProperties for ComparatorLikeProperties {
|
|||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl RedstoneGateBlock<ComparatorLikeProperties> for ComparatorBlock {
|
impl RedstoneGateBlock<ComparatorLikeProperties> for ComparatorBlock {
|
||||||
async fn get_output_level(&self, world: &World, pos: BlockPos) -> u8 {
|
async fn get_output_level(&self, world: &World, pos: BlockPos) -> u8 {
|
||||||
if let Some(blockentity) = world.get_block_entity(&pos).await {
|
if let Some(blockentity) = world.get_block_entity(&pos).await
|
||||||
if blockentity.resource_location() == ComparatorBlockEntity::ID {
|
&& blockentity.resource_location() == ComparatorBlockEntity::ID
|
||||||
|
{
|
||||||
let comparator = blockentity
|
let comparator = blockentity
|
||||||
.as_any()
|
.as_any()
|
||||||
.downcast_ref::<ComparatorBlockEntity>()
|
.downcast_ref::<ComparatorBlockEntity>()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
return comparator.output_signal.load(Ordering::Relaxed);
|
return comparator.output_signal.load(Ordering::Relaxed);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,8 +219,8 @@ impl RedstoneGateBlock<ComparatorLikeProperties> for ComparatorBlock {
|
|||||||
let source_pos = pos.offset(facing.to_offset());
|
let source_pos = pos.offset(facing.to_offset());
|
||||||
let (source_block, source_state) = world.get_block_and_state(&source_pos).await;
|
let (source_block, source_state) = world.get_block_and_state(&source_pos).await;
|
||||||
|
|
||||||
if let Some(pumpkin_block) = world.block_registry.get_pumpkin_block(source_block) {
|
if let Some(pumpkin_block) = world.block_registry.get_pumpkin_block(source_block)
|
||||||
if let Some(level) = pumpkin_block
|
&& let Some(level) = pumpkin_block
|
||||||
.get_comparator_output(GetComparatorOutputArgs {
|
.get_comparator_output(GetComparatorOutputArgs {
|
||||||
world,
|
world,
|
||||||
block: source_block,
|
block: source_block,
|
||||||
@ -231,7 +231,6 @@ impl RedstoneGateBlock<ComparatorLikeProperties> for ComparatorBlock {
|
|||||||
{
|
{
|
||||||
return level;
|
return level;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if redstone_level < 15 && source_state.is_solid() {
|
if redstone_level < 15 && source_state.is_solid() {
|
||||||
let source_pos = source_pos.offset(facing.to_offset());
|
let source_pos = source_pos.offset(facing.to_offset());
|
||||||
@ -322,20 +321,21 @@ impl ComparatorBlock {
|
|||||||
entity.get_entity().entity_type == &EntityType::ITEM_FRAME
|
entity.get_entity().entity_type == &EntityType::ITEM_FRAME
|
||||||
&& entity.get_entity().get_horizontal_facing() == facing
|
&& entity.get_entity().get_horizontal_facing() == facing
|
||||||
});
|
});
|
||||||
if let Some(_itemframe) = itemframes.next() {
|
if let Some(_itemframe) = itemframes.next()
|
||||||
if itemframes.next().is_none() {
|
&& itemframes.next().is_none()
|
||||||
|
{
|
||||||
// TODO itemframe.getComparatorPower()
|
// TODO itemframe.getComparatorPower()
|
||||||
return Some(1);
|
return Some(1);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn update(&self, world: &Arc<World>, pos: BlockPos, state: &BlockState, block: &Block) {
|
async fn update(&self, world: &Arc<World>, pos: BlockPos, state: &BlockState, block: &Block) {
|
||||||
let future_level = i32::from(self.calculate_output_signal(world, pos, state, block).await);
|
let future_level = i32::from(self.calculate_output_signal(world, pos, state, block).await);
|
||||||
let mut now_level = 0;
|
let mut now_level = 0;
|
||||||
if let Some(blockentity) = world.get_block_entity(&pos).await {
|
if let Some(blockentity) = world.get_block_entity(&pos).await
|
||||||
if blockentity.resource_location() == ComparatorBlockEntity::ID {
|
&& blockentity.resource_location() == ComparatorBlockEntity::ID
|
||||||
|
{
|
||||||
let comparator = blockentity
|
let comparator = blockentity
|
||||||
.as_any()
|
.as_any()
|
||||||
.downcast_ref::<ComparatorBlockEntity>()
|
.downcast_ref::<ComparatorBlockEntity>()
|
||||||
@ -345,7 +345,6 @@ impl ComparatorBlock {
|
|||||||
.output_signal
|
.output_signal
|
||||||
.store(future_level as u8, Ordering::Relaxed);
|
.store(future_level as u8, Ordering::Relaxed);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
let mut props = ComparatorLikeProperties::from_state_id(state.id, block);
|
let mut props = ComparatorLikeProperties::from_state_id(state.id, block);
|
||||||
if now_level != future_level || props.mode == ComparatorMode::Compare {
|
if now_level != future_level || props.mode == ComparatorMode::Compare {
|
||||||
let future_power = self.has_power(world, pos, state, block).await;
|
let future_power = self.has_power(world, pos, state, block).await;
|
||||||
|
|||||||
@ -84,13 +84,13 @@ const fn to_data3d(facing: Facing) -> i32 {
|
|||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl BlockBehaviour for DropperBlock {
|
impl BlockBehaviour for DropperBlock {
|
||||||
async fn normal_use(&self, args: NormalUseArgs<'_>) -> BlockActionResult {
|
async fn normal_use(&self, args: NormalUseArgs<'_>) -> BlockActionResult {
|
||||||
if let Some(block_entity) = args.world.get_block_entity(args.position).await {
|
if let Some(block_entity) = args.world.get_block_entity(args.position).await
|
||||||
if let Some(inventory) = block_entity.get_inventory() {
|
&& let Some(inventory) = block_entity.get_inventory()
|
||||||
|
{
|
||||||
args.player
|
args.player
|
||||||
.open_handled_screen(&DropperScreenFactory(inventory))
|
.open_handled_screen(&DropperScreenFactory(inventory))
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
BlockActionResult::Success
|
BlockActionResult::Success
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,8 +157,8 @@ impl BlockBehaviour for DropperBlock {
|
|||||||
.offset(props.facing.to_block_direction().to_offset()),
|
.offset(props.facing.to_block_direction().to_offset()),
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
&& let Some(container) = entity.get_inventory()
|
||||||
{
|
{
|
||||||
if let Some(container) = entity.get_inventory() {
|
|
||||||
// TODO check WorldlyContainer
|
// TODO check WorldlyContainer
|
||||||
let mut is_full = true;
|
let mut is_full = true;
|
||||||
for i in 0..container.size() {
|
for i in 0..container.size() {
|
||||||
@ -175,15 +175,13 @@ impl BlockBehaviour for DropperBlock {
|
|||||||
//TODO WorldlyContainer
|
//TODO WorldlyContainer
|
||||||
let backup = item.clone();
|
let backup = item.clone();
|
||||||
let one_item = item.split(1);
|
let one_item = item.split(1);
|
||||||
if HopperBlockEntity::add_one_item(dropper, container.as_ref(), one_item)
|
if HopperBlockEntity::add_one_item(dropper, container.as_ref(), one_item).await
|
||||||
.await
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
*item = backup;
|
*item = backup;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
let drop_item = item.split(1);
|
let drop_item = item.split(1);
|
||||||
let facing = to_normal(props.facing);
|
let facing = to_normal(props.facing);
|
||||||
let mut position = args.position.to_centered_f64().add(&(facing * 0.7));
|
let mut position = args.position.to_centered_f64().add(&(facing * 0.7));
|
||||||
|
|||||||
@ -29,11 +29,11 @@ pub(super) async fn rail_placement_is_valid(world: &World, block: &Block, pos: &
|
|||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(direction) = rail_leaning_direction {
|
if let Some(direction) = rail_leaning_direction
|
||||||
if !can_place_rail_at(world, &pos.offset(direction.to_offset()).up()).await {
|
&& !can_place_rail_at(world, &pos.offset(direction.to_offset()).up()).await
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|||||||
@ -108,30 +108,26 @@ async fn compute_stair_shape(
|
|||||||
|
|
||||||
if let Some(other_stair_props) =
|
if let Some(other_stair_props) =
|
||||||
get_stair_properties_if_exists(world, &block_pos.offset(facing.to_offset())).await
|
get_stair_properties_if_exists(world, &block_pos.offset(facing.to_offset())).await
|
||||||
|
&& other_stair_props.half == half
|
||||||
{
|
{
|
||||||
if other_stair_props.half == half {
|
|
||||||
if !left_locked && other_stair_props.facing == facing.rotate_clockwise() {
|
if !left_locked && other_stair_props.facing == facing.rotate_clockwise() {
|
||||||
return StairShape::OuterRight;
|
return StairShape::OuterRight;
|
||||||
} else if !right_locked && other_stair_props.facing == facing.rotate_counter_clockwise()
|
} else if !right_locked && other_stair_props.facing == facing.rotate_counter_clockwise() {
|
||||||
{
|
|
||||||
return StairShape::OuterLeft;
|
return StairShape::OuterLeft;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(other_stair_props) =
|
if let Some(other_stair_props) =
|
||||||
get_stair_properties_if_exists(world, &block_pos.offset(facing.opposite().to_offset()))
|
get_stair_properties_if_exists(world, &block_pos.offset(facing.opposite().to_offset()))
|
||||||
.await
|
.await
|
||||||
|
&& other_stair_props.half == half
|
||||||
{
|
{
|
||||||
if other_stair_props.half == half {
|
|
||||||
if !right_locked && other_stair_props.facing == facing.rotate_clockwise() {
|
if !right_locked && other_stair_props.facing == facing.rotate_clockwise() {
|
||||||
return StairShape::InnerRight;
|
return StairShape::InnerRight;
|
||||||
} else if !left_locked && other_stair_props.facing == facing.rotate_counter_clockwise()
|
} else if !left_locked && other_stair_props.facing == facing.rotate_counter_clockwise() {
|
||||||
{
|
|
||||||
return StairShape::InnerLeft;
|
return StairShape::InnerLeft;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
StairShape::Straight
|
StairShape::Straight
|
||||||
}
|
}
|
||||||
|
|||||||
@ -91,15 +91,14 @@ pub trait FlowingFluid {
|
|||||||
|
|
||||||
let state_id = world.get_block_state_id(pos).await;
|
let state_id = world.get_block_state_id(pos).await;
|
||||||
// Check if the block has waterlogged property and if it's true
|
// Check if the block has waterlogged property and if it's true
|
||||||
if let Some(properties) = block.properties(state_id) {
|
if let Some(properties) = block.properties(state_id)
|
||||||
if properties
|
&& properties
|
||||||
.to_props()
|
.to_props()
|
||||||
.iter()
|
.iter()
|
||||||
.any(|(key, value)| key == "waterlogged" && value == "true")
|
.any(|(key, value)| key == "waterlogged" && value == "true")
|
||||||
{
|
{
|
||||||
return Some(state_id);
|
return Some(state_id);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -313,8 +313,7 @@ pub async fn drop_loot(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if experience {
|
if experience && let Some(experience) = &block.experience {
|
||||||
if let Some(experience) = &block.experience {
|
|
||||||
let mut random = RandomGenerator::Xoroshiro(Xoroshiro::from_seed(get_seed()));
|
let mut random = RandomGenerator::Xoroshiro(Xoroshiro::from_seed(get_seed()));
|
||||||
let amount = experience.experience.get(&mut random);
|
let amount = experience.experience.get(&mut random);
|
||||||
// TODO: Silk touch gives no exp
|
// TODO: Silk touch gives no exp
|
||||||
@ -323,7 +322,6 @@ pub async fn drop_loot(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn calc_block_breaking(
|
pub async fn calc_block_breaking(
|
||||||
player: &Player,
|
player: &Player,
|
||||||
|
|||||||
@ -17,7 +17,7 @@ use super::{
|
|||||||
pub struct BlockArgumentConsumer;
|
pub struct BlockArgumentConsumer;
|
||||||
|
|
||||||
impl GetClientSideArgParser for BlockArgumentConsumer {
|
impl GetClientSideArgParser for BlockArgumentConsumer {
|
||||||
fn get_client_side_parser(&self) -> ArgumentType {
|
fn get_client_side_parser(&self) -> ArgumentType<'_> {
|
||||||
ArgumentType::BlockState
|
ArgumentType::BlockState
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ pub enum BlockPredicate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl GetClientSideArgParser for BlockPredicateArgumentConsumer {
|
impl GetClientSideArgParser for BlockPredicateArgumentConsumer {
|
||||||
fn get_client_side_parser(&self) -> ArgumentType {
|
fn get_client_side_parser(&self) -> ArgumentType<'_> {
|
||||||
ArgumentType::BlockPredicate
|
ArgumentType::BlockPredicate
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@ use pumpkin_protocol::java::client::play::{ArgumentType, CommandSuggestion, Sugg
|
|||||||
pub struct BoolArgConsumer;
|
pub struct BoolArgConsumer;
|
||||||
|
|
||||||
impl GetClientSideArgParser for BoolArgConsumer {
|
impl GetClientSideArgParser for BoolArgConsumer {
|
||||||
fn get_client_side_parser(&self) -> ArgumentType {
|
fn get_client_side_parser(&self) -> ArgumentType<'_> {
|
||||||
ArgumentType::Bool
|
ArgumentType::Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -12,7 +12,7 @@ use pumpkin_protocol::java::client::play::{ArgumentType, CommandSuggestion, Sugg
|
|||||||
pub struct BossbarColorArgumentConsumer;
|
pub struct BossbarColorArgumentConsumer;
|
||||||
|
|
||||||
impl GetClientSideArgParser for BossbarColorArgumentConsumer {
|
impl GetClientSideArgParser for BossbarColorArgumentConsumer {
|
||||||
fn get_client_side_parser(&self) -> ArgumentType {
|
fn get_client_side_parser(&self) -> ArgumentType<'_> {
|
||||||
// Not sure if this is right...
|
// Not sure if this is right...
|
||||||
ArgumentType::ResourceLocation
|
ArgumentType::ResourceLocation
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,7 +12,7 @@ use pumpkin_protocol::java::client::play::{ArgumentType, CommandSuggestion, Sugg
|
|||||||
pub struct BossbarStyleArgumentConsumer;
|
pub struct BossbarStyleArgumentConsumer;
|
||||||
|
|
||||||
impl GetClientSideArgParser for BossbarStyleArgumentConsumer {
|
impl GetClientSideArgParser for BossbarStyleArgumentConsumer {
|
||||||
fn get_client_side_parser(&self) -> ArgumentType {
|
fn get_client_side_parser(&self) -> ArgumentType<'_> {
|
||||||
// Not sure if this is right...
|
// Not sure if this is right...
|
||||||
ArgumentType::ResourceLocation
|
ArgumentType::ResourceLocation
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,23 +34,23 @@ where
|
|||||||
) -> Option<Arg<'a>> {
|
) -> Option<Arg<'a>> {
|
||||||
let x = args.pop()?.parse::<T>().ok()?;
|
let x = args.pop()?.parse::<T>().ok()?;
|
||||||
|
|
||||||
if let Some(max) = self.max_inclusive {
|
if let Some(max) = self.max_inclusive
|
||||||
if x > max {
|
&& x > max
|
||||||
|
{
|
||||||
return Some(Arg::Num(Err(NotInBounds::UpperBound(
|
return Some(Arg::Num(Err(NotInBounds::UpperBound(
|
||||||
x.to_number(),
|
x.to_number(),
|
||||||
max.to_number(),
|
max.to_number(),
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(min) = self.min_inclusive {
|
if let Some(min) = self.min_inclusive
|
||||||
if x < min {
|
&& x < min
|
||||||
|
{
|
||||||
return Some(Arg::Num(Err(NotInBounds::LowerBound(
|
return Some(Arg::Num(Err(NotInBounds::LowerBound(
|
||||||
x.to_number(),
|
x.to_number(),
|
||||||
min.to_number(),
|
min.to_number(),
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Some(Arg::Num(Ok(x.to_number())))
|
Some(Arg::Num(Ok(x.to_number())))
|
||||||
}
|
}
|
||||||
@ -198,7 +198,7 @@ impl ToFromNumber for f64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl GetClientSideArgParser for BoundedNumArgumentConsumer<f64> {
|
impl GetClientSideArgParser for BoundedNumArgumentConsumer<f64> {
|
||||||
fn get_client_side_parser(&self) -> ArgumentType {
|
fn get_client_side_parser(&self) -> ArgumentType<'_> {
|
||||||
ArgumentType::Double {
|
ArgumentType::Double {
|
||||||
min: self.min_inclusive,
|
min: self.min_inclusive,
|
||||||
max: self.max_inclusive,
|
max: self.max_inclusive,
|
||||||
@ -226,7 +226,7 @@ impl ToFromNumber for f32 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl GetClientSideArgParser for BoundedNumArgumentConsumer<f32> {
|
impl GetClientSideArgParser for BoundedNumArgumentConsumer<f32> {
|
||||||
fn get_client_side_parser(&self) -> ArgumentType {
|
fn get_client_side_parser(&self) -> ArgumentType<'_> {
|
||||||
ArgumentType::Float {
|
ArgumentType::Float {
|
||||||
min: self.min_inclusive,
|
min: self.min_inclusive,
|
||||||
max: self.max_inclusive,
|
max: self.max_inclusive,
|
||||||
@ -254,7 +254,7 @@ impl ToFromNumber for i32 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl GetClientSideArgParser for BoundedNumArgumentConsumer<i32> {
|
impl GetClientSideArgParser for BoundedNumArgumentConsumer<i32> {
|
||||||
fn get_client_side_parser(&self) -> ArgumentType {
|
fn get_client_side_parser(&self) -> ArgumentType<'_> {
|
||||||
ArgumentType::Integer {
|
ArgumentType::Integer {
|
||||||
min: self.min_inclusive,
|
min: self.min_inclusive,
|
||||||
max: self.max_inclusive,
|
max: self.max_inclusive,
|
||||||
@ -282,7 +282,7 @@ impl ToFromNumber for i64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl GetClientSideArgParser for BoundedNumArgumentConsumer<i64> {
|
impl GetClientSideArgParser for BoundedNumArgumentConsumer<i64> {
|
||||||
fn get_client_side_parser(&self) -> ArgumentType {
|
fn get_client_side_parser(&self) -> ArgumentType<'_> {
|
||||||
ArgumentType::Long {
|
ArgumentType::Long {
|
||||||
min: self.min_inclusive,
|
min: self.min_inclusive,
|
||||||
max: self.max_inclusive,
|
max: self.max_inclusive,
|
||||||
|
|||||||
@ -18,7 +18,7 @@ use super::{Arg, ArgumentConsumer, DefaultNameArgConsumer, FindArg, GetClientSid
|
|||||||
pub struct CommandTreeArgumentConsumer;
|
pub struct CommandTreeArgumentConsumer;
|
||||||
|
|
||||||
impl GetClientSideArgParser for CommandTreeArgumentConsumer {
|
impl GetClientSideArgParser for CommandTreeArgumentConsumer {
|
||||||
fn get_client_side_parser(&self) -> ArgumentType {
|
fn get_client_side_parser(&self) -> ArgumentType<'_> {
|
||||||
ArgumentType::String(StringProtoArgBehavior::SingleWord)
|
ArgumentType::String(StringProtoArgBehavior::SingleWord)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -14,7 +14,7 @@ use super::{Arg, ArgumentConsumer, DefaultNameArgConsumer, FindArg, GetClientSid
|
|||||||
pub struct DifficultyArgumentConsumer;
|
pub struct DifficultyArgumentConsumer;
|
||||||
|
|
||||||
impl GetClientSideArgParser for DifficultyArgumentConsumer {
|
impl GetClientSideArgParser for DifficultyArgumentConsumer {
|
||||||
fn get_client_side_parser(&self) -> ArgumentType {
|
fn get_client_side_parser(&self) -> ArgumentType<'_> {
|
||||||
ArgumentType::String(
|
ArgumentType::String(
|
||||||
pumpkin_protocol::java::client::play::StringProtoArgBehavior::SingleWord,
|
pumpkin_protocol::java::client::play::StringProtoArgBehavior::SingleWord,
|
||||||
)
|
)
|
||||||
|
|||||||
@ -227,9 +227,9 @@ impl FromStr for TargetSelector {
|
|||||||
}
|
}
|
||||||
Ok(selector)
|
Ok(selector)
|
||||||
} else if let Ok(uuid) = Uuid::parse_str(arg) {
|
} else if let Ok(uuid) = Uuid::parse_str(arg) {
|
||||||
return Ok(Self::new(EntitySelectorType::Uuid(uuid)));
|
Ok(Self::new(EntitySelectorType::Uuid(uuid)))
|
||||||
} else {
|
} else {
|
||||||
return Ok(Self::new(EntitySelectorType::NamedPlayer(arg.to_string())));
|
Ok(Self::new(EntitySelectorType::NamedPlayer(arg.to_string())))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -240,7 +240,7 @@ impl FromStr for TargetSelector {
|
|||||||
pub struct EntitiesArgumentConsumer;
|
pub struct EntitiesArgumentConsumer;
|
||||||
|
|
||||||
impl GetClientSideArgParser for EntitiesArgumentConsumer {
|
impl GetClientSideArgParser for EntitiesArgumentConsumer {
|
||||||
fn get_client_side_parser(&self) -> ArgumentType {
|
fn get_client_side_parser(&self) -> ArgumentType<'_> {
|
||||||
// todo: investigate why this does not accept target selectors
|
// todo: investigate why this does not accept target selectors
|
||||||
ArgumentType::Entity { flags: 0 }
|
ArgumentType::Entity { flags: 0 }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,7 +20,7 @@ use super::{Arg, DefaultNameArgConsumer, FindArg, GetClientSideArgParser};
|
|||||||
pub struct EntityArgumentConsumer;
|
pub struct EntityArgumentConsumer;
|
||||||
|
|
||||||
impl GetClientSideArgParser for EntityArgumentConsumer {
|
impl GetClientSideArgParser for EntityArgumentConsumer {
|
||||||
fn get_client_side_parser(&self) -> ArgumentType {
|
fn get_client_side_parser(&self) -> ArgumentType<'_> {
|
||||||
// todo: investigate why this does not accept target selectors
|
// todo: investigate why this does not accept target selectors
|
||||||
ArgumentType::Entity {
|
ArgumentType::Entity {
|
||||||
flags: ArgumentType::ENTITY_FLAG_ONLY_SINGLE,
|
flags: ArgumentType::ENTITY_FLAG_ONLY_SINGLE,
|
||||||
|
|||||||
@ -14,7 +14,7 @@ use super::{Arg, ArgumentConsumer, DefaultNameArgConsumer, FindArg, GetClientSid
|
|||||||
pub struct GamemodeArgumentConsumer;
|
pub struct GamemodeArgumentConsumer;
|
||||||
|
|
||||||
impl GetClientSideArgParser for GamemodeArgumentConsumer {
|
impl GetClientSideArgParser for GamemodeArgumentConsumer {
|
||||||
fn get_client_side_parser(&self) -> ArgumentType {
|
fn get_client_side_parser(&self) -> ArgumentType<'_> {
|
||||||
ArgumentType::Gamemode
|
ArgumentType::Gamemode
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,11 +33,11 @@ impl ArgumentConsumer for GamemodeArgumentConsumer {
|
|||||||
) -> Option<Arg<'a>> {
|
) -> Option<Arg<'a>> {
|
||||||
let s = args.pop()?;
|
let s = args.pop()?;
|
||||||
|
|
||||||
if let Ok(id) = s.parse::<i8>() {
|
if let Ok(id) = s.parse::<i8>()
|
||||||
if let Ok(gamemode) = GameMode::try_from(id) {
|
&& let Ok(gamemode) = GameMode::try_from(id)
|
||||||
|
{
|
||||||
return Some(Arg::GameMode(gamemode));
|
return Some(Arg::GameMode(gamemode));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
GameMode::from_str(s).map_or_else(|_| None, |gamemode| Some(Arg::GameMode(gamemode)))
|
GameMode::from_str(s).map_or_else(|_| None, |gamemode| Some(Arg::GameMode(gamemode)))
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,7 +17,7 @@ use super::{
|
|||||||
pub struct MsgArgConsumer;
|
pub struct MsgArgConsumer;
|
||||||
|
|
||||||
impl GetClientSideArgParser for MsgArgConsumer {
|
impl GetClientSideArgParser for MsgArgConsumer {
|
||||||
fn get_client_side_parser(&self) -> ArgumentType {
|
fn get_client_side_parser(&self) -> ArgumentType<'_> {
|
||||||
ArgumentType::String(StringProtoArgBehavior::GreedyPhrase)
|
ArgumentType::String(StringProtoArgBehavior::GreedyPhrase)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -73,7 +73,7 @@ pub trait ArgumentConsumer: Sync + GetClientSideArgParser {
|
|||||||
|
|
||||||
pub trait GetClientSideArgParser {
|
pub trait GetClientSideArgParser {
|
||||||
/// Return the parser the client should use while typing a command in chat.
|
/// Return the parser the client should use while typing a command in chat.
|
||||||
fn get_client_side_parser(&self) -> ArgumentType;
|
fn get_client_side_parser(&self) -> ArgumentType<'_>;
|
||||||
/// Usually this should return None. This can be used to force suggestions to be processed on serverside.
|
/// Usually this should return None. This can be used to force suggestions to be processed on serverside.
|
||||||
fn get_client_side_suggestion_type_override(&self) -> Option<SuggestionProviders>;
|
fn get_client_side_suggestion_type_override(&self) -> Option<SuggestionProviders>;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,7 +16,7 @@ use super::{Arg, DefaultNameArgConsumer, FindArg, GetClientSideArgParser};
|
|||||||
pub struct PlayersArgumentConsumer;
|
pub struct PlayersArgumentConsumer;
|
||||||
|
|
||||||
impl GetClientSideArgParser for PlayersArgumentConsumer {
|
impl GetClientSideArgParser for PlayersArgumentConsumer {
|
||||||
fn get_client_side_parser(&self) -> ArgumentType {
|
fn get_client_side_parser(&self) -> ArgumentType<'_> {
|
||||||
// todo: investigate why this does not accept target selectors
|
// todo: investigate why this does not accept target selectors
|
||||||
ArgumentType::Entity {
|
ArgumentType::Entity {
|
||||||
flags: ArgumentType::ENTITY_FLAG_PLAYERS_ONLY,
|
flags: ArgumentType::ENTITY_FLAG_PLAYERS_ONLY,
|
||||||
|
|||||||
@ -18,7 +18,7 @@ use super::{Arg, DefaultNameArgConsumer, FindArg, GetClientSideArgParser};
|
|||||||
pub struct Position2DArgumentConsumer;
|
pub struct Position2DArgumentConsumer;
|
||||||
|
|
||||||
impl GetClientSideArgParser for Position2DArgumentConsumer {
|
impl GetClientSideArgParser for Position2DArgumentConsumer {
|
||||||
fn get_client_side_parser(&self) -> ArgumentType {
|
fn get_client_side_parser(&self) -> ArgumentType<'_> {
|
||||||
ArgumentType::Vec2
|
ArgumentType::Vec2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -15,7 +15,7 @@ use super::{Arg, DefaultNameArgConsumer, FindArg, GetClientSideArgParser};
|
|||||||
pub struct Position3DArgumentConsumer;
|
pub struct Position3DArgumentConsumer;
|
||||||
|
|
||||||
impl GetClientSideArgParser for Position3DArgumentConsumer {
|
impl GetClientSideArgParser for Position3DArgumentConsumer {
|
||||||
fn get_client_side_parser(&self) -> ArgumentType {
|
fn get_client_side_parser(&self) -> ArgumentType<'_> {
|
||||||
ArgumentType::Vec3
|
ArgumentType::Vec3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,7 @@ use super::{Arg, DefaultNameArgConsumer, FindArg, GetClientSideArgParser};
|
|||||||
pub struct BlockPosArgumentConsumer;
|
pub struct BlockPosArgumentConsumer;
|
||||||
|
|
||||||
impl GetClientSideArgParser for BlockPosArgumentConsumer {
|
impl GetClientSideArgParser for BlockPosArgumentConsumer {
|
||||||
fn get_client_side_parser(&self) -> ArgumentType {
|
fn get_client_side_parser(&self) -> ArgumentType<'_> {
|
||||||
ArgumentType::BlockPos
|
ArgumentType::BlockPos
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,7 @@ use crate::server::Server;
|
|||||||
pub struct DamageTypeArgumentConsumer;
|
pub struct DamageTypeArgumentConsumer;
|
||||||
|
|
||||||
impl GetClientSideArgParser for DamageTypeArgumentConsumer {
|
impl GetClientSideArgParser for DamageTypeArgumentConsumer {
|
||||||
fn get_client_side_parser(&self) -> ArgumentType {
|
fn get_client_side_parser(&self) -> ArgumentType<'_> {
|
||||||
ArgumentType::Resource {
|
ArgumentType::Resource {
|
||||||
identifier: "damage_type",
|
identifier: "damage_type",
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,7 +16,7 @@ use crate::server::Server;
|
|||||||
pub struct EffectTypeArgumentConsumer;
|
pub struct EffectTypeArgumentConsumer;
|
||||||
|
|
||||||
impl GetClientSideArgParser for EffectTypeArgumentConsumer {
|
impl GetClientSideArgParser for EffectTypeArgumentConsumer {
|
||||||
fn get_client_side_parser(&self) -> ArgumentType {
|
fn get_client_side_parser(&self) -> ArgumentType<'_> {
|
||||||
ArgumentType::Resource {
|
ArgumentType::Resource {
|
||||||
identifier: "mob_effect",
|
identifier: "mob_effect",
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,7 +16,7 @@ use crate::server::Server;
|
|||||||
pub struct EnchantmentArgumentConsumer;
|
pub struct EnchantmentArgumentConsumer;
|
||||||
|
|
||||||
impl GetClientSideArgParser for EnchantmentArgumentConsumer {
|
impl GetClientSideArgParser for EnchantmentArgumentConsumer {
|
||||||
fn get_client_side_parser(&self) -> ArgumentType {
|
fn get_client_side_parser(&self) -> ArgumentType<'_> {
|
||||||
ArgumentType::Resource {
|
ArgumentType::Resource {
|
||||||
identifier: "enchantment",
|
identifier: "enchantment",
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,7 +17,7 @@ use crate::server::Server;
|
|||||||
pub struct ItemArgumentConsumer;
|
pub struct ItemArgumentConsumer;
|
||||||
|
|
||||||
impl GetClientSideArgParser for ItemArgumentConsumer {
|
impl GetClientSideArgParser for ItemArgumentConsumer {
|
||||||
fn get_client_side_parser(&self) -> ArgumentType {
|
fn get_client_side_parser(&self) -> ArgumentType<'_> {
|
||||||
ArgumentType::Resource { identifier: "item" }
|
ArgumentType::Resource { identifier: "item" }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,7 @@ use crate::server::Server;
|
|||||||
pub struct ParticleArgumentConsumer;
|
pub struct ParticleArgumentConsumer;
|
||||||
|
|
||||||
impl GetClientSideArgParser for ParticleArgumentConsumer {
|
impl GetClientSideArgParser for ParticleArgumentConsumer {
|
||||||
fn get_client_side_parser(&self) -> ArgumentType {
|
fn get_client_side_parser(&self) -> ArgumentType<'_> {
|
||||||
ArgumentType::Resource {
|
ArgumentType::Resource {
|
||||||
identifier: "particle_type",
|
identifier: "particle_type",
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,7 +13,7 @@ pub struct ResourceLocationArgumentConsumer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl GetClientSideArgParser for ResourceLocationArgumentConsumer {
|
impl GetClientSideArgParser for ResourceLocationArgumentConsumer {
|
||||||
fn get_client_side_parser(&self) -> ArgumentType {
|
fn get_client_side_parser(&self) -> ArgumentType<'_> {
|
||||||
ArgumentType::ResourceLocation
|
ArgumentType::ResourceLocation
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,7 @@ use super::{Arg, DefaultNameArgConsumer, FindArg, GetClientSideArgParser};
|
|||||||
pub struct RotationArgumentConsumer;
|
pub struct RotationArgumentConsumer;
|
||||||
|
|
||||||
impl GetClientSideArgParser for RotationArgumentConsumer {
|
impl GetClientSideArgParser for RotationArgumentConsumer {
|
||||||
fn get_client_side_parser(&self) -> ArgumentType {
|
fn get_client_side_parser(&self) -> ArgumentType<'_> {
|
||||||
ArgumentType::Rotation
|
ArgumentType::Rotation
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -18,7 +18,7 @@ use super::{
|
|||||||
pub struct SimpleArgConsumer;
|
pub struct SimpleArgConsumer;
|
||||||
|
|
||||||
impl GetClientSideArgParser for SimpleArgConsumer {
|
impl GetClientSideArgParser for SimpleArgConsumer {
|
||||||
fn get_client_side_parser(&self) -> ArgumentType {
|
fn get_client_side_parser(&self) -> ArgumentType<'_> {
|
||||||
ArgumentType::String(StringProtoArgBehavior::SingleWord)
|
ArgumentType::String(StringProtoArgBehavior::SingleWord)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,7 @@ use super::{
|
|||||||
pub struct SoundArgumentConsumer;
|
pub struct SoundArgumentConsumer;
|
||||||
|
|
||||||
impl GetClientSideArgParser for SoundArgumentConsumer {
|
impl GetClientSideArgParser for SoundArgumentConsumer {
|
||||||
fn get_client_side_parser(&self) -> ArgumentType {
|
fn get_client_side_parser(&self) -> ArgumentType<'_> {
|
||||||
ArgumentType::ResourceLocation
|
ArgumentType::ResourceLocation
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,7 @@ use pumpkin_protocol::java::client::play::{ArgumentType, CommandSuggestion, Sugg
|
|||||||
pub struct SoundCategoryArgumentConsumer;
|
pub struct SoundCategoryArgumentConsumer;
|
||||||
|
|
||||||
impl GetClientSideArgParser for SoundCategoryArgumentConsumer {
|
impl GetClientSideArgParser for SoundCategoryArgumentConsumer {
|
||||||
fn get_client_side_parser(&self) -> ArgumentType {
|
fn get_client_side_parser(&self) -> ArgumentType<'_> {
|
||||||
// ResourceLocation is used for enumerated string values
|
// ResourceLocation is used for enumerated string values
|
||||||
ArgumentType::ResourceLocation
|
ArgumentType::ResourceLocation
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,7 +16,7 @@ use super::{
|
|||||||
pub struct SummonableEntitiesArgumentConsumer;
|
pub struct SummonableEntitiesArgumentConsumer;
|
||||||
|
|
||||||
impl GetClientSideArgParser for SummonableEntitiesArgumentConsumer {
|
impl GetClientSideArgParser for SummonableEntitiesArgumentConsumer {
|
||||||
fn get_client_side_parser(&self) -> ArgumentType {
|
fn get_client_side_parser(&self) -> ArgumentType<'_> {
|
||||||
ArgumentType::ResourceLocation
|
ArgumentType::ResourceLocation
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,7 @@ use pumpkin_util::text::TextComponent;
|
|||||||
pub struct TextComponentArgConsumer;
|
pub struct TextComponentArgConsumer;
|
||||||
|
|
||||||
impl GetClientSideArgParser for TextComponentArgConsumer {
|
impl GetClientSideArgParser for TextComponentArgConsumer {
|
||||||
fn get_client_side_parser(&self) -> ArgumentType {
|
fn get_client_side_parser(&self) -> ArgumentType<'_> {
|
||||||
ArgumentType::Component
|
ArgumentType::Component
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -12,7 +12,7 @@ use crate::server::Server;
|
|||||||
pub struct TimeArgumentConsumer;
|
pub struct TimeArgumentConsumer;
|
||||||
|
|
||||||
impl GetClientSideArgParser for TimeArgumentConsumer {
|
impl GetClientSideArgParser for TimeArgumentConsumer {
|
||||||
fn get_client_side_parser(&self) -> ArgumentType {
|
fn get_client_side_parser(&self) -> ArgumentType<'_> {
|
||||||
ArgumentType::Time { min: 0 }
|
ArgumentType::Time { min: 0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -86,11 +86,11 @@ impl CommandExecutor for Executor {
|
|||||||
for y in start_y..=end_y {
|
for y in start_y..=end_y {
|
||||||
for z in start_z..=end_z {
|
for z in start_z..=end_z {
|
||||||
let block_position = BlockPos(Vector3::new(x, y, z));
|
let block_position = BlockPos(Vector3::new(x, y, z));
|
||||||
if let Some(filter) = &option_filter {
|
if let Some(filter) = &option_filter
|
||||||
if not_in_filter(filter, world.get_block(&block_position).await) {
|
&& not_in_filter(filter, world.get_block(&block_position).await)
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
world
|
world
|
||||||
.break_block(
|
.break_block(
|
||||||
&block_position,
|
&block_position,
|
||||||
@ -116,11 +116,11 @@ impl CommandExecutor for Executor {
|
|||||||
for y in start_y..=end_y {
|
for y in start_y..=end_y {
|
||||||
for z in start_z..=end_z {
|
for z in start_z..=end_z {
|
||||||
let block_position = BlockPos(Vector3::new(x, y, z));
|
let block_position = BlockPos(Vector3::new(x, y, z));
|
||||||
if let Some(filter) = &option_filter {
|
if let Some(filter) = &option_filter
|
||||||
if not_in_filter(filter, world.get_block(&block_position).await) {
|
&& not_in_filter(filter, world.get_block(&block_position).await)
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
world
|
world
|
||||||
.set_block_state(
|
.set_block_state(
|
||||||
&block_position,
|
&block_position,
|
||||||
@ -141,12 +141,11 @@ impl CommandExecutor for Executor {
|
|||||||
let block_position = BlockPos(Vector3::new(x, y, z));
|
let block_position = BlockPos(Vector3::new(x, y, z));
|
||||||
let old_state = world.get_block_state(&block_position).await;
|
let old_state = world.get_block_state(&block_position).await;
|
||||||
if old_state.is_air() {
|
if old_state.is_air() {
|
||||||
if let Some(filter) = &option_filter {
|
if let Some(filter) = &option_filter
|
||||||
if not_in_filter(filter, world.get_block(&block_position).await)
|
&& not_in_filter(filter, world.get_block(&block_position).await)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
world
|
world
|
||||||
.set_block_state(
|
.set_block_state(
|
||||||
&block_position,
|
&block_position,
|
||||||
@ -172,11 +171,11 @@ impl CommandExecutor for Executor {
|
|||||||
|| y == end_y
|
|| y == end_y
|
||||||
|| z == start_z
|
|| z == start_z
|
||||||
|| z == end_z;
|
|| z == end_z;
|
||||||
if let Some(filter) = &option_filter {
|
if let Some(filter) = &option_filter
|
||||||
if not_in_filter(filter, world.get_block(&block_position).await) {
|
&& not_in_filter(filter, world.get_block(&block_position).await)
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if is_edge {
|
if is_edge {
|
||||||
world
|
world
|
||||||
.set_block_state(
|
.set_block_state(
|
||||||
@ -210,11 +209,11 @@ impl CommandExecutor for Executor {
|
|||||||
if !is_edge {
|
if !is_edge {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if let Some(filter) = &option_filter {
|
if let Some(filter) = &option_filter
|
||||||
if not_in_filter(filter, world.get_block(&block_position).await) {
|
&& not_in_filter(filter, world.get_block(&block_position).await)
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
world
|
world
|
||||||
.set_block_state(
|
.set_block_state(
|
||||||
&block_position,
|
&block_position,
|
||||||
@ -233,11 +232,11 @@ impl CommandExecutor for Executor {
|
|||||||
for y in start_y..=end_y {
|
for y in start_y..=end_y {
|
||||||
for z in start_z..=end_z {
|
for z in start_z..=end_z {
|
||||||
let block_position = BlockPos(Vector3::new(x, y, z));
|
let block_position = BlockPos(Vector3::new(x, y, z));
|
||||||
if let Some(filter) = &option_filter {
|
if let Some(filter) = &option_filter
|
||||||
if not_in_filter(filter, world.get_block(&block_position).await) {
|
&& not_in_filter(filter, world.get_block(&block_position).await)
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
world
|
world
|
||||||
.set_block_state(
|
.set_block_state(
|
||||||
&block_position,
|
&block_position,
|
||||||
|
|||||||
@ -428,12 +428,12 @@ impl CommandDispatcher {
|
|||||||
for (key, value) in &self.commands {
|
for (key, value) in &self.commands {
|
||||||
if key == name {
|
if key == name {
|
||||||
to_remove.push(key.clone());
|
to_remove.push(key.clone());
|
||||||
} else if let Command::Alias(target) = value {
|
} else if let Command::Alias(target) = value
|
||||||
if target == name {
|
&& target == name
|
||||||
|
{
|
||||||
to_remove.push(key.clone());
|
to_remove.push(key.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
for key in to_remove {
|
for key in to_remove {
|
||||||
self.commands.remove(&key);
|
self.commands.remove(&key);
|
||||||
|
|||||||
@ -141,14 +141,14 @@ impl Goal for LookAtEntityGoal {
|
|||||||
|
|
||||||
async fn tick(&self, mob: &dyn Mob) {
|
async fn tick(&self, mob: &dyn Mob) {
|
||||||
let mob = mob.get_mob_entity();
|
let mob = mob.get_mob_entity();
|
||||||
if let Some(target) = self.target.lock().await.as_ref() {
|
if let Some(target) = self.target.lock().await.as_ref()
|
||||||
if target.get_entity().is_alive() {
|
&& target.get_entity().is_alive()
|
||||||
|
{
|
||||||
let target_pos = target.get_entity().pos.load();
|
let target_pos = target.get_entity().pos.load();
|
||||||
mob.living_entity.entity.look_at(target_pos).await;
|
mob.living_entity.entity.look_at(target_pos).await;
|
||||||
self.look_time.fetch_sub(1, Relaxed);
|
self.look_time.fetch_sub(1, Relaxed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fn get_goal_control(&self) -> &GoalControl {
|
fn get_goal_control(&self) -> &GoalControl {
|
||||||
&self.goal_control
|
&self.goal_control
|
||||||
|
|||||||
@ -702,12 +702,14 @@ impl LivingEntity {
|
|||||||
) -> TextComponent {
|
) -> TextComponent {
|
||||||
match damage_type.death_message_type {
|
match damage_type.death_message_type {
|
||||||
DeathMessageType::Default => {
|
DeathMessageType::Default => {
|
||||||
if cause.is_some() && source.is_some() {
|
if let Some(cause) = cause
|
||||||
|
&& source.is_some()
|
||||||
|
{
|
||||||
TextComponent::translate(
|
TextComponent::translate(
|
||||||
format!("death.attack.{}.player", damage_type.message_id),
|
format!("death.attack.{}.player", damage_type.message_id),
|
||||||
[
|
[
|
||||||
dyn_self.get_display_name().await,
|
dyn_self.get_display_name().await,
|
||||||
cause.unwrap().get_display_name().await,
|
cause.get_display_name().await,
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -990,15 +990,13 @@ impl Entity {
|
|||||||
|
|
||||||
let in_lava = in_fluid[1];
|
let in_lava = in_fluid[1];
|
||||||
|
|
||||||
if in_lava {
|
if in_lava && let Some(living) = caller.get_living_entity() {
|
||||||
if let Some(living) = caller.get_living_entity() {
|
|
||||||
let halved_fall = living.fall_distance.load() / 2.0;
|
let halved_fall = living.fall_distance.load() / 2.0;
|
||||||
|
|
||||||
if halved_fall != 0.0 {
|
if halved_fall != 0.0 {
|
||||||
living.fall_distance.store(halved_fall);
|
living.fall_distance.store(halved_fall);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
self.lava_height.store(lava_height);
|
self.lava_height.store(lava_height);
|
||||||
|
|
||||||
|
|||||||
@ -541,11 +541,12 @@ impl Player {
|
|||||||
block_pos: BlockPos,
|
block_pos: BlockPos,
|
||||||
yaw: f32,
|
yaw: f32,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
if let Some(respawn_point) = self.respawn_point.load() {
|
if let Some(respawn_point) = self.respawn_point.load()
|
||||||
if dimension == respawn_point.dimension && block_pos == respawn_point.position {
|
&& dimension == respawn_point.dimension
|
||||||
|
&& block_pos == respawn_point.position
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
self.respawn_point.store(Some(RespawnPoint {
|
self.respawn_point.store(Some(RespawnPoint {
|
||||||
dimension,
|
dimension,
|
||||||
@ -802,11 +803,11 @@ impl Player {
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.tick_counter.fetch_add(1, Ordering::Relaxed);
|
self.tick_counter.fetch_add(1, Ordering::Relaxed);
|
||||||
if let Some(sleeping_since) = self.sleeping_since.load() {
|
if let Some(sleeping_since) = self.sleeping_since.load()
|
||||||
if sleeping_since < 101 {
|
&& sleeping_since < 101
|
||||||
|
{
|
||||||
self.sleeping_since.store(Some(sleeping_since + 1));
|
self.sleeping_since.store(Some(sleeping_since + 1));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if self.mining.load(Ordering::Relaxed) {
|
if self.mining.load(Ordering::Relaxed) {
|
||||||
let pos = self.mining_pos.lock().await;
|
let pos = self.mining_pos.lock().await;
|
||||||
@ -2006,8 +2007,9 @@ impl NBTStorage for PlayerInventory {
|
|||||||
// Process inventory list
|
// Process inventory list
|
||||||
if let Some(inventory_list) = nbt.get_list("Inventory") {
|
if let Some(inventory_list) = nbt.get_list("Inventory") {
|
||||||
for tag in inventory_list {
|
for tag in inventory_list {
|
||||||
if let Some(item_compound) = tag.extract_compound() {
|
if let Some(item_compound) = tag.extract_compound()
|
||||||
if let Some(slot_byte) = item_compound.get_byte("Slot") {
|
&& let Some(slot_byte) = item_compound.get_byte("Slot")
|
||||||
|
{
|
||||||
let slot = slot_byte as usize;
|
let slot = slot_byte as usize;
|
||||||
if let Some(item_stack) = ItemStack::read_item_stack(item_compound) {
|
if let Some(item_stack) = ItemStack::read_item_stack(item_compound) {
|
||||||
self.set_stack(slot, item_stack).await;
|
self.set_stack(slot, item_stack).await;
|
||||||
@ -2015,41 +2017,40 @@ impl NBTStorage for PlayerInventory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(equipment) = nbt.get_compound("equipment") {
|
if let Some(equipment) = nbt.get_compound("equipment") {
|
||||||
if let Some(offhand) = equipment.get_compound("offhand") {
|
if let Some(offhand) = equipment.get_compound("offhand")
|
||||||
if let Some(item_stack) = ItemStack::read_item_stack(offhand) {
|
&& let Some(item_stack) = ItemStack::read_item_stack(offhand)
|
||||||
|
{
|
||||||
self.set_stack(40, item_stack).await;
|
self.set_stack(40, item_stack).await;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(head) = equipment.get_compound("head") {
|
if let Some(head) = equipment.get_compound("head")
|
||||||
if let Some(item_stack) = ItemStack::read_item_stack(head) {
|
&& let Some(item_stack) = ItemStack::read_item_stack(head)
|
||||||
|
{
|
||||||
self.set_stack(39, item_stack).await;
|
self.set_stack(39, item_stack).await;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(chest) = equipment.get_compound("chest") {
|
if let Some(chest) = equipment.get_compound("chest")
|
||||||
if let Some(item_stack) = ItemStack::read_item_stack(chest) {
|
&& let Some(item_stack) = ItemStack::read_item_stack(chest)
|
||||||
|
{
|
||||||
self.set_stack(38, item_stack).await;
|
self.set_stack(38, item_stack).await;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(legs) = equipment.get_compound("legs") {
|
if let Some(legs) = equipment.get_compound("legs")
|
||||||
if let Some(item_stack) = ItemStack::read_item_stack(legs) {
|
&& let Some(item_stack) = ItemStack::read_item_stack(legs)
|
||||||
|
{
|
||||||
self.set_stack(37, item_stack).await;
|
self.set_stack(37, item_stack).await;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(feet) = equipment.get_compound("feet") {
|
if let Some(feet) = equipment.get_compound("feet")
|
||||||
if let Some(item_stack) = ItemStack::read_item_stack(feet) {
|
&& let Some(item_stack) = ItemStack::read_item_stack(feet)
|
||||||
|
{
|
||||||
self.set_stack(36, item_stack).await;
|
self.set_stack(36, item_stack).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl NBTStorageInit for PlayerInventory {}
|
impl NBTStorageInit for PlayerInventory {}
|
||||||
|
|
||||||
|
|||||||
@ -22,7 +22,6 @@ use crate::world::World;
|
|||||||
|
|
||||||
pub struct EmptyBucketItem;
|
pub struct EmptyBucketItem;
|
||||||
pub struct FilledBucketItem;
|
pub struct FilledBucketItem;
|
||||||
pub struct MilkBucketItem;
|
|
||||||
|
|
||||||
impl ItemMetadata for EmptyBucketItem {
|
impl ItemMetadata for EmptyBucketItem {
|
||||||
fn ids() -> Box<[u16]> {
|
fn ids() -> Box<[u16]> {
|
||||||
@ -47,11 +46,11 @@ impl ItemMetadata for FilledBucketItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ItemMetadata for MilkBucketItem {
|
// impl ItemMetadata for MilkBucketItem {
|
||||||
fn ids() -> Box<[u16]> {
|
// fn ids() -> Box<[u16]> {
|
||||||
[Item::MILK_BUCKET.id].into()
|
// [Item::MILK_BUCKET.id].into()
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
fn get_start_and_end_pos(player: &Player) -> (Vector3<f64>, Vector3<f64>) {
|
fn get_start_and_end_pos(player: &Player) -> (Vector3<f64>, Vector3<f64>) {
|
||||||
let start_pos = player.eye_position();
|
let start_pos = player.eye_position();
|
||||||
|
|||||||
@ -35,11 +35,11 @@ impl ItemBehaviour for HoneyCombItem {
|
|||||||
// First we try to strip the block. by getting his equivalent and applying it the axis.
|
// First we try to strip the block. by getting his equivalent and applying it the axis.
|
||||||
let replacement_block = get_waxed_equivalent(block);
|
let replacement_block = get_waxed_equivalent(block);
|
||||||
// If there is a strip equivalent.
|
// If there is a strip equivalent.
|
||||||
if replacement_block.is_some() {
|
if let Some(replacement_block) = replacement_block {
|
||||||
// get block state of the old log.
|
// get block state of the old log.
|
||||||
// get the log properties
|
// get the log properties
|
||||||
// create new properties for the new log.
|
// create new properties for the new log.
|
||||||
let new_block = &Block::from_id(replacement_block.unwrap());
|
let new_block = &Block::from_id(replacement_block);
|
||||||
|
|
||||||
let new_state_id = if block.is_tagged_with_by_tag(&tag::Block::MINECRAFT_DOORS)
|
let new_state_id = if block.is_tagged_with_by_tag(&tag::Block::MINECRAFT_DOORS)
|
||||||
&& block.is_tagged_with_by_tag(&tag::Block::MINECRAFT_DOORS)
|
&& block.is_tagged_with_by_tag(&tag::Block::MINECRAFT_DOORS)
|
||||||
|
|||||||
@ -175,8 +175,9 @@ impl PumpkinServer {
|
|||||||
|
|
||||||
let mut ticker = Ticker::new();
|
let mut ticker = Ticker::new();
|
||||||
|
|
||||||
if advanced_config().commands.use_console {
|
if advanced_config().commands.use_console
|
||||||
if let Some((wrapper, _)) = &*LOGGER_IMPL {
|
&& let Some((wrapper, _)) = &*LOGGER_IMPL
|
||||||
|
{
|
||||||
if let Some(rl) = wrapper.take_readline() {
|
if let Some(rl) = wrapper.take_readline() {
|
||||||
setup_console(rl, server.clone());
|
setup_console(rl, server.clone());
|
||||||
} else {
|
} else {
|
||||||
@ -188,7 +189,6 @@ impl PumpkinServer {
|
|||||||
setup_stdin_console(server.clone()).await;
|
setup_stdin_console(server.clone()).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if rcon.enabled {
|
if rcon.enabled {
|
||||||
let rcon_server = server.clone();
|
let rcon_server = server.clone();
|
||||||
@ -311,12 +311,12 @@ impl PumpkinServer {
|
|||||||
log::info!("Completed save!");
|
log::info!("Completed save!");
|
||||||
|
|
||||||
// Explicitly drop the line reader to return the terminal to the original state.
|
// Explicitly drop the line reader to return the terminal to the original state.
|
||||||
if let Some((wrapper, _)) = &*LOGGER_IMPL {
|
if let Some((wrapper, _)) = &*LOGGER_IMPL
|
||||||
if let Some(rl) = wrapper.take_readline() {
|
&& let Some(rl) = wrapper.take_readline()
|
||||||
|
{
|
||||||
let _ = rl;
|
let _ = rl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn unified_listener_task(
|
pub async fn unified_listener_task(
|
||||||
&self,
|
&self,
|
||||||
|
|||||||
@ -213,21 +213,21 @@ impl ReadlineLogWrapper {
|
|||||||
impl Log for ReadlineLogWrapper {
|
impl Log for ReadlineLogWrapper {
|
||||||
fn log(&self, record: &log::Record) {
|
fn log(&self, record: &log::Record) {
|
||||||
self.internal.log(record);
|
self.internal.log(record);
|
||||||
if let Ok(mut lock) = self.readline.lock() {
|
if let Ok(mut lock) = self.readline.lock()
|
||||||
if let Some(rl) = lock.as_mut() {
|
&& let Some(rl) = lock.as_mut()
|
||||||
|
{
|
||||||
let _ = rl.flush();
|
let _ = rl.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fn flush(&self) {
|
fn flush(&self) {
|
||||||
self.internal.flush();
|
self.internal.flush();
|
||||||
if let Ok(mut lock) = self.readline.lock() {
|
if let Ok(mut lock) = self.readline.lock()
|
||||||
if let Some(rl) = lock.as_mut() {
|
&& let Some(rl) = lock.as_mut()
|
||||||
|
{
|
||||||
let _ = rl.flush();
|
let _ = rl.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fn enabled(&self, metadata: &log::Metadata) -> bool {
|
fn enabled(&self, metadata: &log::Metadata) -> bool {
|
||||||
self.internal.enabled(metadata)
|
self.internal.enabled(metadata)
|
||||||
|
|||||||
@ -31,7 +31,7 @@ impl BedrockClient {
|
|||||||
&CConnectionRequestAccepted::new(
|
&CConnectionRequestAccepted::new(
|
||||||
self.address,
|
self.address,
|
||||||
0,
|
0,
|
||||||
[SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(0, 0, 0, 0), 19132)); 10],
|
[SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::UNSPECIFIED, 19132)); 10],
|
||||||
packet.time,
|
packet.time,
|
||||||
UNIX_EPOCH.elapsed().unwrap().as_millis() as u64,
|
UNIX_EPOCH.elapsed().unwrap().as_millis() as u64,
|
||||||
),
|
),
|
||||||
|
|||||||
@ -170,15 +170,15 @@ impl BedrockClient {
|
|||||||
|
|
||||||
pub async fn process_packet(self: &Arc<Self>, server: &Server, packet: Cursor<Vec<u8>>) {
|
pub async fn process_packet(self: &Arc<Self>, server: &Server, packet: Cursor<Vec<u8>>) {
|
||||||
let packet = self.get_packet_payload(packet).await;
|
let packet = self.get_packet_payload(packet).await;
|
||||||
if let Some(packet) = packet {
|
if let Some(packet) = packet
|
||||||
if let Err(error) = self.handle_packet_payload(server, packet).await {
|
&& let Err(error) = self.handle_packet_payload(server, packet).await
|
||||||
|
{
|
||||||
let _text = format!("Error while reading incoming packet {error}");
|
let _text = format!("Error while reading incoming packet {error}");
|
||||||
log::error!("Failed to read incoming packet with : {error}");
|
log::error!("Failed to read incoming packet with : {error}");
|
||||||
self.kick(DisconnectReason::BadPacket, error.to_string())
|
self.kick(DisconnectReason::BadPacket, error.to_string())
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn set_compression(&self, compression: CompressionInfo) {
|
pub async fn set_compression(&self, compression: CompressionInfo) {
|
||||||
self.network_reader
|
self.network_reader
|
||||||
|
|||||||
@ -756,11 +756,11 @@ impl JavaClient {
|
|||||||
gameprofile.id,
|
gameprofile.id,
|
||||||
err
|
err
|
||||||
);
|
);
|
||||||
if err.is_kick() {
|
if err.is_kick()
|
||||||
if let Some(reason) = err.client_kick_reason() {
|
&& let Some(reason) = err.client_kick_reason()
|
||||||
|
{
|
||||||
self.kick(TextComponent::text(reason)).await;
|
self.kick(TextComponent::text(reason)).await;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -879,11 +879,11 @@ impl JavaClient {
|
|||||||
player.gameprofile.id,
|
player.gameprofile.id,
|
||||||
err
|
err
|
||||||
);
|
);
|
||||||
if err.is_kick() {
|
if err.is_kick()
|
||||||
if let Some(reason) = err.client_kick_reason() {
|
&& let Some(reason) = err.client_kick_reason()
|
||||||
|
{
|
||||||
self.kick(TextComponent::text(reason)).await;
|
self.kick(TextComponent::text(reason)).await;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -108,8 +108,8 @@ async fn handle_packet(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
PacketType::Status => {
|
PacketType::Status => {
|
||||||
if let Ok(packet) = SStatusRequest::decode(&mut raw_packet).await {
|
if let Ok(packet) = SStatusRequest::decode(&mut raw_packet).await
|
||||||
if clients
|
&& clients
|
||||||
.read()
|
.read()
|
||||||
.await
|
.await
|
||||||
.get(&packet.challenge_token)
|
.get(&packet.challenge_token)
|
||||||
@ -181,6 +181,5 @@ async fn handle_packet(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,7 +46,7 @@ impl CachedBranding {
|
|||||||
cached_server_brand,
|
cached_server_brand,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn get_branding(&self) -> CPluginMessage {
|
pub fn get_branding(&self) -> CPluginMessage<'_> {
|
||||||
CPluginMessage::new("minecraft:brand", &self.cached_server_brand)
|
CPluginMessage::new("minecraft:brand", &self.cached_server_brand)
|
||||||
}
|
}
|
||||||
const BRAND: &str = "Pumpkin";
|
const BRAND: &str = "Pumpkin";
|
||||||
|
|||||||
@ -62,11 +62,11 @@ impl Ticker {
|
|||||||
Duration::from_nanos(manager.nanoseconds_per_tick() as u64)
|
Duration::from_nanos(manager.nanoseconds_per_tick() as u64)
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(sleep_time) = tick_interval.checked_sub(elapsed) {
|
if let Some(sleep_time) = tick_interval.checked_sub(elapsed)
|
||||||
if !sleep_time.is_zero() {
|
&& !sleep_time.is_zero()
|
||||||
|
{
|
||||||
sleep(sleep_time).await;
|
sleep(sleep_time).await;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
self.last_tick = Instant::now();
|
self.last_tick = Instant::now();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -108,7 +108,7 @@ impl CustomBossbars {
|
|||||||
&mut self,
|
&mut self,
|
||||||
server: &Server,
|
server: &Server,
|
||||||
resource_location: String,
|
resource_location: String,
|
||||||
) -> Result<(), BossbarUpdateError> {
|
) -> Result<(), BossbarUpdateError<'_>> {
|
||||||
let bossbar = self.custom_bossbars.get_cloned(&resource_location);
|
let bossbar = self.custom_bossbars.get_cloned(&resource_location);
|
||||||
if let Some(bossbar) = bossbar {
|
if let Some(bossbar) = bossbar {
|
||||||
self.custom_bossbars.remove(&resource_location);
|
self.custom_bossbars.remove(&resource_location);
|
||||||
@ -144,7 +144,7 @@ impl CustomBossbars {
|
|||||||
resource_location: String,
|
resource_location: String,
|
||||||
max_value: u32,
|
max_value: u32,
|
||||||
value: u32,
|
value: u32,
|
||||||
) -> Result<(), BossbarUpdateError> {
|
) -> Result<(), BossbarUpdateError<'_>> {
|
||||||
let bossbar = self.custom_bossbars.get_mut(&resource_location);
|
let bossbar = self.custom_bossbars.get_mut(&resource_location);
|
||||||
if let Some(bossbar) = bossbar {
|
if let Some(bossbar) = bossbar {
|
||||||
if bossbar.value == value && bossbar.max == max_value {
|
if bossbar.value == value && bossbar.max == max_value {
|
||||||
@ -193,7 +193,7 @@ impl CustomBossbars {
|
|||||||
server: &Server,
|
server: &Server,
|
||||||
resource_location: String,
|
resource_location: String,
|
||||||
new_visibility: bool,
|
new_visibility: bool,
|
||||||
) -> Result<(), BossbarUpdateError> {
|
) -> Result<(), BossbarUpdateError<'_>> {
|
||||||
let bossbar = self.custom_bossbars.get_mut(&resource_location);
|
let bossbar = self.custom_bossbars.get_mut(&resource_location);
|
||||||
if let Some(bossbar) = bossbar {
|
if let Some(bossbar) = bossbar {
|
||||||
if bossbar.visible == new_visibility && new_visibility {
|
if bossbar.visible == new_visibility && new_visibility {
|
||||||
@ -232,7 +232,7 @@ impl CustomBossbars {
|
|||||||
server: &Server,
|
server: &Server,
|
||||||
resource_location: &str,
|
resource_location: &str,
|
||||||
new_title: TextComponent,
|
new_title: TextComponent,
|
||||||
) -> Result<(), BossbarUpdateError> {
|
) -> Result<(), BossbarUpdateError<'_>> {
|
||||||
let bossbar = self.custom_bossbars.get_mut(resource_location);
|
let bossbar = self.custom_bossbars.get_mut(resource_location);
|
||||||
if let Some(bossbar) = bossbar {
|
if let Some(bossbar) = bossbar {
|
||||||
if bossbar.bossbar_data.title == new_title {
|
if bossbar.bossbar_data.title == new_title {
|
||||||
@ -271,7 +271,7 @@ impl CustomBossbars {
|
|||||||
server: &Server,
|
server: &Server,
|
||||||
resource_location: String,
|
resource_location: String,
|
||||||
new_color: BossbarColor,
|
new_color: BossbarColor,
|
||||||
) -> Result<(), BossbarUpdateError> {
|
) -> Result<(), BossbarUpdateError<'_>> {
|
||||||
let bossbar = self.custom_bossbars.get_mut(&resource_location);
|
let bossbar = self.custom_bossbars.get_mut(&resource_location);
|
||||||
if let Some(bossbar) = bossbar {
|
if let Some(bossbar) = bossbar {
|
||||||
if bossbar.bossbar_data.color == new_color {
|
if bossbar.bossbar_data.color == new_color {
|
||||||
@ -311,7 +311,7 @@ impl CustomBossbars {
|
|||||||
server: &Server,
|
server: &Server,
|
||||||
resource_location: String,
|
resource_location: String,
|
||||||
new_division: BossbarDivisions,
|
new_division: BossbarDivisions,
|
||||||
) -> Result<(), BossbarUpdateError> {
|
) -> Result<(), BossbarUpdateError<'_>> {
|
||||||
let bossbar = self.custom_bossbars.get_mut(&resource_location);
|
let bossbar = self.custom_bossbars.get_mut(&resource_location);
|
||||||
if let Some(bossbar) = bossbar {
|
if let Some(bossbar) = bossbar {
|
||||||
if bossbar.bossbar_data.division == new_division {
|
if bossbar.bossbar_data.division == new_division {
|
||||||
@ -351,7 +351,7 @@ impl CustomBossbars {
|
|||||||
server: &Server,
|
server: &Server,
|
||||||
resource_location: String,
|
resource_location: String,
|
||||||
new_players: Vec<Uuid>,
|
new_players: Vec<Uuid>,
|
||||||
) -> Result<(), BossbarUpdateError> {
|
) -> Result<(), BossbarUpdateError<'_>> {
|
||||||
let bossbar = self.custom_bossbars.get_mut(&resource_location);
|
let bossbar = self.custom_bossbars.get_mut(&resource_location);
|
||||||
if let Some(bossbar) = bossbar {
|
if let Some(bossbar) = bossbar {
|
||||||
// Get the difference between the old and new player list and remove bossbars from old players.
|
// Get the difference between the old and new player list and remove bossbars from old players.
|
||||||
|
|||||||
@ -53,21 +53,21 @@ trait LootPoolEntryExt {
|
|||||||
|
|
||||||
impl LootPoolEntryExt for LootPoolEntry {
|
impl LootPoolEntryExt for LootPoolEntry {
|
||||||
fn get_loot(&self, params: &LootContextParameters) -> Option<Vec<ItemStack>> {
|
fn get_loot(&self, params: &LootContextParameters) -> Option<Vec<ItemStack>> {
|
||||||
if let Some(conditions) = self.conditions {
|
if let Some(conditions) = self.conditions
|
||||||
if !conditions.iter().all(|cond| cond.is_fulfilled(params)) {
|
&& !conditions.iter().all(|cond| cond.is_fulfilled(params))
|
||||||
|
{
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
let mut stacks = self.content.get_stacks(params);
|
let mut stacks = self.content.get_stacks(params);
|
||||||
|
|
||||||
if let Some(functions) = self.functions {
|
if let Some(functions) = self.functions {
|
||||||
for function in functions {
|
for function in functions {
|
||||||
if let Some(conditions) = function.conditions {
|
if let Some(conditions) = function.conditions
|
||||||
if !conditions.iter().all(|cond| cond.is_fulfilled(params)) {
|
&& !conditions.iter().all(|cond| cond.is_fulfilled(params))
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
match &function.content {
|
match &function.content {
|
||||||
LootFunctionTypes::SetCount { count, add } => {
|
LootFunctionTypes::SetCount { count, add } => {
|
||||||
|
|||||||
@ -3061,11 +3061,11 @@ impl World {
|
|||||||
let mut block = BlockPos::floored(from.x, from.y, from.z);
|
let mut block = BlockPos::floored(from.x, from.y, from.z);
|
||||||
|
|
||||||
let (collision, direction) = self.ray_outline_check(&block, from, to).await;
|
let (collision, direction) = self.ray_outline_check(&block, from, to).await;
|
||||||
if let Some(dir) = direction {
|
if let Some(dir) = direction
|
||||||
if collision {
|
&& collision
|
||||||
|
{
|
||||||
return Some((block, dir));
|
return Some((block, dir));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
let difference = to.sub(&from);
|
let difference = to.sub(&from);
|
||||||
|
|
||||||
|
|||||||
@ -16,12 +16,12 @@ impl EndPortal {
|
|||||||
|
|
||||||
pub async fn get_new_portal(world: &Arc<World>, pos: BlockPos) {
|
pub async fn get_new_portal(world: &Arc<World>, pos: BlockPos) {
|
||||||
let mid_pos = Self::get_mid_pos(world, pos);
|
let mid_pos = Self::get_mid_pos(world, pos);
|
||||||
if let Some(mid_pos) = mid_pos.await {
|
if let Some(mid_pos) = mid_pos.await
|
||||||
if Self::is_valid_portal(world, mid_pos).await {
|
&& Self::is_valid_portal(world, mid_pos).await
|
||||||
|
{
|
||||||
Self::create_portal(world, mid_pos).await;
|
Self::create_portal(world, mid_pos).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
async fn get_mid_pos(world: &World, pos: BlockPos) -> Option<BlockPos> {
|
async fn get_mid_pos(world: &World, pos: BlockPos) -> Option<BlockPos> {
|
||||||
let (block, state) = world.get_block_and_state_id(&pos).await;
|
let (block, state) = world.get_block_and_state_id(&pos).await;
|
||||||
|
|||||||
@ -71,21 +71,23 @@ impl NetherPortal {
|
|||||||
first_axis: HorizontalAxis,
|
first_axis: HorizontalAxis,
|
||||||
) -> Option<Self> {
|
) -> Option<Self> {
|
||||||
// We check both axis here X and Z
|
// We check both axis here X and Z
|
||||||
if let Some(portal) = Self::get_on_axis(world, pos, first_axis).await {
|
if let Some(portal) = Self::get_on_axis(world, pos, first_axis).await
|
||||||
if portal.is_valid() && portal.found_portal_blocks == 0 {
|
&& portal.is_valid()
|
||||||
|
&& portal.found_portal_blocks == 0
|
||||||
|
{
|
||||||
return Some(portal);
|
return Some(portal);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
let next_axis = if first_axis == HorizontalAxis::X {
|
let next_axis = if first_axis == HorizontalAxis::X {
|
||||||
HorizontalAxis::Z
|
HorizontalAxis::Z
|
||||||
} else {
|
} else {
|
||||||
HorizontalAxis::X
|
HorizontalAxis::X
|
||||||
};
|
};
|
||||||
if let Some(portal) = Self::get_on_axis(world, pos, next_axis).await {
|
if let Some(portal) = Self::get_on_axis(world, pos, next_axis).await
|
||||||
if portal.is_valid() && portal.found_portal_blocks == 0 {
|
&& portal.is_valid()
|
||||||
|
&& portal.found_portal_blocks == 0
|
||||||
|
{
|
||||||
return Some(portal);
|
return Some(portal);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user