chore: enforce some more clippy lints
pumpkin contributors will love me :cap:
This commit is contained in:
parent
4ad5b2ba03
commit
2fcc9bcf4a
26
Cargo.lock
generated
26
Cargo.lock
generated
@ -488,7 +488,7 @@ version = "3.1.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "faf9468729b8cbcea668e36183cb69d317348c2e08e994829fb56ebfdfbaac34"
|
checksum = "faf9468729b8cbcea668e36183cb69d317348c2e08e994829fb56ebfdfbaac34"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.61.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -969,9 +969,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dashmap"
|
name = "dashmap"
|
||||||
version = "6.1.0"
|
version = "6.2.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5041cc499144891f3790297212f32a74fb938e5136a14943f338ef9e0ae276cf"
|
checksum = "e6361d5c062261c78a176addb82d4c821ae42bed6089de0e12603cd25de2059c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"crossbeam-utils",
|
"crossbeam-utils",
|
||||||
@ -1112,9 +1112,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "either"
|
name = "either"
|
||||||
version = "1.15.0"
|
version = "1.16.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
|
checksum = "91622ff5e7162018101f2fea40d6ebf4a78bbe5a49736a2020649edf9693679e"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "elliptic-curve"
|
name = "elliptic-curve"
|
||||||
@ -1189,7 +1189,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
|
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.61.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -1663,9 +1663,9 @@ checksum = "135b12329e5e3ce057a9f972339ea52bc954fe1e9358ef27f95e89716fbc5424"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hybrid-array"
|
name = "hybrid-array"
|
||||||
version = "0.4.11"
|
version = "0.4.12"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "08d46837a0ed51fe95bd3b05de33cd64a1ee88fc797477ca48446872504507c5"
|
checksum = "9155a582abd142abc056962c29e3ce5ff2ad5469f4246b537ed42c5deba857da"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"typenum",
|
"typenum",
|
||||||
]
|
]
|
||||||
@ -2284,7 +2284,7 @@ version = "0.50.3"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5"
|
checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-sys 0.59.0",
|
"windows-sys 0.61.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -3316,7 +3316,7 @@ dependencies = [
|
|||||||
"errno",
|
"errno",
|
||||||
"libc",
|
"libc",
|
||||||
"linux-raw-sys 0.12.1",
|
"linux-raw-sys 0.12.1",
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.61.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -3644,7 +3644,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e"
|
checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"windows-sys 0.60.2",
|
"windows-sys 0.61.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -3781,7 +3781,7 @@ dependencies = [
|
|||||||
"getrandom 0.4.2",
|
"getrandom 0.4.2",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"rustix 1.1.4",
|
"rustix 1.1.4",
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.61.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -4930,7 +4930,7 @@ version = "0.1.11"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
|
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.61.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|||||||
11
Cargo.toml
11
Cargo.toml
@ -46,6 +46,11 @@ significant_drop_in_scrutinee = "deny"
|
|||||||
print_stdout = "deny"
|
print_stdout = "deny"
|
||||||
print_stderr = "deny"
|
print_stderr = "deny"
|
||||||
|
|
||||||
|
todo = "deny"
|
||||||
|
unreachable = "deny"
|
||||||
|
unimplemented = "deny"
|
||||||
|
# indexing_slicing = "deny"
|
||||||
|
|
||||||
# Expected/Allowed
|
# Expected/Allowed
|
||||||
cargo_common_metadata = "allow"
|
cargo_common_metadata = "allow"
|
||||||
cast_precision_loss = "allow"
|
cast_precision_loss = "allow"
|
||||||
@ -123,9 +128,9 @@ criterion = { version = "0.8", default-features = false }
|
|||||||
crossbeam-utils = "0.8.21"
|
crossbeam-utils = "0.8.21"
|
||||||
crossfire = { version = "3.1.12", features = ["compat"] }
|
crossfire = { version = "3.1.12", features = ["compat"] }
|
||||||
crypto-bigint = "0.7.3"
|
crypto-bigint = "0.7.3"
|
||||||
dashmap = "6.1"
|
dashmap = "6.2"
|
||||||
ecdsa = "0.16.9"
|
ecdsa = "0.16.9"
|
||||||
either = "1.15.0"
|
either = "1.16.0"
|
||||||
enum_dispatch = "0.3.13"
|
enum_dispatch = "0.3.13"
|
||||||
flate2 = "1.1.9"
|
flate2 = "1.1.9"
|
||||||
heck = "0.5"
|
heck = "0.5"
|
||||||
@ -154,7 +159,7 @@ pumpkin-world = { path = "pumpkin-world" }
|
|||||||
quote = "1.0"
|
quote = "1.0"
|
||||||
rand = "0.10.1"
|
rand = "0.10.1"
|
||||||
rsa = "=0.10.0-rc.18"
|
rsa = "=0.10.0-rc.18"
|
||||||
cipher = "0.5.1"
|
cipher = "0.5.2"
|
||||||
rustc-hash = "2.1.2"
|
rustc-hash = "2.1.2"
|
||||||
rustyline = "18.0.0"
|
rustyline = "18.0.0"
|
||||||
ruzstd = "0.8.3"
|
ruzstd = "0.8.3"
|
||||||
|
|||||||
@ -572,30 +572,23 @@ impl<R> DataResult<R> {
|
|||||||
///
|
///
|
||||||
/// The [`Lifecycle`] of the returned `DataResult` is the addition of both results.
|
/// The [`Lifecycle`] of the returned `DataResult` is the addition of both results.
|
||||||
pub fn with_errors_from<T>(self, result: &DataResult<T>) -> Self {
|
pub fn with_errors_from<T>(self, result: &DataResult<T>) -> Self {
|
||||||
match (&self, result) {
|
let current_lifecycle = self.lifecycle();
|
||||||
// If both values are successes, do nothing.
|
|
||||||
// If `self` is already an error result, do nothing.
|
match (self, result) {
|
||||||
(Self::Success { .. }, DataResult::Success { .. }) | (Self::Error { .. }, _) => self,
|
(s @ Self::Error { .. }, _) | (s, DataResult::Success { .. }) => s,
|
||||||
|
|
||||||
(
|
(
|
||||||
Self::Success { .. },
|
Self::Success { result: val, .. },
|
||||||
DataResult::Error {
|
DataResult::Error {
|
||||||
message,
|
message,
|
||||||
lifecycle: other_lifecycle,
|
lifecycle: other_lifecycle,
|
||||||
..
|
..
|
||||||
},
|
},
|
||||||
) => {
|
) => Self::new_partial_error_with_lifecycle(
|
||||||
let self_lifecycle = self.lifecycle();
|
message.clone(),
|
||||||
if let Self::Success { result, .. } = self {
|
val,
|
||||||
Self::new_partial_error_with_lifecycle(
|
current_lifecycle.add(*other_lifecycle),
|
||||||
message.clone(),
|
),
|
||||||
result,
|
|
||||||
self_lifecycle.add(*other_lifecycle),
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
unreachable!()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -922,7 +922,7 @@ pub fn build() -> TokenStream {
|
|||||||
// block_with_descriptors.property_descriptors = property_descriptors;
|
// block_with_descriptors.property_descriptors = property_descriptors;
|
||||||
|
|
||||||
constants_list.push(quote! {
|
constants_list.push(quote! {
|
||||||
pub const #const_ident: Block = #block;
|
pub const #const_ident: Self = #block;
|
||||||
});
|
});
|
||||||
|
|
||||||
type_from_raw_id_array.push((block.id, quote! { &Self::#const_ident }));
|
type_from_raw_id_array.push((block.id, quote! { &Self::#const_ident }));
|
||||||
@ -1119,6 +1119,7 @@ pub fn build() -> TokenStream {
|
|||||||
);
|
);
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
|
#[allow(clippy::wildcard_imports, clippy::enum_glob_use, clippy::too_many_lines, clippy::match_same_arms)]
|
||||||
use pumpkin_util::math::boundingbox::BoundingBox;
|
use pumpkin_util::math::boundingbox::BoundingBox;
|
||||||
|
|
||||||
use crate::{BlockState, Block, blocks::Flammable};
|
use crate::{BlockState, Block, blocks::Flammable};
|
||||||
@ -1166,20 +1167,24 @@ pub fn build() -> TokenStream {
|
|||||||
];
|
];
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn is_air(state_id: u16) -> bool {
|
#[must_use]
|
||||||
|
pub const fn is_air(state_id: u16) -> bool {
|
||||||
matches!(state_id, #air_state_ids)
|
matches!(state_id, #air_state_ids)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn is_liquid(state_id: u16) -> bool {
|
#[must_use]
|
||||||
|
pub const fn is_liquid(state_id: u16) -> bool {
|
||||||
matches!(state_id, #liquid_state_ids)
|
matches!(state_id, #liquid_state_ids)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
|
#[must_use]
|
||||||
pub fn has_random_ticks(state_id: u16) -> bool {
|
pub fn has_random_ticks(state_id: u16) -> bool {
|
||||||
#mod_ident::#contains_ident(state_id)
|
#mod_ident::#contains_ident(state_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn blocks_movement(block_state: &BlockState, block: u16) -> bool {
|
pub fn blocks_movement(block_state: &BlockState, block: u16) -> bool {
|
||||||
if block_state.is_solid() {
|
if block_state.is_solid() {
|
||||||
return block != Block::COBWEB && block != Block::BAMBOO_SAPLING;
|
return block != Block::COBWEB && block != Block::BAMBOO_SAPLING;
|
||||||
@ -1195,6 +1200,7 @@ pub fn build() -> TokenStream {
|
|||||||
#[doc = r" Get a block state from a state id."]
|
#[doc = r" Get a block state from a state id."]
|
||||||
#[doc = r" If you need access to the block use `BlockState::from_id_with_block` instead."]
|
#[doc = r" If you need access to the block use `BlockState::from_id_with_block` instead."]
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
pub fn from_id(id: u16) -> &'static Self {
|
pub fn from_id(id: u16) -> &'static Self {
|
||||||
// In debug, this avoids the slow range-checking logic
|
// In debug, this avoids the slow range-checking logic
|
||||||
unsafe {
|
unsafe {
|
||||||
@ -1204,13 +1210,15 @@ pub fn build() -> TokenStream {
|
|||||||
|
|
||||||
#[doc = r" Get a block state from a state id and the corresponding block."]
|
#[doc = r" Get a block state from a state id and the corresponding block."]
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
pub fn from_id_with_block(id: u16) -> (&'static Block, &'static Self) {
|
pub fn from_id_with_block(id: u16) -> (&'static Block, &'static Self) {
|
||||||
let block = Block::from_state_id(id);
|
let block = Block::from_state_id(id);
|
||||||
let state: &Self = Block::STATE_FROM_STATE_ID[id as usize];
|
let state: &Self = Block::STATE_FROM_STATE_ID[id as usize];
|
||||||
(block, state)
|
(block, state)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_be_network_id(id: u16) -> u16 {
|
#[must_use]
|
||||||
|
pub const fn to_be_network_id(id: u16) -> u16 {
|
||||||
Self::STATE_ID_TO_BEDROCK[id as usize]
|
Self::STATE_ID_TO_BEDROCK[id as usize]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1226,7 +1234,7 @@ pub fn build() -> TokenStream {
|
|||||||
#raw_id_from_state_id
|
#raw_id_from_state_id
|
||||||
];
|
];
|
||||||
|
|
||||||
const TYPE_FROM_RAW_ID: [&'static Block; #max_type_id] = [
|
const TYPE_FROM_RAW_ID: [&'static Self; #max_type_id] = [
|
||||||
#type_from_raw_id_items
|
#type_from_raw_id_items
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -1236,11 +1244,13 @@ pub fn build() -> TokenStream {
|
|||||||
|
|
||||||
#[doc = r" Try to parse a block from a resource location string."]
|
#[doc = r" Try to parse a block from a resource location string."]
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
pub fn from_registry_key(name: &str) -> Option<&'static Self> {
|
pub fn from_registry_key(name: &str) -> Option<&'static Self> {
|
||||||
Self::BLOCK_FROM_NAME_MAP.get(name)
|
Self::BLOCK_FROM_NAME_MAP.get(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = r" Try to get a block from a namespace prefixed name."]
|
#[doc = r" Try to get a block from a namespace prefixed name."]
|
||||||
|
#[must_use]
|
||||||
pub fn from_name(name: &str) -> Option<&'static Self> {
|
pub fn from_name(name: &str) -> Option<&'static Self> {
|
||||||
let key = name.strip_prefix("minecraft:").unwrap_or(name);
|
let key = name.strip_prefix("minecraft:").unwrap_or(name);
|
||||||
Self::BLOCK_FROM_NAME_MAP.get(key)
|
Self::BLOCK_FROM_NAME_MAP.get(key)
|
||||||
@ -1248,6 +1258,7 @@ pub fn build() -> TokenStream {
|
|||||||
|
|
||||||
#[doc = r" Get a block from a raw block id."]
|
#[doc = r" Get a block from a raw block id."]
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
pub const fn from_id(id: u16) -> &'static Self {
|
pub const fn from_id(id: u16) -> &'static Self {
|
||||||
if id as usize >= Self::RAW_ID_FROM_STATE_ID.len() {
|
if id as usize >= Self::RAW_ID_FROM_STATE_ID.len() {
|
||||||
&Self::AIR
|
&Self::AIR
|
||||||
@ -1258,7 +1269,8 @@ pub fn build() -> TokenStream {
|
|||||||
|
|
||||||
#[doc = r" Get a raw ID from an State ID."]
|
#[doc = r" Get a raw ID from an State ID."]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_raw_id_from_state_id(state_id: u16) -> u16 {
|
#[must_use]
|
||||||
|
pub fn get_raw_id_from_state_id(state_id: u16) -> u16 {
|
||||||
let index = state_id as usize;
|
let index = state_id as usize;
|
||||||
if index >= Self::RAW_ID_FROM_STATE_ID.len() {
|
if index >= Self::RAW_ID_FROM_STATE_ID.len() {
|
||||||
0
|
0
|
||||||
@ -1269,6 +1281,7 @@ pub fn build() -> TokenStream {
|
|||||||
|
|
||||||
#[doc = r" Get a block from a state id."]
|
#[doc = r" Get a block from a state id."]
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
pub fn from_state_id(id: u16) -> &'static Self {
|
pub fn from_state_id(id: u16) -> &'static Self {
|
||||||
let index = id as usize;
|
let index = id as usize;
|
||||||
if index >= Self::RAW_ID_FROM_STATE_ID.len() {
|
if index >= Self::RAW_ID_FROM_STATE_ID.len() {
|
||||||
@ -1279,6 +1292,7 @@ pub fn build() -> TokenStream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[doc = r" Try to parse a block from an item id."]
|
#[doc = r" Try to parse a block from an item id."]
|
||||||
|
#[must_use]
|
||||||
pub const fn from_item_id(id: u16) -> Option<&'static Self> {
|
pub const fn from_item_id(id: u16) -> Option<&'static Self> {
|
||||||
#[allow(unreachable_patterns)]
|
#[allow(unreachable_patterns)]
|
||||||
match id {
|
match id {
|
||||||
@ -1311,28 +1325,31 @@ pub fn build() -> TokenStream {
|
|||||||
#(#block_props)*
|
#(#block_props)*
|
||||||
|
|
||||||
impl Facing {
|
impl Facing {
|
||||||
pub fn opposite(&self) -> Self {
|
#[must_use]
|
||||||
|
pub const fn opposite(&self) -> Self {
|
||||||
match self {
|
match self {
|
||||||
Facing::North => Facing::South,
|
Self::North => Self::South,
|
||||||
Facing::South => Facing::North,
|
Self::South => Self::North,
|
||||||
Facing::East => Facing::West,
|
Self::East => Self::West,
|
||||||
Facing::West => Facing::East,
|
Self::West => Self::East,
|
||||||
Facing::Up => Facing::Down,
|
Self::Up => Self::Down,
|
||||||
Facing::Down => Facing::Up,
|
Self::Down => Self::Up,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HorizontalFacing {
|
impl HorizontalFacing {
|
||||||
pub fn all() -> [HorizontalFacing; 4] {
|
#[must_use]
|
||||||
|
pub fn all() -> [Self; 4] {
|
||||||
[
|
[
|
||||||
HorizontalFacing::North,
|
Self::North,
|
||||||
HorizontalFacing::South,
|
Self::South,
|
||||||
HorizontalFacing::West,
|
Self::West,
|
||||||
HorizontalFacing::East,
|
Self::East,
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn to_offset(&self) -> Vector3<i32> {
|
pub fn to_offset(&self) -> Vector3<i32> {
|
||||||
match self {
|
match self {
|
||||||
Self::North => (0, 0, -1),
|
Self::North => (0, 0, -1),
|
||||||
@ -1343,7 +1360,8 @@ pub fn build() -> TokenStream {
|
|||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn opposite(&self) -> Self {
|
#[must_use]
|
||||||
|
pub const fn opposite(&self) -> Self {
|
||||||
match self {
|
match self {
|
||||||
Self::North => Self::South,
|
Self::North => Self::South,
|
||||||
Self::South => Self::North,
|
Self::South => Self::North,
|
||||||
@ -1352,7 +1370,8 @@ pub fn build() -> TokenStream {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn rotate_clockwise(&self) -> Self {
|
#[must_use]
|
||||||
|
pub const fn rotate_clockwise(&self) -> Self {
|
||||||
match self {
|
match self {
|
||||||
Self::North => Self::East,
|
Self::North => Self::East,
|
||||||
Self::South => Self::West,
|
Self::South => Self::West,
|
||||||
@ -1361,7 +1380,8 @@ pub fn build() -> TokenStream {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn rotate_counter_clockwise(&self) -> Self {
|
#[must_use]
|
||||||
|
pub const fn rotate_counter_clockwise(&self) -> Self {
|
||||||
match self {
|
match self {
|
||||||
Self::North => Self::West,
|
Self::North => Self::West,
|
||||||
Self::South => Self::East,
|
Self::South => Self::East,
|
||||||
@ -1372,13 +1392,15 @@ pub fn build() -> TokenStream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl RailShape {
|
impl RailShape {
|
||||||
pub fn is_ascending(&self) -> bool {
|
#[must_use]
|
||||||
|
pub const fn is_ascending(&self) -> bool {
|
||||||
matches!(self, Self::AscendingEast | Self::AscendingWest | Self::AscendingNorth | Self::AscendingSouth)
|
matches!(self, Self::AscendingEast | Self::AscendingWest | Self::AscendingNorth | Self::AscendingSouth)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RailShapeStraight {
|
impl RailShapeStraight {
|
||||||
pub fn is_ascending(&self) -> bool {
|
#[must_use]
|
||||||
|
pub const fn is_ascending(&self) -> bool {
|
||||||
matches!(self, Self::AscendingEast | Self::AscendingWest | Self::AscendingNorth | Self::AscendingSouth)
|
matches!(self, Self::AscendingEast | Self::AscendingWest | Self::AscendingNorth | Self::AscendingSouth)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -138,6 +138,7 @@ pub fn build() -> TokenStream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl CaveCarverConfig {
|
impl CaveCarverConfig {
|
||||||
|
#[must_use]
|
||||||
pub const fn default() -> Self {
|
pub const fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
horizontal_radius_multiplier: FloatProvider::Constant(1.0),
|
horizontal_radius_multiplier: FloatProvider::Constant(1.0),
|
||||||
|
|||||||
@ -153,6 +153,7 @@ pub fn build() -> TokenStream {
|
|||||||
|
|
||||||
// Emit get_chest_loot_table
|
// Emit get_chest_loot_table
|
||||||
all_tokens.extend(quote! {
|
all_tokens.extend(quote! {
|
||||||
|
#[must_use]
|
||||||
pub fn get_chest_loot_table(key: &str) -> Option<&'static ChestLootTable> {
|
pub fn get_chest_loot_table(key: &str) -> Option<&'static ChestLootTable> {
|
||||||
match key {
|
match key {
|
||||||
#(#table_keys => Some(&#table_idents),)*
|
#(#table_keys => Some(&#table_idents),)*
|
||||||
|
|||||||
@ -492,6 +492,7 @@ pub fn build() -> TokenStream {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn trim_height(&self, bottom_y: i8, top_y: u16) -> Self {
|
pub fn trim_height(&self, bottom_y: i8, top_y: u16) -> Self {
|
||||||
let new_min = self.min_y.max(bottom_y);
|
let new_min = self.min_y.max(bottom_y);
|
||||||
let this_top = if self.min_y >= 0 {
|
let this_top = if self.min_y >= 0 {
|
||||||
@ -599,6 +600,7 @@ pub fn build() -> TokenStream {
|
|||||||
impl GenerationSettings {
|
impl GenerationSettings {
|
||||||
#const_defs
|
#const_defs
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn from_dimension(dimension: &Dimension) -> &'static Self {
|
pub fn from_dimension(dimension: &Dimension) -> &'static Self {
|
||||||
if dimension == &Dimension::OVERWORLD {
|
if dimension == &Dimension::OVERWORLD {
|
||||||
&Self::OVERWORLD
|
&Self::OVERWORLD
|
||||||
|
|||||||
@ -23,6 +23,7 @@ pub fn build() -> TokenStream {
|
|||||||
.collect();
|
.collect();
|
||||||
quote! {
|
quote! {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
|
#[allow(clippy::too_many_lines, clippy::match_same_arms)]
|
||||||
pub const fn get_composter_increase_chance_from_item_id(item_id: u16) -> Option<f32> {
|
pub const fn get_composter_increase_chance_from_item_id(item_id: u16) -> Option<f32> {
|
||||||
match item_id {
|
match item_id {
|
||||||
#(#match_arms)*
|
#(#match_arms)*
|
||||||
|
|||||||
@ -31,12 +31,12 @@ pub fn build() -> TokenStream {
|
|||||||
});
|
});
|
||||||
|
|
||||||
id_to_enum.extend(quote! {
|
id_to_enum.extend(quote! {
|
||||||
#raw_value => Some(DataComponent::#pascal_case),
|
#raw_value => Some(Self::#pascal_case),
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO use phf
|
// TODO use phf
|
||||||
name_to_enum.extend(quote! {
|
name_to_enum.extend(quote! {
|
||||||
#raw_name => Some(DataComponent::#pascal_case),
|
#raw_name => Some(Self::#pascal_case),
|
||||||
});
|
});
|
||||||
|
|
||||||
// Enum -> &str
|
// Enum -> &str
|
||||||
@ -55,21 +55,31 @@ pub fn build() -> TokenStream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl DataComponent {
|
impl DataComponent {
|
||||||
|
#[must_use]
|
||||||
pub const fn to_id(self) -> u8 {
|
pub const fn to_id(self) -> u8 {
|
||||||
self as u8
|
self as u8
|
||||||
}
|
}
|
||||||
pub const fn try_from_id(id: u8) -> Option<DataComponent> {
|
|
||||||
|
#[must_use]
|
||||||
|
#[allow(clippy::too_many_lines)]
|
||||||
|
pub const fn try_from_id(id: u8) -> Option<Self> {
|
||||||
match id {
|
match id {
|
||||||
#id_to_enum
|
#id_to_enum
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn try_from_name(name: &str) -> Option<DataComponent> {
|
|
||||||
|
#[must_use]
|
||||||
|
#[allow(clippy::too_many_lines)]
|
||||||
|
pub fn try_from_name(name: &str) -> Option<Self> {
|
||||||
match name {
|
match name {
|
||||||
#name_to_enum
|
#name_to_enum
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
|
#[allow(clippy::too_many_lines)]
|
||||||
pub const fn to_name(self) -> &'static str {
|
pub const fn to_name(self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
#enum_to_name
|
#enum_to_name
|
||||||
|
|||||||
@ -157,12 +157,15 @@ pub fn build() -> TokenStream {
|
|||||||
impl StatusEffect {
|
impl StatusEffect {
|
||||||
#variants
|
#variants
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn from_name(name: &str) -> Option<&'static Self> {
|
pub fn from_name(name: &str) -> Option<&'static Self> {
|
||||||
match name {
|
match name {
|
||||||
#name_to_type
|
#name_to_type
|
||||||
_ => None
|
_ => None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn from_minecraft_name(name: &str) -> Option<&'static Self> {
|
pub fn from_minecraft_name(name: &str) -> Option<&'static Self> {
|
||||||
match name {
|
match name {
|
||||||
#minecraft_name_to_type
|
#minecraft_name_to_type
|
||||||
@ -171,10 +174,12 @@ pub fn build() -> TokenStream {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl IDSetContent for StatusEffect {
|
impl IDSetContent for StatusEffect {
|
||||||
|
#[must_use]
|
||||||
fn registry_id(&self) -> u16 {
|
fn registry_id(&self) -> u16 {
|
||||||
self.id as u16
|
self.id as u16
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
fn from_id(id: u16) -> Option<&'static Self> {
|
fn from_id(id: u16) -> Option<&'static Self> {
|
||||||
match id {
|
match id {
|
||||||
#id_to_type
|
#id_to_type
|
||||||
@ -182,10 +187,12 @@ pub fn build() -> TokenStream {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
fn from_str(name: &str) -> Option<&'static Self> {
|
fn from_str(name: &str) -> Option<&'static Self> {
|
||||||
StatusEffect::from_minecraft_name(name)
|
Self::from_minecraft_name(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
fn to_string(&self) -> String {
|
fn to_string(&self) -> String {
|
||||||
self.minecraft_name.to_string()
|
self.minecraft_name.to_string()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,6 +32,7 @@ pub fn build() -> TokenStream {
|
|||||||
];
|
];
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
|
#[allow(clippy::too_many_lines, clippy::match_same_arms)]
|
||||||
pub const fn get_item_burn_ticks(item_id: u16) -> Option<u16> {
|
pub const fn get_item_burn_ticks(item_id: u16) -> Option<u16> {
|
||||||
match item_id {
|
match item_id {
|
||||||
#(#burn_tick_list_tokens)*
|
#(#burn_tick_list_tokens)*
|
||||||
|
|||||||
@ -796,7 +796,7 @@ pub fn build() -> TokenStream {
|
|||||||
let id_lit = LitInt::new(&item.id.to_string(), Span::call_site());
|
let id_lit = LitInt::new(&item.id.to_string(), Span::call_site());
|
||||||
|
|
||||||
constants.extend(quote! {
|
constants.extend(quote! {
|
||||||
pub const #const_ident: Item = Item {
|
pub const #const_ident: Self = Self {
|
||||||
id: #id_lit,
|
id: #id_lit,
|
||||||
registry_key: #name,
|
registry_key: #name,
|
||||||
components: &[#components_tokens],
|
components: &[#components_tokens],
|
||||||
@ -813,6 +813,7 @@ pub fn build() -> TokenStream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
|
#[allow(clippy::wildcard_imports, clippy::enum_glob_use, clippy::too_many_lines)]
|
||||||
use crate::data_component::DataComponent::*;
|
use crate::data_component::DataComponent::*;
|
||||||
use crate::data_component_impl::*;
|
use crate::data_component_impl::*;
|
||||||
use crate::tag::{RegistryKey, Taggable};
|
use crate::tag::{RegistryKey, Taggable};
|
||||||
@ -851,21 +852,18 @@ pub fn build() -> TokenStream {
|
|||||||
impl Item {
|
impl Item {
|
||||||
#constants
|
#constants
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn translated_name(&self) -> TextComponent {
|
pub fn translated_name(&self) -> TextComponent {
|
||||||
TextComponent::translate(
|
TextComponent::translate(
|
||||||
self.components
|
self.components
|
||||||
.iter()
|
.iter()
|
||||||
.find_map(|(id, data)| if id == &ItemName {
|
.find_map(|(id, data)| (id == &ItemName).then(|| data.as_any().downcast_ref::<ItemNameImpl>().unwrap().name)).unwrap(),
|
||||||
Some(data.as_any().downcast_ref::<ItemNameImpl>().unwrap().name)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
).unwrap(),
|
|
||||||
&[],
|
&[],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "Try to parse an item from a resource location string."]
|
#[doc = "Try to parse an item from a resource location string."]
|
||||||
|
#[must_use]
|
||||||
pub fn from_registry_key(name: &str) -> Option<&'static Self> {
|
pub fn from_registry_key(name: &str) -> Option<&'static Self> {
|
||||||
let name = name.strip_prefix("minecraft:").unwrap_or(name);
|
let name = name.strip_prefix("minecraft:").unwrap_or(name);
|
||||||
match name {
|
match name {
|
||||||
@ -875,6 +873,7 @@ pub fn build() -> TokenStream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "Try to parse an item from a raw id."]
|
#[doc = "Try to parse an item from a raw id."]
|
||||||
|
#[must_use]
|
||||||
pub const fn from_id(id: u16) -> Option<&'static Self> {
|
pub const fn from_id(id: u16) -> Option<&'static Self> {
|
||||||
match id {
|
match id {
|
||||||
#type_from_raw_id_arms
|
#type_from_raw_id_arms
|
||||||
|
|||||||
@ -105,7 +105,8 @@ pub fn build() -> TokenStream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl JukeboxSong {
|
impl JukeboxSong {
|
||||||
#[doc = r" Returns the JukeboxSong from the string name (e.g., 'pigstep')."]
|
#[doc = r" Returns the `JukeboxSong` from the string name (e.g., 'pigstep')."]
|
||||||
|
#[must_use]
|
||||||
pub fn from_name(name: &str) -> Option<Self> {
|
pub fn from_name(name: &str) -> Option<Self> {
|
||||||
match name {
|
match name {
|
||||||
#type_from_name
|
#type_from_name
|
||||||
@ -114,6 +115,7 @@ pub fn build() -> TokenStream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[doc = r" Returns the string name of the song."]
|
#[doc = r" Returns the string name of the song."]
|
||||||
|
#[must_use]
|
||||||
pub const fn to_name(&self) -> &'static str {
|
pub const fn to_name(&self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
#type_to_name
|
#type_to_name
|
||||||
@ -121,6 +123,7 @@ pub fn build() -> TokenStream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[doc = r" Returns the numeric ID associated with the song."]
|
#[doc = r" Returns the numeric ID associated with the song."]
|
||||||
|
#[must_use]
|
||||||
pub const fn get_id(&self) -> u32 {
|
pub const fn get_id(&self) -> u32 {
|
||||||
match self {
|
match self {
|
||||||
#type_to_id
|
#type_to_id
|
||||||
@ -128,20 +131,25 @@ pub fn build() -> TokenStream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[doc = r" Returns the comparator output value (0-15) for this song."]
|
#[doc = r" Returns the comparator output value (0-15) for this song."]
|
||||||
|
#[must_use]
|
||||||
pub const fn comparator_output(&self) -> u8 {
|
pub const fn comparator_output(&self) -> u8 {
|
||||||
|
#[allow(clippy::match_same_arms)]
|
||||||
match self {
|
match self {
|
||||||
#type_to_comparator
|
#type_to_comparator
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = r" Returns the song length in seconds."]
|
#[doc = r" Returns the song length in seconds."]
|
||||||
|
#[must_use]
|
||||||
pub const fn length_in_seconds(&self) -> u32 {
|
pub const fn length_in_seconds(&self) -> u32 {
|
||||||
|
#[allow(clippy::match_same_arms)]
|
||||||
match self {
|
match self {
|
||||||
#type_to_length
|
#type_to_length
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = r" Returns the song length in ticks (20 ticks per second)."]
|
#[doc = r" Returns the song length in ticks (20 ticks per second)."]
|
||||||
|
#[must_use]
|
||||||
pub const fn length_in_ticks(&self) -> u64 {
|
pub const fn length_in_ticks(&self) -> u64 {
|
||||||
self.length_in_seconds() as u64 * 20
|
self.length_in_seconds() as u64 * 20
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1278,7 +1278,8 @@ pub fn build() -> TokenStream {
|
|||||||
|
|
||||||
impl WeirdScaledMapper {
|
impl WeirdScaledMapper {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn max_multiplier(&self) -> f64 {
|
#[must_use]
|
||||||
|
pub const fn max_multiplier(&self) -> f64 {
|
||||||
match self {
|
match self {
|
||||||
Self::Tunnels => 2.0,
|
Self::Tunnels => 2.0,
|
||||||
Self::Caves => 3.0,
|
Self::Caves => 3.0,
|
||||||
@ -1286,7 +1287,9 @@ pub fn build() -> TokenStream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn scale(&self, value: f64) -> f64 {
|
#[must_use]
|
||||||
|
#[allow(clippy::too_many_lines)]
|
||||||
|
pub const fn scale(&self, value: f64) -> f64 {
|
||||||
match self {
|
match self {
|
||||||
Self::Tunnels => {
|
Self::Tunnels => {
|
||||||
if value < -0.5 {
|
if value < -0.5 {
|
||||||
@ -1361,7 +1364,8 @@ pub fn build() -> TokenStream {
|
|||||||
|
|
||||||
impl LinearData {
|
impl LinearData {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn apply_density(&self, density: f64) -> f64 {
|
#[must_use]
|
||||||
|
pub const fn apply_density(&self, density: f64) -> f64 {
|
||||||
match self.operation {
|
match self.operation {
|
||||||
LinearOperation::Add => density + self.argument,
|
LinearOperation::Add => density + self.argument,
|
||||||
LinearOperation::Mul => density * self.argument,
|
LinearOperation::Mul => density * self.argument,
|
||||||
@ -1386,7 +1390,9 @@ pub fn build() -> TokenStream {
|
|||||||
|
|
||||||
impl UnaryData {
|
impl UnaryData {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn apply_density(&self, density: f64) -> f64 {
|
#[must_use]
|
||||||
|
#[allow(clippy::too_many_lines)]
|
||||||
|
pub const fn apply_density(&self, density: f64) -> f64 {
|
||||||
match self.operation {
|
match self.operation {
|
||||||
UnaryOperation::Abs => density.abs(),
|
UnaryOperation::Abs => density.abs(),
|
||||||
UnaryOperation::Square => density * density,
|
UnaryOperation::Square => density * density,
|
||||||
@ -1423,7 +1429,8 @@ pub fn build() -> TokenStream {
|
|||||||
|
|
||||||
impl ClampData {
|
impl ClampData {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn apply_density(&self, density: f64) -> f64 {
|
#[must_use]
|
||||||
|
pub const fn apply_density(&self, density: f64) -> f64 {
|
||||||
density.clamp(self.min_value, self.max_value)
|
density.clamp(self.min_value, self.max_value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -104,7 +104,9 @@ fn generate_struct<T>(versions: &BTreeMap<JavaMinecraftVersion, T>) -> TokenStre
|
|||||||
impl PacketId {
|
impl PacketId {
|
||||||
/// Converts the requested protocol version into the corresponding packet ID.
|
/// Converts the requested protocol version into the corresponding packet ID.
|
||||||
/// Returns -1 if the packet does not exist in that version.
|
/// Returns -1 if the packet does not exist in that version.
|
||||||
pub fn to_id(&self, version: JavaMinecraftVersion) -> i32 {
|
#[must_use]
|
||||||
|
pub const fn to_id(&self, version: JavaMinecraftVersion) -> i32 {
|
||||||
|
#[allow(clippy::match_same_arms)]
|
||||||
match version {
|
match version {
|
||||||
#match_arms
|
#match_arms
|
||||||
_ => self.#latest_field_ident,
|
_ => self.#latest_field_ident,
|
||||||
|
|||||||
@ -42,12 +42,17 @@ pub fn build() -> TokenStream {
|
|||||||
|
|
||||||
impl Particle {
|
impl Particle {
|
||||||
#[doc = r" Try to parse a `Particle` from a resource location string."]
|
#[doc = r" Try to parse a `Particle` from a resource location string."]
|
||||||
|
#[must_use]
|
||||||
|
#[allow(clippy::too_many_lines)]
|
||||||
pub fn from_name(name: &str) -> Option<Self> {
|
pub fn from_name(name: &str) -> Option<Self> {
|
||||||
match name {
|
match name {
|
||||||
#type_from_name
|
#type_from_name
|
||||||
_ => None
|
_ => None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
|
#[allow(clippy::too_many_lines)]
|
||||||
pub const fn to_name(&self) -> &'static str {
|
pub const fn to_name(&self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
#type_to_name
|
#type_to_name
|
||||||
|
|||||||
@ -110,6 +110,7 @@ pub fn build() -> TokenStream {
|
|||||||
impl Potion {
|
impl Potion {
|
||||||
#variants
|
#variants
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn from_name(name: &str) -> Option<&'static Self> {
|
pub fn from_name(name: &str) -> Option<&'static Self> {
|
||||||
match name {
|
match name {
|
||||||
#name_to_type
|
#name_to_type
|
||||||
|
|||||||
@ -119,15 +119,21 @@ pub fn build() -> TokenStream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl PotionRecipe {
|
impl PotionRecipe {
|
||||||
pub fn from(&self) -> &'static Potion { self.from }
|
#[must_use]
|
||||||
pub fn ingredient(&self) -> &'static [&'static Item] { self.ingredient }
|
pub const fn from(&self) -> &'static Potion { self.from }
|
||||||
pub fn to(&self) -> &'static Potion { self.to }
|
#[must_use]
|
||||||
|
pub const fn ingredient(&self) -> &'static [&'static Item] { self.ingredient }
|
||||||
|
#[must_use]
|
||||||
|
pub const fn to(&self) -> &'static Potion { self.to }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ItemRecipe {
|
impl ItemRecipe {
|
||||||
pub fn from(&self) -> &'static Item { self.from }
|
#[must_use]
|
||||||
pub fn ingredient(&self) -> &'static [&'static Item] { self.ingredient }
|
pub const fn from(&self) -> &'static Item { self.from }
|
||||||
pub fn to(&self) -> &'static Item { self.to }
|
#[must_use]
|
||||||
|
pub const fn ingredient(&self) -> &'static [&'static Item] { self.ingredient }
|
||||||
|
#[must_use]
|
||||||
|
pub const fn to(&self) -> &'static Item { self.to }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const ITEM_RECIPES: [ItemRecipe; #item_len] = [#(#item_recipes_tokens)*];
|
pub const ITEM_RECIPES: [ItemRecipe; #item_len] = [#(#item_recipes_tokens)*];
|
||||||
|
|||||||
@ -20,6 +20,7 @@ pub fn build() -> TokenStream {
|
|||||||
.collect();
|
.collect();
|
||||||
quote! {
|
quote! {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
|
#[allow(clippy::match_same_arms)]
|
||||||
pub const fn get_recipe_remainder_id(item_id: u16) -> Option<u16> {
|
pub const fn get_recipe_remainder_id(item_id: u16) -> Option<u16> {
|
||||||
match item_id {
|
match item_id {
|
||||||
#(#match_arms)*
|
#(#match_arms)*
|
||||||
|
|||||||
@ -595,34 +595,37 @@ pub fn build() -> TokenStream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl From<&CookingRecipeType> for CookingRecipeKind {
|
impl From<&CookingRecipeType> for CookingRecipeKind {
|
||||||
|
#[must_use]
|
||||||
fn from(recipe_type: &CookingRecipeType) -> Self {
|
fn from(recipe_type: &CookingRecipeType) -> Self {
|
||||||
match recipe_type {
|
match recipe_type {
|
||||||
CookingRecipeType::Blasting(_) => CookingRecipeKind::Blasting,
|
CookingRecipeType::Blasting(_) => Self::Blasting,
|
||||||
CookingRecipeType::Smelting(_) => CookingRecipeKind::Smelting,
|
CookingRecipeType::Smelting(_) => Self::Smelting,
|
||||||
CookingRecipeType::Smoking(_) => CookingRecipeKind::Smoking,
|
CookingRecipeType::Smoking(_) => Self::Smoking,
|
||||||
CookingRecipeType::CampfireCooking(_) => CookingRecipeKind::CampfireCooking,
|
CookingRecipeType::CampfireCooking(_) => Self::CampfireCooking,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<CookingRecipeType> for CookingRecipeKind {
|
impl From<CookingRecipeType> for CookingRecipeKind {
|
||||||
|
#[must_use]
|
||||||
fn from(recipe_type: CookingRecipeType) -> Self {
|
fn from(recipe_type: CookingRecipeType) -> Self {
|
||||||
match recipe_type {
|
match recipe_type {
|
||||||
CookingRecipeType::Blasting(_) => CookingRecipeKind::Blasting,
|
CookingRecipeType::Blasting(_) => Self::Blasting,
|
||||||
CookingRecipeType::Smelting(_) => CookingRecipeKind::Smelting,
|
CookingRecipeType::Smelting(_) => Self::Smelting,
|
||||||
CookingRecipeType::Smoking(_) => CookingRecipeKind::Smoking,
|
CookingRecipeType::Smoking(_) => Self::Smoking,
|
||||||
CookingRecipeType::CampfireCooking(_) => CookingRecipeKind::CampfireCooking,
|
CookingRecipeType::CampfireCooking(_) => Self::CampfireCooking,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CookingRecipeKind {
|
impl CookingRecipeKind {
|
||||||
pub fn to_type(self, recipe: CookingRecipe) -> CookingRecipeType {
|
#[must_use]
|
||||||
|
pub const fn to_type(self, recipe: CookingRecipe) -> CookingRecipeType {
|
||||||
match self {
|
match self {
|
||||||
CookingRecipeKind::Blasting => CookingRecipeType::Blasting(recipe),
|
Self::Blasting => CookingRecipeType::Blasting(recipe),
|
||||||
CookingRecipeKind::Smelting => CookingRecipeType::Smelting(recipe),
|
Self::Smelting => CookingRecipeType::Smelting(recipe),
|
||||||
CookingRecipeKind::Smoking => CookingRecipeType::Smoking(recipe),
|
Self::Smoking => CookingRecipeType::Smoking(recipe),
|
||||||
CookingRecipeKind::CampfireCooking => CookingRecipeType::CampfireCooking(recipe),
|
Self::CampfireCooking => CookingRecipeType::CampfireCooking(recipe),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -648,16 +651,17 @@ pub fn build() -> TokenStream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl RecipeIngredientTypes {
|
impl RecipeIngredientTypes {
|
||||||
|
#[must_use]
|
||||||
pub fn match_item(&self, item: &Item) -> bool {
|
pub fn match_item(&self, item: &Item) -> bool {
|
||||||
match self {
|
match self {
|
||||||
RecipeIngredientTypes::Simple(ingredient) => {
|
Self::Simple(ingredient) => {
|
||||||
let name = format!("minecraft:{}", item.registry_key);
|
let name = format!("minecraft:{}", item.registry_key);
|
||||||
name == *ingredient
|
name == *ingredient
|
||||||
}
|
}
|
||||||
RecipeIngredientTypes::Tagged(tag) => item
|
Self::Tagged(tag) => item
|
||||||
.is_tagged_with(tag)
|
.is_tagged_with(tag)
|
||||||
.expect("Crafting recipe used invalid tag"),
|
.expect("Crafting recipe used invalid tag"),
|
||||||
RecipeIngredientTypes::OneOf(ingredients) => {
|
Self::OneOf(ingredients) => {
|
||||||
let name = format!("minecraft:{}", item.registry_key);
|
let name = format!("minecraft:{}", item.registry_key);
|
||||||
ingredients.contains(&name.as_str())
|
ingredients.contains(&name.as_str())
|
||||||
}
|
}
|
||||||
@ -685,6 +689,7 @@ pub fn build() -> TokenStream {
|
|||||||
#(#stonecutting_recipes),*
|
#(#stonecutting_recipes),*
|
||||||
];
|
];
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn get_cooking_recipe_with_ingredient(ingredient: &Item, recipe_type: CookingRecipeKind) -> Option<&'static CookingRecipe> {
|
pub fn get_cooking_recipe_with_ingredient(ingredient: &Item, recipe_type: CookingRecipeKind) -> Option<&'static CookingRecipe> {
|
||||||
RECIPES_COOKING
|
RECIPES_COOKING
|
||||||
.iter()
|
.iter()
|
||||||
@ -704,7 +709,8 @@ pub fn build() -> TokenStream {
|
|||||||
|
|
||||||
/// Get the experience value for a recipe by its recipe ID.
|
/// Get the experience value for a recipe by its recipe ID.
|
||||||
/// Used for calculating XP when extracting from furnace.
|
/// Used for calculating XP when extracting from furnace.
|
||||||
/// Recipe IDs are in vanilla format like "minecraft:iron_ingot_from_smelting_iron_ore"
|
/// Recipe IDs are in vanilla format like `"minecraft:iron_ingot_from_smelting_iron_ore"`
|
||||||
|
#[must_use]
|
||||||
pub fn get_recipe_experience(recipe_id: &str) -> Option<f32> {
|
pub fn get_recipe_experience(recipe_id: &str) -> Option<f32> {
|
||||||
RECIPES_COOKING.iter().find_map(|recipe| {
|
RECIPES_COOKING.iter().find_map(|recipe| {
|
||||||
let cooking_recipe = match recipe {
|
let cooking_recipe = match recipe {
|
||||||
|
|||||||
@ -125,7 +125,9 @@ pub(crate) fn build() -> TokenStream {
|
|||||||
#static_values
|
#static_values
|
||||||
|
|
||||||
impl Registry {
|
impl Registry {
|
||||||
|
#[must_use]
|
||||||
pub fn get_synced(version: JavaMinecraftVersion) -> Vec<Self> {
|
pub fn get_synced(version: JavaMinecraftVersion) -> Vec<Self> {
|
||||||
|
#[allow(clippy::match_same_arms)]
|
||||||
let static_regs = match version {
|
let static_regs = match version {
|
||||||
#match_arms
|
#match_arms
|
||||||
_ => #latest_registry,
|
_ => #latest_registry,
|
||||||
|
|||||||
@ -39,10 +39,12 @@ pub fn build() -> TokenStream {
|
|||||||
impl Sound {
|
impl Sound {
|
||||||
pub const NAMES: &[&str] = &[ #(#names_list),* ];
|
pub const NAMES: &[&str] = &[ #(#names_list),* ];
|
||||||
|
|
||||||
const LOOKUP: &[(&str, Sound)] = &[
|
#[allow(clippy::large_stack_arrays)]
|
||||||
|
const LOOKUP: &[(&str, Self)] = &[
|
||||||
#(#lookup_table),*
|
#(#lookup_table),*
|
||||||
];
|
];
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn from_name(name: &str) -> Option<Self> {
|
pub fn from_name(name: &str) -> Option<Self> {
|
||||||
Self::LOOKUP
|
Self::LOOKUP
|
||||||
.binary_search_by_key(&name, |&(k, _)| k)
|
.binary_search_by_key(&name, |&(k, _)| k)
|
||||||
@ -50,11 +52,14 @@ pub fn build() -> TokenStream {
|
|||||||
.map(|idx| Self::LOOKUP[idx].1)
|
.map(|idx| Self::LOOKUP[idx].1)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const fn to_name(&self) -> &'static str {
|
#[must_use]
|
||||||
|
pub const fn to_name(&self) -> &'static str {
|
||||||
Self::NAMES[*self as usize]
|
Self::NAMES[*self as usize]
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn slice() -> &'static [Self] {
|
#[must_use]
|
||||||
|
#[allow(clippy::large_stack_arrays, clippy::too_many_lines)]
|
||||||
|
pub const fn slice() -> &'static [Self] {
|
||||||
&[#(#variants_list)*]
|
&[#(#variants_list)*]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -305,7 +305,7 @@ pub fn build() -> TokenStream {
|
|||||||
let key_variant = structure_key_to_token(name);
|
let key_variant = structure_key_to_token(name);
|
||||||
|
|
||||||
structure_const_defs.extend(quote!(
|
structure_const_defs.extend(quote!(
|
||||||
pub const #const_name: Structure = #structure;
|
pub const #const_name: Self = #structure;
|
||||||
));
|
));
|
||||||
|
|
||||||
structure_lookup_arms.extend(quote!(
|
structure_lookup_arms.extend(quote!(
|
||||||
@ -323,7 +323,7 @@ pub fn build() -> TokenStream {
|
|||||||
let const_name = format_ident!("{}", upper_name);
|
let const_name = format_ident!("{}", upper_name);
|
||||||
|
|
||||||
structure_set_const_defs.extend(quote!(
|
structure_set_const_defs.extend(quote!(
|
||||||
pub const #const_name: StructureSet = #structure_set;
|
pub const #const_name: Self = #structure_set;
|
||||||
));
|
));
|
||||||
|
|
||||||
structure_set_lookup_arms.extend(quote!(
|
structure_set_lookup_arms.extend(quote!(
|
||||||
|
|||||||
@ -48,6 +48,7 @@ impl ToTokens for EnumCreator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl #name {
|
impl #name {
|
||||||
|
#[must_use]
|
||||||
pub fn from_string(s: &str) -> Option<Self> {
|
pub fn from_string(s: &str) -> Option<Self> {
|
||||||
match s {
|
match s {
|
||||||
#(#from_string_arms,)*
|
#(#from_string_arms,)*
|
||||||
@ -55,7 +56,8 @@ impl ToTokens for EnumCreator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn identifier_string(&self) -> &str {
|
#[must_use]
|
||||||
|
pub const fn identifier_string(&self) -> &str {
|
||||||
match self {
|
match self {
|
||||||
#(#to_string_arms),*
|
#(#to_string_arms),*
|
||||||
}
|
}
|
||||||
@ -206,7 +208,7 @@ pub(crate) fn build() -> TokenStream {
|
|||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub mod #key_pascal {
|
pub mod #key_pascal {
|
||||||
#(#tag_entries)* }
|
#(#tag_entries)* }
|
||||||
pub(crate) static #dict_name: phf::Map<&'static str, &'static #tag_type_path> = phf::phf_map! {
|
static #dict_name: phf::Map<&'static str, &'static #tag_type_path> = phf::phf_map! {
|
||||||
#(#tag_map_entries),* };
|
#(#tag_map_entries),* };
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -217,7 +219,8 @@ pub(crate) fn build() -> TokenStream {
|
|||||||
latest_modules.push(quote! {
|
latest_modules.push(quote! {
|
||||||
#(#tag_dicts)*
|
#(#tag_dicts)*
|
||||||
#[allow(unreachable_patterns)]
|
#[allow(unreachable_patterns)]
|
||||||
pub fn get_latest_map(key: RegistryKey) -> Option<&'static phf::Map<&'static str, &'static Tag>> {
|
#[must_use]
|
||||||
|
pub const fn get_latest_map(key: RegistryKey) -> Option<&'static phf::Map<&'static str, &'static Tag>> {
|
||||||
match key { #(#match_local_map,)* _ => None }
|
match key { #(#match_local_map,)* _ => None }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -228,7 +231,8 @@ pub(crate) fn build() -> TokenStream {
|
|||||||
mod #mod_name {
|
mod #mod_name {
|
||||||
use super::RegistryKey;
|
use super::RegistryKey;
|
||||||
#(#tag_dicts)*
|
#(#tag_dicts)*
|
||||||
pub fn get_map(key: RegistryKey) -> Option<&'static phf::Map<&'static str, &'static super::Tag>> {
|
#[must_use]
|
||||||
|
pub const fn get_map(key: RegistryKey) -> Option<&'static phf::Map<&'static str, &'static super::Tag>> {
|
||||||
match key { #(#match_local_map,)* _ => None }
|
match key { #(#match_local_map,)* _ => None }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -257,15 +261,18 @@ pub(crate) fn build() -> TokenStream {
|
|||||||
// Legacy tags are hidden in their own module
|
// Legacy tags are hidden in their own module
|
||||||
#(#legacy_modules)*
|
#(#legacy_modules)*
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn get_tag_values(tag_category: RegistryKey, tag: &str) -> Option<&'static [&'static str]> {
|
pub fn get_tag_values(tag_category: RegistryKey, tag: &str) -> Option<&'static [&'static str]> {
|
||||||
get_latest_map(tag_category).and_then(|m| m.get(tag)).map(|t| t.0)
|
get_latest_map(tag_category).and_then(|m| m.get(tag)).map(|t| t.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn get_tag_ids(tag_category: RegistryKey, tag: &str) -> Option<&'static [u16]> {
|
pub fn get_tag_ids(tag_category: RegistryKey, tag: &str) -> Option<&'static [u16]> {
|
||||||
get_latest_map(tag_category).and_then(|m| m.get(tag)).map(|t| t.1)
|
get_latest_map(tag_category).and_then(|m| m.get(tag)).map(|t| t.1)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_registry_key_tags(version: JavaMinecraftVersion, tag_category: RegistryKey) -> Option<&'static phf::Map<&'static str, &'static Tag>> {
|
#[must_use]
|
||||||
|
pub const fn get_registry_key_tags(version: JavaMinecraftVersion, tag_category: RegistryKey) -> Option<&'static phf::Map<&'static str, &'static Tag>> {
|
||||||
match version {
|
match version {
|
||||||
#(#match_get_map),*,
|
#(#match_get_map),*,
|
||||||
_ => get_latest_map(tag_category)
|
_ => get_latest_map(tag_category)
|
||||||
@ -277,16 +284,19 @@ pub(crate) fn build() -> TokenStream {
|
|||||||
fn registry_key(&self) -> &str;
|
fn registry_key(&self) -> &str;
|
||||||
fn registry_id(&self) -> u16;
|
fn registry_id(&self) -> u16;
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
fn is_tagged_with(&self, tag: &str) -> Option<bool> {
|
fn is_tagged_with(&self, tag: &str) -> Option<bool> {
|
||||||
let tag = tag.strip_prefix("#").unwrap_or(tag);
|
let tag = tag.strip_prefix("#").unwrap_or(tag);
|
||||||
let items = get_tag_ids(Self::tag_key(), tag)?;
|
let items = get_tag_ids(Self::tag_key(), tag)?;
|
||||||
Some(items.contains(&self.registry_id()))
|
Some(items.contains(&self.registry_id()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
fn has_tag(&self, tag: &'static Tag) -> bool {
|
fn has_tag(&self, tag: &'static Tag) -> bool {
|
||||||
tag.1.contains(&self.registry_id())
|
tag.1.contains(&self.registry_id())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
fn get_tag_values(tag: &str) -> Option<&'static [&'static str]> {
|
fn get_tag_values(tag: &str) -> Option<&'static [&'static str]> {
|
||||||
let tag = tag.strip_prefix("#").unwrap_or(tag);
|
let tag = tag.strip_prefix("#").unwrap_or(tag);
|
||||||
get_tag_values(Self::tag_key(), tag)
|
get_tag_values(Self::tag_key(), tag)
|
||||||
|
|||||||
@ -51,6 +51,7 @@ pub fn build() -> TokenStream {
|
|||||||
|
|
||||||
// --- Final Assembly ---
|
// --- Final Assembly ---
|
||||||
quote! {
|
quote! {
|
||||||
|
#![allow(clippy::doc_markdown)]
|
||||||
pub mod java {
|
pub mod java {
|
||||||
#java_constants
|
#java_constants
|
||||||
}
|
}
|
||||||
|
|||||||
@ -247,7 +247,7 @@ pub fn build() -> TokenStream {
|
|||||||
quote! {
|
quote! {
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq)]
|
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||||
pub struct VillagerTradeItem {
|
pub struct VillagerTradeItem {
|
||||||
pub item: &'static crate::item::Item,
|
pub item: &'static crate::item::Item,
|
||||||
pub count: i32,
|
pub count: i32,
|
||||||
@ -279,7 +279,7 @@ pub fn build() -> TokenStream {
|
|||||||
|
|
||||||
impl VillagerProfession {
|
impl VillagerProfession {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn from_i32(id: i32) -> Option<Self> {
|
pub const fn from_i32(id: i32) -> Option<Self> {
|
||||||
match id {
|
match id {
|
||||||
#(#profession_from_i32,)*
|
#(#profession_from_i32,)*
|
||||||
_ => None,
|
_ => None,
|
||||||
@ -287,28 +287,31 @@ pub fn build() -> TokenStream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn work_sound(&self) -> Option<crate::sound::Sound> {
|
#[allow(clippy::match_same_arms)]
|
||||||
|
pub const fn work_sound(&self) -> Option<crate::sound::Sound> {
|
||||||
match self {
|
match self {
|
||||||
#(#work_sounds),*
|
#(#work_sounds),*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn requested_items(&self) -> &'static [&'static crate::item::Item] {
|
#[allow(clippy::match_same_arms)]
|
||||||
|
pub const fn requested_items(&self) -> &'static [&'static crate::item::Item] {
|
||||||
match self {
|
match self {
|
||||||
#(#requested_items),*
|
#(#requested_items),*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn translation_key(&self) -> &'static str {
|
pub const fn translation_key(&self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
#(#profession_names),*
|
#(#profession_names),*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn trade_set(&self, level: i32) -> Option<VillagerTradeSet> {
|
#[allow(clippy::too_many_lines, clippy::match_same_arms)]
|
||||||
|
pub const fn trade_set(&self, level: i32) -> Option<VillagerTradeSet> {
|
||||||
match self {
|
match self {
|
||||||
#(#profession_trade_sets,)*
|
#(#profession_trade_sets,)*
|
||||||
}
|
}
|
||||||
@ -331,7 +334,7 @@ pub fn build() -> TokenStream {
|
|||||||
|
|
||||||
impl VillagerType {
|
impl VillagerType {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn from_i32(id: i32) -> Option<Self> {
|
pub const fn from_i32(id: i32) -> Option<Self> {
|
||||||
match id {
|
match id {
|
||||||
#(#type_from_i32,)*
|
#(#type_from_i32,)*
|
||||||
_ => None,
|
_ => None,
|
||||||
|
|||||||
@ -127,7 +127,7 @@ impl BlockState {
|
|||||||
match side {
|
match side {
|
||||||
BlockDirection::Down => self.side_flags & DOWN_CENTER_SOLID != 0,
|
BlockDirection::Down => self.side_flags & DOWN_CENTER_SOLID != 0,
|
||||||
BlockDirection::Up => self.side_flags & UP_CENTER_SOLID != 0,
|
BlockDirection::Up => self.side_flags & UP_CENTER_SOLID != 0,
|
||||||
_ => unreachable!(),
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -29,6 +29,7 @@ pub struct CaveCarverConfig {
|
|||||||
pub floor_level: FloatProvider,
|
pub floor_level: FloatProvider,
|
||||||
}
|
}
|
||||||
impl CaveCarverConfig {
|
impl CaveCarverConfig {
|
||||||
|
#[must_use]
|
||||||
pub const fn default() -> Self {
|
pub const fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
horizontal_radius_multiplier: FloatProvider::Constant(1.0),
|
horizontal_radius_multiplier: FloatProvider::Constant(1.0),
|
||||||
|
|||||||
@ -5482,6 +5482,7 @@ static WOODLAND_MANSION_POOLS: &[ChestLootPool] = &[
|
|||||||
pub static WOODLAND_MANSION: ChestLootTable = ChestLootTable {
|
pub static WOODLAND_MANSION: ChestLootTable = ChestLootTable {
|
||||||
pools: WOODLAND_MANSION_POOLS,
|
pools: WOODLAND_MANSION_POOLS,
|
||||||
};
|
};
|
||||||
|
#[must_use]
|
||||||
pub fn get_chest_loot_table(key: &str) -> Option<&'static ChestLootTable> {
|
pub fn get_chest_loot_table(key: &str) -> Option<&'static ChestLootTable> {
|
||||||
match key {
|
match key {
|
||||||
"minecraft:chests/abandoned_mineshaft" => Some(&ABANDONED_MINESHAFT),
|
"minecraft:chests/abandoned_mineshaft" => Some(&ABANDONED_MINESHAFT),
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -1,5 +1,6 @@
|
|||||||
/* This file is generated. Do not edit manually. */
|
/* This file is generated. Do not edit manually. */
|
||||||
#[must_use]
|
#[must_use]
|
||||||
|
#[allow(clippy::too_many_lines, clippy::match_same_arms)]
|
||||||
pub const fn get_composter_increase_chance_from_item_id(item_id: u16) -> Option<f32> {
|
pub const fn get_composter_increase_chance_from_item_id(item_id: u16) -> Option<f32> {
|
||||||
match item_id {
|
match item_id {
|
||||||
49 => Some(0.3f32),
|
49 => Some(0.3f32),
|
||||||
|
|||||||
@ -115,241 +115,246 @@ pub enum DataComponent {
|
|||||||
ShulkerColor = 109u8,
|
ShulkerColor = 109u8,
|
||||||
}
|
}
|
||||||
impl DataComponent {
|
impl DataComponent {
|
||||||
|
#[must_use]
|
||||||
pub const fn to_id(self) -> u8 {
|
pub const fn to_id(self) -> u8 {
|
||||||
self as u8
|
self as u8
|
||||||
}
|
}
|
||||||
pub const fn try_from_id(id: u8) -> Option<DataComponent> {
|
#[must_use]
|
||||||
|
#[allow(clippy::too_many_lines)]
|
||||||
|
pub const fn try_from_id(id: u8) -> Option<Self> {
|
||||||
match id {
|
match id {
|
||||||
0u8 => Some(DataComponent::CustomData),
|
0u8 => Some(Self::CustomData),
|
||||||
1u8 => Some(DataComponent::MaxStackSize),
|
1u8 => Some(Self::MaxStackSize),
|
||||||
2u8 => Some(DataComponent::MaxDamage),
|
2u8 => Some(Self::MaxDamage),
|
||||||
3u8 => Some(DataComponent::Damage),
|
3u8 => Some(Self::Damage),
|
||||||
4u8 => Some(DataComponent::Unbreakable),
|
4u8 => Some(Self::Unbreakable),
|
||||||
5u8 => Some(DataComponent::UseEffects),
|
5u8 => Some(Self::UseEffects),
|
||||||
6u8 => Some(DataComponent::CustomName),
|
6u8 => Some(Self::CustomName),
|
||||||
7u8 => Some(DataComponent::MinimumAttackCharge),
|
7u8 => Some(Self::MinimumAttackCharge),
|
||||||
8u8 => Some(DataComponent::DamageType),
|
8u8 => Some(Self::DamageType),
|
||||||
9u8 => Some(DataComponent::ItemName),
|
9u8 => Some(Self::ItemName),
|
||||||
10u8 => Some(DataComponent::ItemModel),
|
10u8 => Some(Self::ItemModel),
|
||||||
11u8 => Some(DataComponent::Lore),
|
11u8 => Some(Self::Lore),
|
||||||
12u8 => Some(DataComponent::Rarity),
|
12u8 => Some(Self::Rarity),
|
||||||
13u8 => Some(DataComponent::Enchantments),
|
13u8 => Some(Self::Enchantments),
|
||||||
14u8 => Some(DataComponent::CanPlaceOn),
|
14u8 => Some(Self::CanPlaceOn),
|
||||||
15u8 => Some(DataComponent::CanBreak),
|
15u8 => Some(Self::CanBreak),
|
||||||
16u8 => Some(DataComponent::AttributeModifiers),
|
16u8 => Some(Self::AttributeModifiers),
|
||||||
17u8 => Some(DataComponent::CustomModelData),
|
17u8 => Some(Self::CustomModelData),
|
||||||
18u8 => Some(DataComponent::TooltipDisplay),
|
18u8 => Some(Self::TooltipDisplay),
|
||||||
19u8 => Some(DataComponent::RepairCost),
|
19u8 => Some(Self::RepairCost),
|
||||||
20u8 => Some(DataComponent::CreativeSlotLock),
|
20u8 => Some(Self::CreativeSlotLock),
|
||||||
21u8 => Some(DataComponent::EnchantmentGlintOverride),
|
21u8 => Some(Self::EnchantmentGlintOverride),
|
||||||
22u8 => Some(DataComponent::IntangibleProjectile),
|
22u8 => Some(Self::IntangibleProjectile),
|
||||||
23u8 => Some(DataComponent::Food),
|
23u8 => Some(Self::Food),
|
||||||
24u8 => Some(DataComponent::Consumable),
|
24u8 => Some(Self::Consumable),
|
||||||
25u8 => Some(DataComponent::UseRemainder),
|
25u8 => Some(Self::UseRemainder),
|
||||||
26u8 => Some(DataComponent::UseCooldown),
|
26u8 => Some(Self::UseCooldown),
|
||||||
27u8 => Some(DataComponent::DamageResistant),
|
27u8 => Some(Self::DamageResistant),
|
||||||
28u8 => Some(DataComponent::Tool),
|
28u8 => Some(Self::Tool),
|
||||||
29u8 => Some(DataComponent::Weapon),
|
29u8 => Some(Self::Weapon),
|
||||||
30u8 => Some(DataComponent::AttackRange),
|
30u8 => Some(Self::AttackRange),
|
||||||
31u8 => Some(DataComponent::Enchantable),
|
31u8 => Some(Self::Enchantable),
|
||||||
32u8 => Some(DataComponent::Equippable),
|
32u8 => Some(Self::Equippable),
|
||||||
33u8 => Some(DataComponent::Repairable),
|
33u8 => Some(Self::Repairable),
|
||||||
34u8 => Some(DataComponent::Glider),
|
34u8 => Some(Self::Glider),
|
||||||
35u8 => Some(DataComponent::TooltipStyle),
|
35u8 => Some(Self::TooltipStyle),
|
||||||
36u8 => Some(DataComponent::DeathProtection),
|
36u8 => Some(Self::DeathProtection),
|
||||||
37u8 => Some(DataComponent::BlocksAttacks),
|
37u8 => Some(Self::BlocksAttacks),
|
||||||
38u8 => Some(DataComponent::PiercingWeapon),
|
38u8 => Some(Self::PiercingWeapon),
|
||||||
39u8 => Some(DataComponent::KineticWeapon),
|
39u8 => Some(Self::KineticWeapon),
|
||||||
40u8 => Some(DataComponent::SwingAnimation),
|
40u8 => Some(Self::SwingAnimation),
|
||||||
41u8 => Some(DataComponent::AdditionalTradeCost),
|
41u8 => Some(Self::AdditionalTradeCost),
|
||||||
42u8 => Some(DataComponent::StoredEnchantments),
|
42u8 => Some(Self::StoredEnchantments),
|
||||||
43u8 => Some(DataComponent::Dye),
|
43u8 => Some(Self::Dye),
|
||||||
44u8 => Some(DataComponent::DyedColor),
|
44u8 => Some(Self::DyedColor),
|
||||||
45u8 => Some(DataComponent::MapColor),
|
45u8 => Some(Self::MapColor),
|
||||||
46u8 => Some(DataComponent::MapId),
|
46u8 => Some(Self::MapId),
|
||||||
47u8 => Some(DataComponent::MapDecorations),
|
47u8 => Some(Self::MapDecorations),
|
||||||
48u8 => Some(DataComponent::MapPostProcessing),
|
48u8 => Some(Self::MapPostProcessing),
|
||||||
49u8 => Some(DataComponent::ChargedProjectiles),
|
49u8 => Some(Self::ChargedProjectiles),
|
||||||
50u8 => Some(DataComponent::BundleContents),
|
50u8 => Some(Self::BundleContents),
|
||||||
51u8 => Some(DataComponent::PotionContents),
|
51u8 => Some(Self::PotionContents),
|
||||||
52u8 => Some(DataComponent::PotionDurationScale),
|
52u8 => Some(Self::PotionDurationScale),
|
||||||
53u8 => Some(DataComponent::SuspiciousStewEffects),
|
53u8 => Some(Self::SuspiciousStewEffects),
|
||||||
54u8 => Some(DataComponent::WritableBookContent),
|
54u8 => Some(Self::WritableBookContent),
|
||||||
55u8 => Some(DataComponent::WrittenBookContent),
|
55u8 => Some(Self::WrittenBookContent),
|
||||||
56u8 => Some(DataComponent::Trim),
|
56u8 => Some(Self::Trim),
|
||||||
57u8 => Some(DataComponent::DebugStickState),
|
57u8 => Some(Self::DebugStickState),
|
||||||
58u8 => Some(DataComponent::EntityData),
|
58u8 => Some(Self::EntityData),
|
||||||
59u8 => Some(DataComponent::BucketEntityData),
|
59u8 => Some(Self::BucketEntityData),
|
||||||
60u8 => Some(DataComponent::BlockEntityData),
|
60u8 => Some(Self::BlockEntityData),
|
||||||
61u8 => Some(DataComponent::Instrument),
|
61u8 => Some(Self::Instrument),
|
||||||
62u8 => Some(DataComponent::ProvidesTrimMaterial),
|
62u8 => Some(Self::ProvidesTrimMaterial),
|
||||||
63u8 => Some(DataComponent::OminousBottleAmplifier),
|
63u8 => Some(Self::OminousBottleAmplifier),
|
||||||
64u8 => Some(DataComponent::JukeboxPlayable),
|
64u8 => Some(Self::JukeboxPlayable),
|
||||||
65u8 => Some(DataComponent::ProvidesBannerPatterns),
|
65u8 => Some(Self::ProvidesBannerPatterns),
|
||||||
66u8 => Some(DataComponent::Recipes),
|
66u8 => Some(Self::Recipes),
|
||||||
67u8 => Some(DataComponent::LodestoneTracker),
|
67u8 => Some(Self::LodestoneTracker),
|
||||||
68u8 => Some(DataComponent::FireworkExplosion),
|
68u8 => Some(Self::FireworkExplosion),
|
||||||
69u8 => Some(DataComponent::Fireworks),
|
69u8 => Some(Self::Fireworks),
|
||||||
70u8 => Some(DataComponent::Profile),
|
70u8 => Some(Self::Profile),
|
||||||
71u8 => Some(DataComponent::NoteBlockSound),
|
71u8 => Some(Self::NoteBlockSound),
|
||||||
72u8 => Some(DataComponent::BannerPatterns),
|
72u8 => Some(Self::BannerPatterns),
|
||||||
73u8 => Some(DataComponent::BaseColor),
|
73u8 => Some(Self::BaseColor),
|
||||||
74u8 => Some(DataComponent::PotDecorations),
|
74u8 => Some(Self::PotDecorations),
|
||||||
75u8 => Some(DataComponent::Container),
|
75u8 => Some(Self::Container),
|
||||||
76u8 => Some(DataComponent::BlockState),
|
76u8 => Some(Self::BlockState),
|
||||||
77u8 => Some(DataComponent::Bees),
|
77u8 => Some(Self::Bees),
|
||||||
78u8 => Some(DataComponent::Lock),
|
78u8 => Some(Self::Lock),
|
||||||
79u8 => Some(DataComponent::ContainerLoot),
|
79u8 => Some(Self::ContainerLoot),
|
||||||
80u8 => Some(DataComponent::BreakSound),
|
80u8 => Some(Self::BreakSound),
|
||||||
81u8 => Some(DataComponent::VillagerVariant),
|
81u8 => Some(Self::VillagerVariant),
|
||||||
82u8 => Some(DataComponent::WolfVariant),
|
82u8 => Some(Self::WolfVariant),
|
||||||
83u8 => Some(DataComponent::WolfSoundVariant),
|
83u8 => Some(Self::WolfSoundVariant),
|
||||||
84u8 => Some(DataComponent::WolfCollar),
|
84u8 => Some(Self::WolfCollar),
|
||||||
85u8 => Some(DataComponent::FoxVariant),
|
85u8 => Some(Self::FoxVariant),
|
||||||
86u8 => Some(DataComponent::SalmonSize),
|
86u8 => Some(Self::SalmonSize),
|
||||||
87u8 => Some(DataComponent::ParrotVariant),
|
87u8 => Some(Self::ParrotVariant),
|
||||||
88u8 => Some(DataComponent::TropicalFishPattern),
|
88u8 => Some(Self::TropicalFishPattern),
|
||||||
89u8 => Some(DataComponent::TropicalFishBaseColor),
|
89u8 => Some(Self::TropicalFishBaseColor),
|
||||||
90u8 => Some(DataComponent::TropicalFishPatternColor),
|
90u8 => Some(Self::TropicalFishPatternColor),
|
||||||
91u8 => Some(DataComponent::MooshroomVariant),
|
91u8 => Some(Self::MooshroomVariant),
|
||||||
92u8 => Some(DataComponent::RabbitVariant),
|
92u8 => Some(Self::RabbitVariant),
|
||||||
93u8 => Some(DataComponent::PigVariant),
|
93u8 => Some(Self::PigVariant),
|
||||||
94u8 => Some(DataComponent::PigSoundVariant),
|
94u8 => Some(Self::PigSoundVariant),
|
||||||
95u8 => Some(DataComponent::CowVariant),
|
95u8 => Some(Self::CowVariant),
|
||||||
96u8 => Some(DataComponent::CowSoundVariant),
|
96u8 => Some(Self::CowSoundVariant),
|
||||||
97u8 => Some(DataComponent::ChickenVariant),
|
97u8 => Some(Self::ChickenVariant),
|
||||||
98u8 => Some(DataComponent::ChickenSoundVariant),
|
98u8 => Some(Self::ChickenSoundVariant),
|
||||||
99u8 => Some(DataComponent::ZombieNautilusVariant),
|
99u8 => Some(Self::ZombieNautilusVariant),
|
||||||
100u8 => Some(DataComponent::FrogVariant),
|
100u8 => Some(Self::FrogVariant),
|
||||||
101u8 => Some(DataComponent::HorseVariant),
|
101u8 => Some(Self::HorseVariant),
|
||||||
102u8 => Some(DataComponent::PaintingVariant),
|
102u8 => Some(Self::PaintingVariant),
|
||||||
103u8 => Some(DataComponent::LlamaVariant),
|
103u8 => Some(Self::LlamaVariant),
|
||||||
104u8 => Some(DataComponent::AxolotlVariant),
|
104u8 => Some(Self::AxolotlVariant),
|
||||||
105u8 => Some(DataComponent::CatVariant),
|
105u8 => Some(Self::CatVariant),
|
||||||
106u8 => Some(DataComponent::CatSoundVariant),
|
106u8 => Some(Self::CatSoundVariant),
|
||||||
107u8 => Some(DataComponent::CatCollar),
|
107u8 => Some(Self::CatCollar),
|
||||||
108u8 => Some(DataComponent::SheepColor),
|
108u8 => Some(Self::SheepColor),
|
||||||
109u8 => Some(DataComponent::ShulkerColor),
|
109u8 => Some(Self::ShulkerColor),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn try_from_name(name: &str) -> Option<DataComponent> {
|
#[must_use]
|
||||||
|
#[allow(clippy::too_many_lines)]
|
||||||
|
pub fn try_from_name(name: &str) -> Option<Self> {
|
||||||
match name {
|
match name {
|
||||||
"minecraft:custom_data" => Some(DataComponent::CustomData),
|
"minecraft:custom_data" => Some(Self::CustomData),
|
||||||
"minecraft:max_stack_size" => Some(DataComponent::MaxStackSize),
|
"minecraft:max_stack_size" => Some(Self::MaxStackSize),
|
||||||
"minecraft:max_damage" => Some(DataComponent::MaxDamage),
|
"minecraft:max_damage" => Some(Self::MaxDamage),
|
||||||
"minecraft:damage" => Some(DataComponent::Damage),
|
"minecraft:damage" => Some(Self::Damage),
|
||||||
"minecraft:unbreakable" => Some(DataComponent::Unbreakable),
|
"minecraft:unbreakable" => Some(Self::Unbreakable),
|
||||||
"minecraft:use_effects" => Some(DataComponent::UseEffects),
|
"minecraft:use_effects" => Some(Self::UseEffects),
|
||||||
"minecraft:custom_name" => Some(DataComponent::CustomName),
|
"minecraft:custom_name" => Some(Self::CustomName),
|
||||||
"minecraft:minimum_attack_charge" => Some(DataComponent::MinimumAttackCharge),
|
"minecraft:minimum_attack_charge" => Some(Self::MinimumAttackCharge),
|
||||||
"minecraft:damage_type" => Some(DataComponent::DamageType),
|
"minecraft:damage_type" => Some(Self::DamageType),
|
||||||
"minecraft:item_name" => Some(DataComponent::ItemName),
|
"minecraft:item_name" => Some(Self::ItemName),
|
||||||
"minecraft:item_model" => Some(DataComponent::ItemModel),
|
"minecraft:item_model" => Some(Self::ItemModel),
|
||||||
"minecraft:lore" => Some(DataComponent::Lore),
|
"minecraft:lore" => Some(Self::Lore),
|
||||||
"minecraft:rarity" => Some(DataComponent::Rarity),
|
"minecraft:rarity" => Some(Self::Rarity),
|
||||||
"minecraft:enchantments" => Some(DataComponent::Enchantments),
|
"minecraft:enchantments" => Some(Self::Enchantments),
|
||||||
"minecraft:can_place_on" => Some(DataComponent::CanPlaceOn),
|
"minecraft:can_place_on" => Some(Self::CanPlaceOn),
|
||||||
"minecraft:can_break" => Some(DataComponent::CanBreak),
|
"minecraft:can_break" => Some(Self::CanBreak),
|
||||||
"minecraft:attribute_modifiers" => Some(DataComponent::AttributeModifiers),
|
"minecraft:attribute_modifiers" => Some(Self::AttributeModifiers),
|
||||||
"minecraft:custom_model_data" => Some(DataComponent::CustomModelData),
|
"minecraft:custom_model_data" => Some(Self::CustomModelData),
|
||||||
"minecraft:tooltip_display" => Some(DataComponent::TooltipDisplay),
|
"minecraft:tooltip_display" => Some(Self::TooltipDisplay),
|
||||||
"minecraft:repair_cost" => Some(DataComponent::RepairCost),
|
"minecraft:repair_cost" => Some(Self::RepairCost),
|
||||||
"minecraft:creative_slot_lock" => Some(DataComponent::CreativeSlotLock),
|
"minecraft:creative_slot_lock" => Some(Self::CreativeSlotLock),
|
||||||
"minecraft:enchantment_glint_override" => Some(DataComponent::EnchantmentGlintOverride),
|
"minecraft:enchantment_glint_override" => Some(Self::EnchantmentGlintOverride),
|
||||||
"minecraft:intangible_projectile" => Some(DataComponent::IntangibleProjectile),
|
"minecraft:intangible_projectile" => Some(Self::IntangibleProjectile),
|
||||||
"minecraft:food" => Some(DataComponent::Food),
|
"minecraft:food" => Some(Self::Food),
|
||||||
"minecraft:consumable" => Some(DataComponent::Consumable),
|
"minecraft:consumable" => Some(Self::Consumable),
|
||||||
"minecraft:use_remainder" => Some(DataComponent::UseRemainder),
|
"minecraft:use_remainder" => Some(Self::UseRemainder),
|
||||||
"minecraft:use_cooldown" => Some(DataComponent::UseCooldown),
|
"minecraft:use_cooldown" => Some(Self::UseCooldown),
|
||||||
"minecraft:damage_resistant" => Some(DataComponent::DamageResistant),
|
"minecraft:damage_resistant" => Some(Self::DamageResistant),
|
||||||
"minecraft:tool" => Some(DataComponent::Tool),
|
"minecraft:tool" => Some(Self::Tool),
|
||||||
"minecraft:weapon" => Some(DataComponent::Weapon),
|
"minecraft:weapon" => Some(Self::Weapon),
|
||||||
"minecraft:attack_range" => Some(DataComponent::AttackRange),
|
"minecraft:attack_range" => Some(Self::AttackRange),
|
||||||
"minecraft:enchantable" => Some(DataComponent::Enchantable),
|
"minecraft:enchantable" => Some(Self::Enchantable),
|
||||||
"minecraft:equippable" => Some(DataComponent::Equippable),
|
"minecraft:equippable" => Some(Self::Equippable),
|
||||||
"minecraft:repairable" => Some(DataComponent::Repairable),
|
"minecraft:repairable" => Some(Self::Repairable),
|
||||||
"minecraft:glider" => Some(DataComponent::Glider),
|
"minecraft:glider" => Some(Self::Glider),
|
||||||
"minecraft:tooltip_style" => Some(DataComponent::TooltipStyle),
|
"minecraft:tooltip_style" => Some(Self::TooltipStyle),
|
||||||
"minecraft:death_protection" => Some(DataComponent::DeathProtection),
|
"minecraft:death_protection" => Some(Self::DeathProtection),
|
||||||
"minecraft:blocks_attacks" => Some(DataComponent::BlocksAttacks),
|
"minecraft:blocks_attacks" => Some(Self::BlocksAttacks),
|
||||||
"minecraft:piercing_weapon" => Some(DataComponent::PiercingWeapon),
|
"minecraft:piercing_weapon" => Some(Self::PiercingWeapon),
|
||||||
"minecraft:kinetic_weapon" => Some(DataComponent::KineticWeapon),
|
"minecraft:kinetic_weapon" => Some(Self::KineticWeapon),
|
||||||
"minecraft:swing_animation" => Some(DataComponent::SwingAnimation),
|
"minecraft:swing_animation" => Some(Self::SwingAnimation),
|
||||||
"minecraft:additional_trade_cost" => Some(DataComponent::AdditionalTradeCost),
|
"minecraft:additional_trade_cost" => Some(Self::AdditionalTradeCost),
|
||||||
"minecraft:stored_enchantments" => Some(DataComponent::StoredEnchantments),
|
"minecraft:stored_enchantments" => Some(Self::StoredEnchantments),
|
||||||
"minecraft:dye" => Some(DataComponent::Dye),
|
"minecraft:dye" => Some(Self::Dye),
|
||||||
"minecraft:dyed_color" => Some(DataComponent::DyedColor),
|
"minecraft:dyed_color" => Some(Self::DyedColor),
|
||||||
"minecraft:map_color" => Some(DataComponent::MapColor),
|
"minecraft:map_color" => Some(Self::MapColor),
|
||||||
"minecraft:map_id" => Some(DataComponent::MapId),
|
"minecraft:map_id" => Some(Self::MapId),
|
||||||
"minecraft:map_decorations" => Some(DataComponent::MapDecorations),
|
"minecraft:map_decorations" => Some(Self::MapDecorations),
|
||||||
"minecraft:map_post_processing" => Some(DataComponent::MapPostProcessing),
|
"minecraft:map_post_processing" => Some(Self::MapPostProcessing),
|
||||||
"minecraft:charged_projectiles" => Some(DataComponent::ChargedProjectiles),
|
"minecraft:charged_projectiles" => Some(Self::ChargedProjectiles),
|
||||||
"minecraft:bundle_contents" => Some(DataComponent::BundleContents),
|
"minecraft:bundle_contents" => Some(Self::BundleContents),
|
||||||
"minecraft:potion_contents" => Some(DataComponent::PotionContents),
|
"minecraft:potion_contents" => Some(Self::PotionContents),
|
||||||
"minecraft:potion_duration_scale" => Some(DataComponent::PotionDurationScale),
|
"minecraft:potion_duration_scale" => Some(Self::PotionDurationScale),
|
||||||
"minecraft:suspicious_stew_effects" => Some(DataComponent::SuspiciousStewEffects),
|
"minecraft:suspicious_stew_effects" => Some(Self::SuspiciousStewEffects),
|
||||||
"minecraft:writable_book_content" => Some(DataComponent::WritableBookContent),
|
"minecraft:writable_book_content" => Some(Self::WritableBookContent),
|
||||||
"minecraft:written_book_content" => Some(DataComponent::WrittenBookContent),
|
"minecraft:written_book_content" => Some(Self::WrittenBookContent),
|
||||||
"minecraft:trim" => Some(DataComponent::Trim),
|
"minecraft:trim" => Some(Self::Trim),
|
||||||
"minecraft:debug_stick_state" => Some(DataComponent::DebugStickState),
|
"minecraft:debug_stick_state" => Some(Self::DebugStickState),
|
||||||
"minecraft:entity_data" => Some(DataComponent::EntityData),
|
"minecraft:entity_data" => Some(Self::EntityData),
|
||||||
"minecraft:bucket_entity_data" => Some(DataComponent::BucketEntityData),
|
"minecraft:bucket_entity_data" => Some(Self::BucketEntityData),
|
||||||
"minecraft:block_entity_data" => Some(DataComponent::BlockEntityData),
|
"minecraft:block_entity_data" => Some(Self::BlockEntityData),
|
||||||
"minecraft:instrument" => Some(DataComponent::Instrument),
|
"minecraft:instrument" => Some(Self::Instrument),
|
||||||
"minecraft:provides_trim_material" => Some(DataComponent::ProvidesTrimMaterial),
|
"minecraft:provides_trim_material" => Some(Self::ProvidesTrimMaterial),
|
||||||
"minecraft:ominous_bottle_amplifier" => Some(DataComponent::OminousBottleAmplifier),
|
"minecraft:ominous_bottle_amplifier" => Some(Self::OminousBottleAmplifier),
|
||||||
"minecraft:jukebox_playable" => Some(DataComponent::JukeboxPlayable),
|
"minecraft:jukebox_playable" => Some(Self::JukeboxPlayable),
|
||||||
"minecraft:provides_banner_patterns" => Some(DataComponent::ProvidesBannerPatterns),
|
"minecraft:provides_banner_patterns" => Some(Self::ProvidesBannerPatterns),
|
||||||
"minecraft:recipes" => Some(DataComponent::Recipes),
|
"minecraft:recipes" => Some(Self::Recipes),
|
||||||
"minecraft:lodestone_tracker" => Some(DataComponent::LodestoneTracker),
|
"minecraft:lodestone_tracker" => Some(Self::LodestoneTracker),
|
||||||
"minecraft:firework_explosion" => Some(DataComponent::FireworkExplosion),
|
"minecraft:firework_explosion" => Some(Self::FireworkExplosion),
|
||||||
"minecraft:fireworks" => Some(DataComponent::Fireworks),
|
"minecraft:fireworks" => Some(Self::Fireworks),
|
||||||
"minecraft:profile" => Some(DataComponent::Profile),
|
"minecraft:profile" => Some(Self::Profile),
|
||||||
"minecraft:note_block_sound" => Some(DataComponent::NoteBlockSound),
|
"minecraft:note_block_sound" => Some(Self::NoteBlockSound),
|
||||||
"minecraft:banner_patterns" => Some(DataComponent::BannerPatterns),
|
"minecraft:banner_patterns" => Some(Self::BannerPatterns),
|
||||||
"minecraft:base_color" => Some(DataComponent::BaseColor),
|
"minecraft:base_color" => Some(Self::BaseColor),
|
||||||
"minecraft:pot_decorations" => Some(DataComponent::PotDecorations),
|
"minecraft:pot_decorations" => Some(Self::PotDecorations),
|
||||||
"minecraft:container" => Some(DataComponent::Container),
|
"minecraft:container" => Some(Self::Container),
|
||||||
"minecraft:block_state" => Some(DataComponent::BlockState),
|
"minecraft:block_state" => Some(Self::BlockState),
|
||||||
"minecraft:bees" => Some(DataComponent::Bees),
|
"minecraft:bees" => Some(Self::Bees),
|
||||||
"minecraft:lock" => Some(DataComponent::Lock),
|
"minecraft:lock" => Some(Self::Lock),
|
||||||
"minecraft:container_loot" => Some(DataComponent::ContainerLoot),
|
"minecraft:container_loot" => Some(Self::ContainerLoot),
|
||||||
"minecraft:break_sound" => Some(DataComponent::BreakSound),
|
"minecraft:break_sound" => Some(Self::BreakSound),
|
||||||
"minecraft:villager/variant" => Some(DataComponent::VillagerVariant),
|
"minecraft:villager/variant" => Some(Self::VillagerVariant),
|
||||||
"minecraft:wolf/variant" => Some(DataComponent::WolfVariant),
|
"minecraft:wolf/variant" => Some(Self::WolfVariant),
|
||||||
"minecraft:wolf/sound_variant" => Some(DataComponent::WolfSoundVariant),
|
"minecraft:wolf/sound_variant" => Some(Self::WolfSoundVariant),
|
||||||
"minecraft:wolf/collar" => Some(DataComponent::WolfCollar),
|
"minecraft:wolf/collar" => Some(Self::WolfCollar),
|
||||||
"minecraft:fox/variant" => Some(DataComponent::FoxVariant),
|
"minecraft:fox/variant" => Some(Self::FoxVariant),
|
||||||
"minecraft:salmon/size" => Some(DataComponent::SalmonSize),
|
"minecraft:salmon/size" => Some(Self::SalmonSize),
|
||||||
"minecraft:parrot/variant" => Some(DataComponent::ParrotVariant),
|
"minecraft:parrot/variant" => Some(Self::ParrotVariant),
|
||||||
"minecraft:tropical_fish/pattern" => Some(DataComponent::TropicalFishPattern),
|
"minecraft:tropical_fish/pattern" => Some(Self::TropicalFishPattern),
|
||||||
"minecraft:tropical_fish/base_color" => Some(DataComponent::TropicalFishBaseColor),
|
"minecraft:tropical_fish/base_color" => Some(Self::TropicalFishBaseColor),
|
||||||
"minecraft:tropical_fish/pattern_color" => {
|
"minecraft:tropical_fish/pattern_color" => Some(Self::TropicalFishPatternColor),
|
||||||
Some(DataComponent::TropicalFishPatternColor)
|
"minecraft:mooshroom/variant" => Some(Self::MooshroomVariant),
|
||||||
}
|
"minecraft:rabbit/variant" => Some(Self::RabbitVariant),
|
||||||
"minecraft:mooshroom/variant" => Some(DataComponent::MooshroomVariant),
|
"minecraft:pig/variant" => Some(Self::PigVariant),
|
||||||
"minecraft:rabbit/variant" => Some(DataComponent::RabbitVariant),
|
"minecraft:pig/sound_variant" => Some(Self::PigSoundVariant),
|
||||||
"minecraft:pig/variant" => Some(DataComponent::PigVariant),
|
"minecraft:cow/variant" => Some(Self::CowVariant),
|
||||||
"minecraft:pig/sound_variant" => Some(DataComponent::PigSoundVariant),
|
"minecraft:cow/sound_variant" => Some(Self::CowSoundVariant),
|
||||||
"minecraft:cow/variant" => Some(DataComponent::CowVariant),
|
"minecraft:chicken/variant" => Some(Self::ChickenVariant),
|
||||||
"minecraft:cow/sound_variant" => Some(DataComponent::CowSoundVariant),
|
"minecraft:chicken/sound_variant" => Some(Self::ChickenSoundVariant),
|
||||||
"minecraft:chicken/variant" => Some(DataComponent::ChickenVariant),
|
"minecraft:zombie_nautilus/variant" => Some(Self::ZombieNautilusVariant),
|
||||||
"minecraft:chicken/sound_variant" => Some(DataComponent::ChickenSoundVariant),
|
"minecraft:frog/variant" => Some(Self::FrogVariant),
|
||||||
"minecraft:zombie_nautilus/variant" => Some(DataComponent::ZombieNautilusVariant),
|
"minecraft:horse/variant" => Some(Self::HorseVariant),
|
||||||
"minecraft:frog/variant" => Some(DataComponent::FrogVariant),
|
"minecraft:painting/variant" => Some(Self::PaintingVariant),
|
||||||
"minecraft:horse/variant" => Some(DataComponent::HorseVariant),
|
"minecraft:llama/variant" => Some(Self::LlamaVariant),
|
||||||
"minecraft:painting/variant" => Some(DataComponent::PaintingVariant),
|
"minecraft:axolotl/variant" => Some(Self::AxolotlVariant),
|
||||||
"minecraft:llama/variant" => Some(DataComponent::LlamaVariant),
|
"minecraft:cat/variant" => Some(Self::CatVariant),
|
||||||
"minecraft:axolotl/variant" => Some(DataComponent::AxolotlVariant),
|
"minecraft:cat/sound_variant" => Some(Self::CatSoundVariant),
|
||||||
"minecraft:cat/variant" => Some(DataComponent::CatVariant),
|
"minecraft:cat/collar" => Some(Self::CatCollar),
|
||||||
"minecraft:cat/sound_variant" => Some(DataComponent::CatSoundVariant),
|
"minecraft:sheep/color" => Some(Self::SheepColor),
|
||||||
"minecraft:cat/collar" => Some(DataComponent::CatCollar),
|
"minecraft:shulker/color" => Some(Self::ShulkerColor),
|
||||||
"minecraft:sheep/color" => Some(DataComponent::SheepColor),
|
|
||||||
"minecraft:shulker/color" => Some(DataComponent::ShulkerColor),
|
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#[must_use]
|
||||||
|
#[allow(clippy::too_many_lines)]
|
||||||
pub const fn to_name(self) -> &'static str {
|
pub const fn to_name(self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
Self::CustomData => "minecraft:custom_data",
|
Self::CustomData => "minecraft:custom_data",
|
||||||
|
|||||||
@ -418,6 +418,7 @@ impl StatusEffect {
|
|||||||
translation_key: "effect.minecraft.wither",
|
translation_key: "effect.minecraft.wither",
|
||||||
attribute_modifiers: &[],
|
attribute_modifiers: &[],
|
||||||
};
|
};
|
||||||
|
#[must_use]
|
||||||
pub fn from_name(name: &str) -> Option<&'static Self> {
|
pub fn from_name(name: &str) -> Option<&'static Self> {
|
||||||
match name {
|
match name {
|
||||||
"absorption" => Some(&Self::ABSORPTION),
|
"absorption" => Some(&Self::ABSORPTION),
|
||||||
@ -463,6 +464,7 @@ impl StatusEffect {
|
|||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#[must_use]
|
||||||
pub fn from_minecraft_name(name: &str) -> Option<&'static Self> {
|
pub fn from_minecraft_name(name: &str) -> Option<&'static Self> {
|
||||||
match name {
|
match name {
|
||||||
"minecraft:absorption" => Some(&Self::ABSORPTION),
|
"minecraft:absorption" => Some(&Self::ABSORPTION),
|
||||||
@ -510,9 +512,11 @@ impl StatusEffect {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl IDSetContent for StatusEffect {
|
impl IDSetContent for StatusEffect {
|
||||||
|
|
||||||
fn registry_id(&self) -> u16 {
|
fn registry_id(&self) -> u16 {
|
||||||
self.id as u16
|
self.id as u16
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_id(id: u16) -> Option<&'static Self> {
|
fn from_id(id: u16) -> Option<&'static Self> {
|
||||||
match id {
|
match id {
|
||||||
21u16 => Some(&Self::ABSORPTION),
|
21u16 => Some(&Self::ABSORPTION),
|
||||||
@ -558,9 +562,11 @@ impl IDSetContent for StatusEffect {
|
|||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_str(name: &str) -> Option<&'static Self> {
|
fn from_str(name: &str) -> Option<&'static Self> {
|
||||||
StatusEffect::from_minecraft_name(name)
|
Self::from_minecraft_name(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_string(&self) -> String {
|
fn to_string(&self) -> String {
|
||||||
self.minecraft_name.to_string()
|
self.minecraft_name.to_string()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -282,6 +282,7 @@ pub const FUELS: [(u16, u16); 280usize] = [
|
|||||||
(1361u16, 300u16),
|
(1361u16, 300u16),
|
||||||
];
|
];
|
||||||
#[must_use]
|
#[must_use]
|
||||||
|
#[allow(clippy::too_many_lines, clippy::match_same_arms)]
|
||||||
pub const fn get_item_burn_ticks(item_id: u16) -> Option<u16> {
|
pub const fn get_item_burn_ticks(item_id: u16) -> Option<u16> {
|
||||||
match item_id {
|
match item_id {
|
||||||
36u16 => Some(300u16),
|
36u16 => Some(300u16),
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -25,7 +25,8 @@ pub enum JukeboxSong {
|
|||||||
Ward,
|
Ward,
|
||||||
}
|
}
|
||||||
impl JukeboxSong {
|
impl JukeboxSong {
|
||||||
#[doc = r" Returns the JukeboxSong from the string name (e.g., 'pigstep')."]
|
#[doc = r" Returns the `JukeboxSong` from the string name (e.g., 'pigstep')."]
|
||||||
|
#[must_use]
|
||||||
pub fn from_name(name: &str) -> Option<Self> {
|
pub fn from_name(name: &str) -> Option<Self> {
|
||||||
match name {
|
match name {
|
||||||
"11" => Some(Self::Id11),
|
"11" => Some(Self::Id11),
|
||||||
@ -53,6 +54,7 @@ impl JukeboxSong {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[doc = r" Returns the string name of the song."]
|
#[doc = r" Returns the string name of the song."]
|
||||||
|
#[must_use]
|
||||||
pub const fn to_name(&self) -> &'static str {
|
pub const fn to_name(&self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
Self::Id11 => "11",
|
Self::Id11 => "11",
|
||||||
@ -79,6 +81,7 @@ impl JukeboxSong {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[doc = r" Returns the numeric ID associated with the song."]
|
#[doc = r" Returns the numeric ID associated with the song."]
|
||||||
|
#[must_use]
|
||||||
pub const fn get_id(&self) -> u32 {
|
pub const fn get_id(&self) -> u32 {
|
||||||
match self {
|
match self {
|
||||||
Self::Id11 => 0u32,
|
Self::Id11 => 0u32,
|
||||||
@ -105,7 +108,9 @@ impl JukeboxSong {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[doc = r" Returns the comparator output value (0-15) for this song."]
|
#[doc = r" Returns the comparator output value (0-15) for this song."]
|
||||||
|
#[must_use]
|
||||||
pub const fn comparator_output(&self) -> u8 {
|
pub const fn comparator_output(&self) -> u8 {
|
||||||
|
#[allow(clippy::match_same_arms)]
|
||||||
match self {
|
match self {
|
||||||
Self::Id11 => 11u8,
|
Self::Id11 => 11u8,
|
||||||
Self::Id13 => 1u8,
|
Self::Id13 => 1u8,
|
||||||
@ -131,7 +136,9 @@ impl JukeboxSong {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[doc = r" Returns the song length in seconds."]
|
#[doc = r" Returns the song length in seconds."]
|
||||||
|
#[must_use]
|
||||||
pub const fn length_in_seconds(&self) -> u32 {
|
pub const fn length_in_seconds(&self) -> u32 {
|
||||||
|
#[allow(clippy::match_same_arms)]
|
||||||
match self {
|
match self {
|
||||||
Self::Id11 => 71u32,
|
Self::Id11 => 71u32,
|
||||||
Self::Id13 => 178u32,
|
Self::Id13 => 178u32,
|
||||||
@ -157,6 +164,7 @@ impl JukeboxSong {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[doc = r" Returns the song length in ticks (20 ticks per second)."]
|
#[doc = r" Returns the song length in ticks (20 ticks per second)."]
|
||||||
|
#[must_use]
|
||||||
pub const fn length_in_ticks(&self) -> u64 {
|
pub const fn length_in_ticks(&self) -> u64 {
|
||||||
self.length_in_seconds() as u64 * 20
|
self.length_in_seconds() as u64 * 20
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,14 +21,17 @@ pub enum WeirdScaledMapper {
|
|||||||
}
|
}
|
||||||
impl WeirdScaledMapper {
|
impl WeirdScaledMapper {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn max_multiplier(&self) -> f64 {
|
#[must_use]
|
||||||
|
pub const fn max_multiplier(&self) -> f64 {
|
||||||
match self {
|
match self {
|
||||||
Self::Tunnels => 2.0,
|
Self::Tunnels => 2.0,
|
||||||
Self::Caves => 3.0,
|
Self::Caves => 3.0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn scale(&self, value: f64) -> f64 {
|
#[must_use]
|
||||||
|
#[allow(clippy::too_many_lines)]
|
||||||
|
pub const fn scale(&self, value: f64) -> f64 {
|
||||||
match self {
|
match self {
|
||||||
Self::Tunnels => {
|
Self::Tunnels => {
|
||||||
if value < -0.5 {
|
if value < -0.5 {
|
||||||
@ -95,7 +98,8 @@ pub struct LinearData {
|
|||||||
}
|
}
|
||||||
impl LinearData {
|
impl LinearData {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn apply_density(&self, density: f64) -> f64 {
|
#[must_use]
|
||||||
|
pub const fn apply_density(&self, density: f64) -> f64 {
|
||||||
match self.operation {
|
match self.operation {
|
||||||
LinearOperation::Add => density + self.argument,
|
LinearOperation::Add => density + self.argument,
|
||||||
LinearOperation::Mul => density * self.argument,
|
LinearOperation::Mul => density * self.argument,
|
||||||
@ -117,7 +121,9 @@ pub struct UnaryData {
|
|||||||
}
|
}
|
||||||
impl UnaryData {
|
impl UnaryData {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn apply_density(&self, density: f64) -> f64 {
|
#[must_use]
|
||||||
|
#[allow(clippy::too_many_lines)]
|
||||||
|
pub const fn apply_density(&self, density: f64) -> f64 {
|
||||||
match self.operation {
|
match self.operation {
|
||||||
UnaryOperation::Abs => density.abs(),
|
UnaryOperation::Abs => density.abs(),
|
||||||
UnaryOperation::Square => density * density,
|
UnaryOperation::Square => density * density,
|
||||||
@ -156,7 +162,8 @@ pub struct ClampData {
|
|||||||
}
|
}
|
||||||
impl ClampData {
|
impl ClampData {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn apply_density(&self, density: f64) -> f64 {
|
#[must_use]
|
||||||
|
pub const fn apply_density(&self, density: f64) -> f64 {
|
||||||
density.clamp(self.min_value, self.max_value)
|
density.clamp(self.min_value, self.max_value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,7 +19,9 @@ pub struct PacketId {
|
|||||||
impl PacketId {
|
impl PacketId {
|
||||||
#[doc = r" Converts the requested protocol version into the corresponding packet ID."]
|
#[doc = r" Converts the requested protocol version into the corresponding packet ID."]
|
||||||
#[doc = r" Returns -1 if the packet does not exist in that version."]
|
#[doc = r" Returns -1 if the packet does not exist in that version."]
|
||||||
pub fn to_id(&self, version: JavaMinecraftVersion) -> i32 {
|
#[must_use]
|
||||||
|
pub const fn to_id(&self, version: JavaMinecraftVersion) -> i32 {
|
||||||
|
#[allow(clippy::match_same_arms)]
|
||||||
match version {
|
match version {
|
||||||
pumpkin_util::version::JavaMinecraftVersion::V_1_20_5 => self.v1_20_5,
|
pumpkin_util::version::JavaMinecraftVersion::V_1_20_5 => self.v1_20_5,
|
||||||
pumpkin_util::version::JavaMinecraftVersion::V_1_21 => self.v1_21,
|
pumpkin_util::version::JavaMinecraftVersion::V_1_21 => self.v1_21,
|
||||||
|
|||||||
@ -121,6 +121,8 @@ pub enum Particle {
|
|||||||
}
|
}
|
||||||
impl Particle {
|
impl Particle {
|
||||||
#[doc = r" Try to parse a `Particle` from a resource location string."]
|
#[doc = r" Try to parse a `Particle` from a resource location string."]
|
||||||
|
#[must_use]
|
||||||
|
#[allow(clippy::too_many_lines)]
|
||||||
pub fn from_name(name: &str) -> Option<Self> {
|
pub fn from_name(name: &str) -> Option<Self> {
|
||||||
match name {
|
match name {
|
||||||
"angry_villager" => Some(Self::AngryVillager),
|
"angry_villager" => Some(Self::AngryVillager),
|
||||||
@ -243,6 +245,8 @@ impl Particle {
|
|||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#[must_use]
|
||||||
|
#[allow(clippy::too_many_lines)]
|
||||||
pub const fn to_name(&self) -> &'static str {
|
pub const fn to_name(&self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
Self::AngryVillager => "angry_villager",
|
Self::AngryVillager => "angry_villager",
|
||||||
|
|||||||
@ -616,6 +616,7 @@ impl Potion {
|
|||||||
blend: false,
|
blend: false,
|
||||||
}],
|
}],
|
||||||
};
|
};
|
||||||
|
#[must_use]
|
||||||
pub fn from_name(name: &str) -> Option<&'static Self> {
|
pub fn from_name(name: &str) -> Option<&'static Self> {
|
||||||
match name {
|
match name {
|
||||||
"awkward" => Some(&Self::AWKWARD),
|
"awkward" => Some(&Self::AWKWARD),
|
||||||
|
|||||||
@ -13,24 +13,30 @@ pub struct ItemRecipe {
|
|||||||
to: &'static Item,
|
to: &'static Item,
|
||||||
}
|
}
|
||||||
impl PotionRecipe {
|
impl PotionRecipe {
|
||||||
pub fn from(&self) -> &'static Potion {
|
#[must_use]
|
||||||
|
pub const fn from(&self) -> &'static Potion {
|
||||||
self.from
|
self.from
|
||||||
}
|
}
|
||||||
pub fn ingredient(&self) -> &'static [&'static Item] {
|
#[must_use]
|
||||||
|
pub const fn ingredient(&self) -> &'static [&'static Item] {
|
||||||
self.ingredient
|
self.ingredient
|
||||||
}
|
}
|
||||||
pub fn to(&self) -> &'static Potion {
|
#[must_use]
|
||||||
|
pub const fn to(&self) -> &'static Potion {
|
||||||
self.to
|
self.to
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl ItemRecipe {
|
impl ItemRecipe {
|
||||||
pub fn from(&self) -> &'static Item {
|
#[must_use]
|
||||||
|
pub const fn from(&self) -> &'static Item {
|
||||||
self.from
|
self.from
|
||||||
}
|
}
|
||||||
pub fn ingredient(&self) -> &'static [&'static Item] {
|
#[must_use]
|
||||||
|
pub const fn ingredient(&self) -> &'static [&'static Item] {
|
||||||
self.ingredient
|
self.ingredient
|
||||||
}
|
}
|
||||||
pub fn to(&self) -> &'static Item {
|
#[must_use]
|
||||||
|
pub const fn to(&self) -> &'static Item {
|
||||||
self.to
|
self.to
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
/* This file is generated. Do not edit manually. */
|
/* This file is generated. Do not edit manually. */
|
||||||
#[must_use]
|
#[must_use]
|
||||||
|
#[allow(clippy::match_same_arms)]
|
||||||
pub const fn get_recipe_remainder_id(item_id: u16) -> Option<u16> {
|
pub const fn get_recipe_remainder_id(item_id: u16) -> Option<u16> {
|
||||||
match item_id {
|
match item_id {
|
||||||
948 => Some(893),
|
948 => Some(893),
|
||||||
|
|||||||
@ -57,32 +57,35 @@ pub enum CookingRecipeKind {
|
|||||||
CampfireCooking,
|
CampfireCooking,
|
||||||
}
|
}
|
||||||
impl From<&CookingRecipeType> for CookingRecipeKind {
|
impl From<&CookingRecipeType> for CookingRecipeKind {
|
||||||
|
|
||||||
fn from(recipe_type: &CookingRecipeType) -> Self {
|
fn from(recipe_type: &CookingRecipeType) -> Self {
|
||||||
match recipe_type {
|
match recipe_type {
|
||||||
CookingRecipeType::Blasting(_) => CookingRecipeKind::Blasting,
|
CookingRecipeType::Blasting(_) => Self::Blasting,
|
||||||
CookingRecipeType::Smelting(_) => CookingRecipeKind::Smelting,
|
CookingRecipeType::Smelting(_) => Self::Smelting,
|
||||||
CookingRecipeType::Smoking(_) => CookingRecipeKind::Smoking,
|
CookingRecipeType::Smoking(_) => Self::Smoking,
|
||||||
CookingRecipeType::CampfireCooking(_) => CookingRecipeKind::CampfireCooking,
|
CookingRecipeType::CampfireCooking(_) => Self::CampfireCooking,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<CookingRecipeType> for CookingRecipeKind {
|
impl From<CookingRecipeType> for CookingRecipeKind {
|
||||||
|
|
||||||
fn from(recipe_type: CookingRecipeType) -> Self {
|
fn from(recipe_type: CookingRecipeType) -> Self {
|
||||||
match recipe_type {
|
match recipe_type {
|
||||||
CookingRecipeType::Blasting(_) => CookingRecipeKind::Blasting,
|
CookingRecipeType::Blasting(_) => Self::Blasting,
|
||||||
CookingRecipeType::Smelting(_) => CookingRecipeKind::Smelting,
|
CookingRecipeType::Smelting(_) => Self::Smelting,
|
||||||
CookingRecipeType::Smoking(_) => CookingRecipeKind::Smoking,
|
CookingRecipeType::Smoking(_) => Self::Smoking,
|
||||||
CookingRecipeType::CampfireCooking(_) => CookingRecipeKind::CampfireCooking,
|
CookingRecipeType::CampfireCooking(_) => Self::CampfireCooking,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl CookingRecipeKind {
|
impl CookingRecipeKind {
|
||||||
pub fn to_type(self, recipe: CookingRecipe) -> CookingRecipeType {
|
#[must_use]
|
||||||
|
pub const fn to_type(self, recipe: CookingRecipe) -> CookingRecipeType {
|
||||||
match self {
|
match self {
|
||||||
CookingRecipeKind::Blasting => CookingRecipeType::Blasting(recipe),
|
Self::Blasting => CookingRecipeType::Blasting(recipe),
|
||||||
CookingRecipeKind::Smelting => CookingRecipeType::Smelting(recipe),
|
Self::Smelting => CookingRecipeType::Smelting(recipe),
|
||||||
CookingRecipeKind::Smoking => CookingRecipeType::Smoking(recipe),
|
Self::Smoking => CookingRecipeType::Smoking(recipe),
|
||||||
CookingRecipeKind::CampfireCooking => CookingRecipeType::CampfireCooking(recipe),
|
Self::CampfireCooking => CookingRecipeType::CampfireCooking(recipe),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -104,16 +107,17 @@ pub enum RecipeIngredientTypes {
|
|||||||
OneOf(&'static [&'static str]),
|
OneOf(&'static [&'static str]),
|
||||||
}
|
}
|
||||||
impl RecipeIngredientTypes {
|
impl RecipeIngredientTypes {
|
||||||
|
#[must_use]
|
||||||
pub fn match_item(&self, item: &Item) -> bool {
|
pub fn match_item(&self, item: &Item) -> bool {
|
||||||
match self {
|
match self {
|
||||||
RecipeIngredientTypes::Simple(ingredient) => {
|
Self::Simple(ingredient) => {
|
||||||
let name = format!("minecraft:{}", item.registry_key);
|
let name = format!("minecraft:{}", item.registry_key);
|
||||||
name == *ingredient
|
name == *ingredient
|
||||||
}
|
}
|
||||||
RecipeIngredientTypes::Tagged(tag) => item
|
Self::Tagged(tag) => item
|
||||||
.is_tagged_with(tag)
|
.is_tagged_with(tag)
|
||||||
.expect("Crafting recipe used invalid tag"),
|
.expect("Crafting recipe used invalid tag"),
|
||||||
RecipeIngredientTypes::OneOf(ingredients) => {
|
Self::OneOf(ingredients) => {
|
||||||
let name = format!("minecraft:{}", item.registry_key);
|
let name = format!("minecraft:{}", item.registry_key);
|
||||||
ingredients.contains(&name.as_str())
|
ingredients.contains(&name.as_str())
|
||||||
}
|
}
|
||||||
@ -20478,6 +20482,7 @@ pub static RECIPES_STONECUTTING: &[StonecutterRecipe] = &[
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
#[must_use]
|
||||||
pub fn get_cooking_recipe_with_ingredient(
|
pub fn get_cooking_recipe_with_ingredient(
|
||||||
ingredient: &Item,
|
ingredient: &Item,
|
||||||
recipe_type: CookingRecipeKind,
|
recipe_type: CookingRecipeKind,
|
||||||
@ -20500,7 +20505,8 @@ pub fn get_cooking_recipe_with_ingredient(
|
|||||||
}
|
}
|
||||||
#[doc = r" Get the experience value for a recipe by its recipe ID."]
|
#[doc = r" Get the experience value for a recipe by its recipe ID."]
|
||||||
#[doc = r" Used for calculating XP when extracting from furnace."]
|
#[doc = r" Used for calculating XP when extracting from furnace."]
|
||||||
#[doc = r#" Recipe IDs are in vanilla format like "minecraft:iron_ingot_from_smelting_iron_ore""#]
|
#[doc = r#" Recipe IDs are in vanilla format like `"minecraft:iron_ingot_from_smelting_iron_ore"`"#]
|
||||||
|
#[must_use]
|
||||||
pub fn get_recipe_experience(recipe_id: &str) -> Option<f32> {
|
pub fn get_recipe_experience(recipe_id: &str) -> Option<f32> {
|
||||||
RECIPES_COOKING.iter().find_map(|recipe| {
|
RECIPES_COOKING.iter().find_map(|recipe| {
|
||||||
let cooking_recipe = match recipe {
|
let cooking_recipe = match recipe {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -3810,7 +3810,8 @@ impl Sound {
|
|||||||
"item.nautilus_saddle_underwater_equip",
|
"item.nautilus_saddle_underwater_equip",
|
||||||
"item.nautilus_saddle_equip",
|
"item.nautilus_saddle_equip",
|
||||||
];
|
];
|
||||||
const LOOKUP: &[(&str, Sound)] = &[
|
#[allow(clippy::large_stack_arrays)]
|
||||||
|
const LOOKUP: &[(&str, Self)] = &[
|
||||||
(
|
(
|
||||||
"ambient.basalt_deltas.additions",
|
"ambient.basalt_deltas.additions",
|
||||||
Self::AmbientBasaltDeltasAdditions,
|
Self::AmbientBasaltDeltasAdditions,
|
||||||
@ -7016,16 +7017,20 @@ impl Sound {
|
|||||||
("weather.rain", Self::WeatherRain),
|
("weather.rain", Self::WeatherRain),
|
||||||
("weather.rain.above", Self::WeatherRainAbove),
|
("weather.rain.above", Self::WeatherRainAbove),
|
||||||
];
|
];
|
||||||
|
#[must_use]
|
||||||
pub fn from_name(name: &str) -> Option<Self> {
|
pub fn from_name(name: &str) -> Option<Self> {
|
||||||
Self::LOOKUP
|
Self::LOOKUP
|
||||||
.binary_search_by_key(&name, |&(k, _)| k)
|
.binary_search_by_key(&name, |&(k, _)| k)
|
||||||
.ok()
|
.ok()
|
||||||
.map(|idx| Self::LOOKUP[idx].1)
|
.map(|idx| Self::LOOKUP[idx].1)
|
||||||
}
|
}
|
||||||
|
#[must_use]
|
||||||
pub const fn to_name(&self) -> &'static str {
|
pub const fn to_name(&self) -> &'static str {
|
||||||
Self::NAMES[*self as usize]
|
Self::NAMES[*self as usize]
|
||||||
}
|
}
|
||||||
pub fn slice() -> &'static [Self] {
|
#[must_use]
|
||||||
|
#[allow(clippy::large_stack_arrays, clippy::too_many_lines)]
|
||||||
|
pub const fn slice() -> &'static [Self] {
|
||||||
&[
|
&[
|
||||||
Self::EntityAllayAmbientWithItem,
|
Self::EntityAllayAmbientWithItem,
|
||||||
Self::EntityAllayAmbientWithoutItem,
|
Self::EntityAllayAmbientWithoutItem,
|
||||||
|
|||||||
@ -128,139 +128,139 @@ impl StructurePlacementCalculator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Structure {
|
impl Structure {
|
||||||
pub const ANCIENT_CITY: Structure = Structure {
|
pub const ANCIENT_CITY: Self = Structure {
|
||||||
biomes: "#minecraft:has_structure/ancient_city",
|
biomes: "#minecraft:has_structure/ancient_city",
|
||||||
step: GenerationStep::UndergroundDecoration,
|
step: GenerationStep::UndergroundDecoration,
|
||||||
};
|
};
|
||||||
pub const BASTION_REMNANT: Structure = Structure {
|
pub const BASTION_REMNANT: Self = Structure {
|
||||||
biomes: "#minecraft:has_structure/bastion_remnant",
|
biomes: "#minecraft:has_structure/bastion_remnant",
|
||||||
step: GenerationStep::SurfaceStructures,
|
step: GenerationStep::SurfaceStructures,
|
||||||
};
|
};
|
||||||
pub const BURIED_TREASURE: Structure = Structure {
|
pub const BURIED_TREASURE: Self = Structure {
|
||||||
biomes: "#minecraft:has_structure/buried_treasure",
|
biomes: "#minecraft:has_structure/buried_treasure",
|
||||||
step: GenerationStep::UndergroundStructures,
|
step: GenerationStep::UndergroundStructures,
|
||||||
};
|
};
|
||||||
pub const DESERT_PYRAMID: Structure = Structure {
|
pub const DESERT_PYRAMID: Self = Structure {
|
||||||
biomes: "#minecraft:has_structure/desert_pyramid",
|
biomes: "#minecraft:has_structure/desert_pyramid",
|
||||||
step: GenerationStep::SurfaceStructures,
|
step: GenerationStep::SurfaceStructures,
|
||||||
};
|
};
|
||||||
pub const END_CITY: Structure = Structure {
|
pub const END_CITY: Self = Structure {
|
||||||
biomes: "#minecraft:has_structure/end_city",
|
biomes: "#minecraft:has_structure/end_city",
|
||||||
step: GenerationStep::SurfaceStructures,
|
step: GenerationStep::SurfaceStructures,
|
||||||
};
|
};
|
||||||
pub const FORTRESS: Structure = Structure {
|
pub const FORTRESS: Self = Structure {
|
||||||
biomes: "#minecraft:has_structure/nether_fortress",
|
biomes: "#minecraft:has_structure/nether_fortress",
|
||||||
step: GenerationStep::UndergroundDecoration,
|
step: GenerationStep::UndergroundDecoration,
|
||||||
};
|
};
|
||||||
pub const IGLOO: Structure = Structure {
|
pub const IGLOO: Self = Structure {
|
||||||
biomes: "#minecraft:has_structure/igloo",
|
biomes: "#minecraft:has_structure/igloo",
|
||||||
step: GenerationStep::SurfaceStructures,
|
step: GenerationStep::SurfaceStructures,
|
||||||
};
|
};
|
||||||
pub const JUNGLE_PYRAMID: Structure = Structure {
|
pub const JUNGLE_PYRAMID: Self = Structure {
|
||||||
biomes: "#minecraft:has_structure/jungle_temple",
|
biomes: "#minecraft:has_structure/jungle_temple",
|
||||||
step: GenerationStep::SurfaceStructures,
|
step: GenerationStep::SurfaceStructures,
|
||||||
};
|
};
|
||||||
pub const MANSION: Structure = Structure {
|
pub const MANSION: Self = Structure {
|
||||||
biomes: "#minecraft:has_structure/woodland_mansion",
|
biomes: "#minecraft:has_structure/woodland_mansion",
|
||||||
step: GenerationStep::SurfaceStructures,
|
step: GenerationStep::SurfaceStructures,
|
||||||
};
|
};
|
||||||
pub const MINESHAFT: Structure = Structure {
|
pub const MINESHAFT: Self = Structure {
|
||||||
biomes: "#minecraft:has_structure/mineshaft",
|
biomes: "#minecraft:has_structure/mineshaft",
|
||||||
step: GenerationStep::UndergroundStructures,
|
step: GenerationStep::UndergroundStructures,
|
||||||
};
|
};
|
||||||
pub const MINESHAFT_MESA: Structure = Structure {
|
pub const MINESHAFT_MESA: Self = Structure {
|
||||||
biomes: "#minecraft:has_structure/mineshaft_mesa",
|
biomes: "#minecraft:has_structure/mineshaft_mesa",
|
||||||
step: GenerationStep::UndergroundStructures,
|
step: GenerationStep::UndergroundStructures,
|
||||||
};
|
};
|
||||||
pub const MONUMENT: Structure = Structure {
|
pub const MONUMENT: Self = Structure {
|
||||||
biomes: "#minecraft:has_structure/ocean_monument",
|
biomes: "#minecraft:has_structure/ocean_monument",
|
||||||
step: GenerationStep::SurfaceStructures,
|
step: GenerationStep::SurfaceStructures,
|
||||||
};
|
};
|
||||||
pub const NETHER_FOSSIL: Structure = Structure {
|
pub const NETHER_FOSSIL: Self = Structure {
|
||||||
biomes: "#minecraft:has_structure/nether_fossil",
|
biomes: "#minecraft:has_structure/nether_fossil",
|
||||||
step: GenerationStep::UndergroundDecoration,
|
step: GenerationStep::UndergroundDecoration,
|
||||||
};
|
};
|
||||||
pub const OCEAN_RUIN_COLD: Structure = Structure {
|
pub const OCEAN_RUIN_COLD: Self = Structure {
|
||||||
biomes: "#minecraft:has_structure/ocean_ruin_cold",
|
biomes: "#minecraft:has_structure/ocean_ruin_cold",
|
||||||
step: GenerationStep::SurfaceStructures,
|
step: GenerationStep::SurfaceStructures,
|
||||||
};
|
};
|
||||||
pub const OCEAN_RUIN_WARM: Structure = Structure {
|
pub const OCEAN_RUIN_WARM: Self = Structure {
|
||||||
biomes: "#minecraft:has_structure/ocean_ruin_warm",
|
biomes: "#minecraft:has_structure/ocean_ruin_warm",
|
||||||
step: GenerationStep::SurfaceStructures,
|
step: GenerationStep::SurfaceStructures,
|
||||||
};
|
};
|
||||||
pub const PILLAGER_OUTPOST: Structure = Structure {
|
pub const PILLAGER_OUTPOST: Self = Structure {
|
||||||
biomes: "#minecraft:has_structure/pillager_outpost",
|
biomes: "#minecraft:has_structure/pillager_outpost",
|
||||||
step: GenerationStep::SurfaceStructures,
|
step: GenerationStep::SurfaceStructures,
|
||||||
};
|
};
|
||||||
pub const RUINED_PORTAL: Structure = Structure {
|
pub const RUINED_PORTAL: Self = Structure {
|
||||||
biomes: "#minecraft:has_structure/ruined_portal_standard",
|
biomes: "#minecraft:has_structure/ruined_portal_standard",
|
||||||
step: GenerationStep::SurfaceStructures,
|
step: GenerationStep::SurfaceStructures,
|
||||||
};
|
};
|
||||||
pub const RUINED_PORTAL_DESERT: Structure = Structure {
|
pub const RUINED_PORTAL_DESERT: Self = Structure {
|
||||||
biomes: "#minecraft:has_structure/ruined_portal_desert",
|
biomes: "#minecraft:has_structure/ruined_portal_desert",
|
||||||
step: GenerationStep::SurfaceStructures,
|
step: GenerationStep::SurfaceStructures,
|
||||||
};
|
};
|
||||||
pub const RUINED_PORTAL_JUNGLE: Structure = Structure {
|
pub const RUINED_PORTAL_JUNGLE: Self = Structure {
|
||||||
biomes: "#minecraft:has_structure/ruined_portal_jungle",
|
biomes: "#minecraft:has_structure/ruined_portal_jungle",
|
||||||
step: GenerationStep::SurfaceStructures,
|
step: GenerationStep::SurfaceStructures,
|
||||||
};
|
};
|
||||||
pub const RUINED_PORTAL_MOUNTAIN: Structure = Structure {
|
pub const RUINED_PORTAL_MOUNTAIN: Self = Structure {
|
||||||
biomes: "#minecraft:has_structure/ruined_portal_mountain",
|
biomes: "#minecraft:has_structure/ruined_portal_mountain",
|
||||||
step: GenerationStep::SurfaceStructures,
|
step: GenerationStep::SurfaceStructures,
|
||||||
};
|
};
|
||||||
pub const RUINED_PORTAL_NETHER: Structure = Structure {
|
pub const RUINED_PORTAL_NETHER: Self = Structure {
|
||||||
biomes: "#minecraft:has_structure/ruined_portal_nether",
|
biomes: "#minecraft:has_structure/ruined_portal_nether",
|
||||||
step: GenerationStep::SurfaceStructures,
|
step: GenerationStep::SurfaceStructures,
|
||||||
};
|
};
|
||||||
pub const RUINED_PORTAL_OCEAN: Structure = Structure {
|
pub const RUINED_PORTAL_OCEAN: Self = Structure {
|
||||||
biomes: "#minecraft:has_structure/ruined_portal_ocean",
|
biomes: "#minecraft:has_structure/ruined_portal_ocean",
|
||||||
step: GenerationStep::SurfaceStructures,
|
step: GenerationStep::SurfaceStructures,
|
||||||
};
|
};
|
||||||
pub const RUINED_PORTAL_SWAMP: Structure = Structure {
|
pub const RUINED_PORTAL_SWAMP: Self = Structure {
|
||||||
biomes: "#minecraft:has_structure/ruined_portal_swamp",
|
biomes: "#minecraft:has_structure/ruined_portal_swamp",
|
||||||
step: GenerationStep::SurfaceStructures,
|
step: GenerationStep::SurfaceStructures,
|
||||||
};
|
};
|
||||||
pub const SHIPWRECK: Structure = Structure {
|
pub const SHIPWRECK: Self = Structure {
|
||||||
biomes: "#minecraft:has_structure/shipwreck",
|
biomes: "#minecraft:has_structure/shipwreck",
|
||||||
step: GenerationStep::SurfaceStructures,
|
step: GenerationStep::SurfaceStructures,
|
||||||
};
|
};
|
||||||
pub const SHIPWRECK_BEACHED: Structure = Structure {
|
pub const SHIPWRECK_BEACHED: Self = Structure {
|
||||||
biomes: "#minecraft:has_structure/shipwreck_beached",
|
biomes: "#minecraft:has_structure/shipwreck_beached",
|
||||||
step: GenerationStep::SurfaceStructures,
|
step: GenerationStep::SurfaceStructures,
|
||||||
};
|
};
|
||||||
pub const STRONGHOLD: Structure = Structure {
|
pub const STRONGHOLD: Self = Structure {
|
||||||
biomes: "#minecraft:has_structure/stronghold",
|
biomes: "#minecraft:has_structure/stronghold",
|
||||||
step: GenerationStep::SurfaceStructures,
|
step: GenerationStep::SurfaceStructures,
|
||||||
};
|
};
|
||||||
pub const SWAMP_HUT: Structure = Structure {
|
pub const SWAMP_HUT: Self = Structure {
|
||||||
biomes: "#minecraft:has_structure/swamp_hut",
|
biomes: "#minecraft:has_structure/swamp_hut",
|
||||||
step: GenerationStep::SurfaceStructures,
|
step: GenerationStep::SurfaceStructures,
|
||||||
};
|
};
|
||||||
pub const TRAIL_RUINS: Structure = Structure {
|
pub const TRAIL_RUINS: Self = Structure {
|
||||||
biomes: "#minecraft:has_structure/trail_ruins",
|
biomes: "#minecraft:has_structure/trail_ruins",
|
||||||
step: GenerationStep::UndergroundStructures,
|
step: GenerationStep::UndergroundStructures,
|
||||||
};
|
};
|
||||||
pub const TRIAL_CHAMBERS: Structure = Structure {
|
pub const TRIAL_CHAMBERS: Self = Structure {
|
||||||
biomes: "#minecraft:has_structure/trial_chambers",
|
biomes: "#minecraft:has_structure/trial_chambers",
|
||||||
step: GenerationStep::UndergroundStructures,
|
step: GenerationStep::UndergroundStructures,
|
||||||
};
|
};
|
||||||
pub const VILLAGE_DESERT: Structure = Structure {
|
pub const VILLAGE_DESERT: Self = Structure {
|
||||||
biomes: "#minecraft:has_structure/village_desert",
|
biomes: "#minecraft:has_structure/village_desert",
|
||||||
step: GenerationStep::SurfaceStructures,
|
step: GenerationStep::SurfaceStructures,
|
||||||
};
|
};
|
||||||
pub const VILLAGE_PLAINS: Structure = Structure {
|
pub const VILLAGE_PLAINS: Self = Structure {
|
||||||
biomes: "#minecraft:has_structure/village_plains",
|
biomes: "#minecraft:has_structure/village_plains",
|
||||||
step: GenerationStep::SurfaceStructures,
|
step: GenerationStep::SurfaceStructures,
|
||||||
};
|
};
|
||||||
pub const VILLAGE_SAVANNA: Structure = Structure {
|
pub const VILLAGE_SAVANNA: Self = Structure {
|
||||||
biomes: "#minecraft:has_structure/village_savanna",
|
biomes: "#minecraft:has_structure/village_savanna",
|
||||||
step: GenerationStep::SurfaceStructures,
|
step: GenerationStep::SurfaceStructures,
|
||||||
};
|
};
|
||||||
pub const VILLAGE_SNOWY: Structure = Structure {
|
pub const VILLAGE_SNOWY: Self = Structure {
|
||||||
biomes: "#minecraft:has_structure/village_snowy",
|
biomes: "#minecraft:has_structure/village_snowy",
|
||||||
step: GenerationStep::SurfaceStructures,
|
step: GenerationStep::SurfaceStructures,
|
||||||
};
|
};
|
||||||
pub const VILLAGE_TAIGA: Structure = Structure {
|
pub const VILLAGE_TAIGA: Self = Structure {
|
||||||
biomes: "#minecraft:has_structure/village_taiga",
|
biomes: "#minecraft:has_structure/village_taiga",
|
||||||
step: GenerationStep::SurfaceStructures,
|
step: GenerationStep::SurfaceStructures,
|
||||||
};
|
};
|
||||||
@ -305,7 +305,7 @@ impl Structure {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl StructureSet {
|
impl StructureSet {
|
||||||
pub const ANCIENT_CITIES: StructureSet = StructureSet {
|
pub const ANCIENT_CITIES: Self = StructureSet {
|
||||||
placement: StructurePlacement {
|
placement: StructurePlacement {
|
||||||
frequency_reduction_method: None,
|
frequency_reduction_method: None,
|
||||||
frequency: None,
|
frequency: None,
|
||||||
@ -321,7 +321,7 @@ impl StructureSet {
|
|||||||
weight: 1u32,
|
weight: 1u32,
|
||||||
}],
|
}],
|
||||||
};
|
};
|
||||||
pub const BURIED_TREASURES: StructureSet = StructureSet {
|
pub const BURIED_TREASURES: Self = StructureSet {
|
||||||
placement: StructurePlacement {
|
placement: StructurePlacement {
|
||||||
frequency_reduction_method: Some(FrequencyReductionMethod::LegacyType2),
|
frequency_reduction_method: Some(FrequencyReductionMethod::LegacyType2),
|
||||||
frequency: Some(0.01f32),
|
frequency: Some(0.01f32),
|
||||||
@ -337,7 +337,7 @@ impl StructureSet {
|
|||||||
weight: 1u32,
|
weight: 1u32,
|
||||||
}],
|
}],
|
||||||
};
|
};
|
||||||
pub const DESERT_PYRAMIDS: StructureSet = StructureSet {
|
pub const DESERT_PYRAMIDS: Self = StructureSet {
|
||||||
placement: StructurePlacement {
|
placement: StructurePlacement {
|
||||||
frequency_reduction_method: None,
|
frequency_reduction_method: None,
|
||||||
frequency: None,
|
frequency: None,
|
||||||
@ -353,7 +353,7 @@ impl StructureSet {
|
|||||||
weight: 1u32,
|
weight: 1u32,
|
||||||
}],
|
}],
|
||||||
};
|
};
|
||||||
pub const END_CITIES: StructureSet = StructureSet {
|
pub const END_CITIES: Self = StructureSet {
|
||||||
placement: StructurePlacement {
|
placement: StructurePlacement {
|
||||||
frequency_reduction_method: None,
|
frequency_reduction_method: None,
|
||||||
frequency: None,
|
frequency: None,
|
||||||
@ -369,7 +369,7 @@ impl StructureSet {
|
|||||||
weight: 1u32,
|
weight: 1u32,
|
||||||
}],
|
}],
|
||||||
};
|
};
|
||||||
pub const IGLOOS: StructureSet = StructureSet {
|
pub const IGLOOS: Self = StructureSet {
|
||||||
placement: StructurePlacement {
|
placement: StructurePlacement {
|
||||||
frequency_reduction_method: None,
|
frequency_reduction_method: None,
|
||||||
frequency: None,
|
frequency: None,
|
||||||
@ -385,7 +385,7 @@ impl StructureSet {
|
|||||||
weight: 1u32,
|
weight: 1u32,
|
||||||
}],
|
}],
|
||||||
};
|
};
|
||||||
pub const JUNGLE_TEMPLES: StructureSet = StructureSet {
|
pub const JUNGLE_TEMPLES: Self = StructureSet {
|
||||||
placement: StructurePlacement {
|
placement: StructurePlacement {
|
||||||
frequency_reduction_method: None,
|
frequency_reduction_method: None,
|
||||||
frequency: None,
|
frequency: None,
|
||||||
@ -401,7 +401,7 @@ impl StructureSet {
|
|||||||
weight: 1u32,
|
weight: 1u32,
|
||||||
}],
|
}],
|
||||||
};
|
};
|
||||||
pub const MINESHAFTS: StructureSet = StructureSet {
|
pub const MINESHAFTS: Self = StructureSet {
|
||||||
placement: StructurePlacement {
|
placement: StructurePlacement {
|
||||||
frequency_reduction_method: Some(FrequencyReductionMethod::LegacyType3),
|
frequency_reduction_method: Some(FrequencyReductionMethod::LegacyType3),
|
||||||
frequency: Some(0.004f32),
|
frequency: Some(0.004f32),
|
||||||
@ -423,7 +423,7 @@ impl StructureSet {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
pub const NETHER_COMPLEXES: StructureSet = StructureSet {
|
pub const NETHER_COMPLEXES: Self = StructureSet {
|
||||||
placement: StructurePlacement {
|
placement: StructurePlacement {
|
||||||
frequency_reduction_method: None,
|
frequency_reduction_method: None,
|
||||||
frequency: None,
|
frequency: None,
|
||||||
@ -445,7 +445,7 @@ impl StructureSet {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
pub const NETHER_FOSSILS: StructureSet = StructureSet {
|
pub const NETHER_FOSSILS: Self = StructureSet {
|
||||||
placement: StructurePlacement {
|
placement: StructurePlacement {
|
||||||
frequency_reduction_method: None,
|
frequency_reduction_method: None,
|
||||||
frequency: None,
|
frequency: None,
|
||||||
@ -461,7 +461,7 @@ impl StructureSet {
|
|||||||
weight: 1u32,
|
weight: 1u32,
|
||||||
}],
|
}],
|
||||||
};
|
};
|
||||||
pub const OCEAN_MONUMENTS: StructureSet = StructureSet {
|
pub const OCEAN_MONUMENTS: Self = StructureSet {
|
||||||
placement: StructurePlacement {
|
placement: StructurePlacement {
|
||||||
frequency_reduction_method: None,
|
frequency_reduction_method: None,
|
||||||
frequency: None,
|
frequency: None,
|
||||||
@ -477,7 +477,7 @@ impl StructureSet {
|
|||||||
weight: 1u32,
|
weight: 1u32,
|
||||||
}],
|
}],
|
||||||
};
|
};
|
||||||
pub const OCEAN_RUINS: StructureSet = StructureSet {
|
pub const OCEAN_RUINS: Self = StructureSet {
|
||||||
placement: StructurePlacement {
|
placement: StructurePlacement {
|
||||||
frequency_reduction_method: None,
|
frequency_reduction_method: None,
|
||||||
frequency: None,
|
frequency: None,
|
||||||
@ -499,7 +499,7 @@ impl StructureSet {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
pub const PILLAGER_OUTPOSTS: StructureSet = StructureSet {
|
pub const PILLAGER_OUTPOSTS: Self = StructureSet {
|
||||||
placement: StructurePlacement {
|
placement: StructurePlacement {
|
||||||
frequency_reduction_method: Some(FrequencyReductionMethod::LegacyType1),
|
frequency_reduction_method: Some(FrequencyReductionMethod::LegacyType1),
|
||||||
frequency: Some(0.2f32),
|
frequency: Some(0.2f32),
|
||||||
@ -515,7 +515,7 @@ impl StructureSet {
|
|||||||
weight: 1u32,
|
weight: 1u32,
|
||||||
}],
|
}],
|
||||||
};
|
};
|
||||||
pub const RUINED_PORTALS: StructureSet = StructureSet {
|
pub const RUINED_PORTALS: Self = StructureSet {
|
||||||
placement: StructurePlacement {
|
placement: StructurePlacement {
|
||||||
frequency_reduction_method: None,
|
frequency_reduction_method: None,
|
||||||
frequency: None,
|
frequency: None,
|
||||||
@ -557,7 +557,7 @@ impl StructureSet {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
pub const SHIPWRECKS: StructureSet = StructureSet {
|
pub const SHIPWRECKS: Self = StructureSet {
|
||||||
placement: StructurePlacement {
|
placement: StructurePlacement {
|
||||||
frequency_reduction_method: None,
|
frequency_reduction_method: None,
|
||||||
frequency: None,
|
frequency: None,
|
||||||
@ -579,7 +579,7 @@ impl StructureSet {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
pub const STRONGHOLDS: StructureSet = StructureSet {
|
pub const STRONGHOLDS: Self = StructureSet {
|
||||||
placement: StructurePlacement {
|
placement: StructurePlacement {
|
||||||
frequency_reduction_method: None,
|
frequency_reduction_method: None,
|
||||||
frequency: None,
|
frequency: None,
|
||||||
@ -598,7 +598,7 @@ impl StructureSet {
|
|||||||
weight: 1u32,
|
weight: 1u32,
|
||||||
}],
|
}],
|
||||||
};
|
};
|
||||||
pub const SWAMP_HUTS: StructureSet = StructureSet {
|
pub const SWAMP_HUTS: Self = StructureSet {
|
||||||
placement: StructurePlacement {
|
placement: StructurePlacement {
|
||||||
frequency_reduction_method: None,
|
frequency_reduction_method: None,
|
||||||
frequency: None,
|
frequency: None,
|
||||||
@ -614,7 +614,7 @@ impl StructureSet {
|
|||||||
weight: 1u32,
|
weight: 1u32,
|
||||||
}],
|
}],
|
||||||
};
|
};
|
||||||
pub const TRAIL_RUINS: StructureSet = StructureSet {
|
pub const TRAIL_RUINS: Self = StructureSet {
|
||||||
placement: StructurePlacement {
|
placement: StructurePlacement {
|
||||||
frequency_reduction_method: None,
|
frequency_reduction_method: None,
|
||||||
frequency: None,
|
frequency: None,
|
||||||
@ -630,7 +630,7 @@ impl StructureSet {
|
|||||||
weight: 1u32,
|
weight: 1u32,
|
||||||
}],
|
}],
|
||||||
};
|
};
|
||||||
pub const TRIAL_CHAMBERS: StructureSet = StructureSet {
|
pub const TRIAL_CHAMBERS: Self = StructureSet {
|
||||||
placement: StructurePlacement {
|
placement: StructurePlacement {
|
||||||
frequency_reduction_method: None,
|
frequency_reduction_method: None,
|
||||||
frequency: None,
|
frequency: None,
|
||||||
@ -646,7 +646,7 @@ impl StructureSet {
|
|||||||
weight: 1u32,
|
weight: 1u32,
|
||||||
}],
|
}],
|
||||||
};
|
};
|
||||||
pub const VILLAGES: StructureSet = StructureSet {
|
pub const VILLAGES: Self = StructureSet {
|
||||||
placement: StructurePlacement {
|
placement: StructurePlacement {
|
||||||
frequency_reduction_method: None,
|
frequency_reduction_method: None,
|
||||||
frequency: None,
|
frequency: None,
|
||||||
@ -680,7 +680,7 @@ impl StructureSet {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
pub const WOODLAND_MANSIONS: StructureSet = StructureSet {
|
pub const WOODLAND_MANSIONS: Self = StructureSet {
|
||||||
placement: StructurePlacement {
|
placement: StructurePlacement {
|
||||||
frequency_reduction_method: None,
|
frequency_reduction_method: None,
|
||||||
frequency: None,
|
frequency: None,
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -1,4 +1,5 @@
|
|||||||
/* This file is generated. Do not edit manually. */
|
/* This file is generated. Do not edit manually. */
|
||||||
|
#![allow(clippy::doc_markdown)]
|
||||||
pub mod java {
|
pub mod java {
|
||||||
#[doc = "Accessibility Settings..."]
|
#[doc = "Accessibility Settings..."]
|
||||||
pub const ACCESSIBILITY_ONBOARDING_ACCESSIBILITY_BUTTON: &str =
|
pub const ACCESSIBILITY_ONBOARDING_ACCESSIBILITY_BUTTON: &str =
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/* This file is generated. Do not edit manually. */
|
/* This file is generated. Do not edit manually. */
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
#[derive(Clone, Copy, PartialEq)]
|
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||||
pub struct VillagerTradeItem {
|
pub struct VillagerTradeItem {
|
||||||
pub item: &'static crate::item::Item,
|
pub item: &'static crate::item::Item,
|
||||||
pub count: i32,
|
pub count: i32,
|
||||||
@ -4244,7 +4244,7 @@ pub enum VillagerProfession {
|
|||||||
}
|
}
|
||||||
impl VillagerProfession {
|
impl VillagerProfession {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn from_i32(id: i32) -> Option<Self> {
|
pub const fn from_i32(id: i32) -> Option<Self> {
|
||||||
match id {
|
match id {
|
||||||
0i32 => Some(Self::None),
|
0i32 => Some(Self::None),
|
||||||
1i32 => Some(Self::Armorer),
|
1i32 => Some(Self::Armorer),
|
||||||
@ -4265,7 +4265,8 @@ impl VillagerProfession {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn work_sound(&self) -> Option<crate::sound::Sound> {
|
#[allow(clippy::match_same_arms)]
|
||||||
|
pub const fn work_sound(&self) -> Option<crate::sound::Sound> {
|
||||||
match self {
|
match self {
|
||||||
Self::None => None,
|
Self::None => None,
|
||||||
Self::Armorer => Some(crate::sound::Sound::EntityVillagerWorkArmorer),
|
Self::Armorer => Some(crate::sound::Sound::EntityVillagerWorkArmorer),
|
||||||
@ -4285,7 +4286,8 @@ impl VillagerProfession {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn requested_items(&self) -> &'static [&'static crate::item::Item] {
|
#[allow(clippy::match_same_arms)]
|
||||||
|
pub const fn requested_items(&self) -> &'static [&'static crate::item::Item] {
|
||||||
match self {
|
match self {
|
||||||
Self::None => &[],
|
Self::None => &[],
|
||||||
Self::Armorer => &[],
|
Self::Armorer => &[],
|
||||||
@ -4310,7 +4312,7 @@ impl VillagerProfession {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn translation_key(&self) -> &'static str {
|
pub const fn translation_key(&self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
Self::None => "entity.minecraft.villager.none",
|
Self::None => "entity.minecraft.villager.none",
|
||||||
Self::Armorer => "entity.minecraft.villager.armorer",
|
Self::Armorer => "entity.minecraft.villager.armorer",
|
||||||
@ -4330,7 +4332,8 @@ impl VillagerProfession {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn trade_set(&self, level: i32) -> Option<VillagerTradeSet> {
|
#[allow(clippy::too_many_lines, clippy::match_same_arms)]
|
||||||
|
pub const fn trade_set(&self, level: i32) -> Option<VillagerTradeSet> {
|
||||||
match self {
|
match self {
|
||||||
Self::None => None,
|
Self::None => None,
|
||||||
Self::Armorer => match level {
|
Self::Armorer => match level {
|
||||||
@ -4655,7 +4658,7 @@ pub enum VillagerType {
|
|||||||
}
|
}
|
||||||
impl VillagerType {
|
impl VillagerType {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn from_i32(id: i32) -> Option<Self> {
|
pub const fn from_i32(id: i32) -> Option<Self> {
|
||||||
match id {
|
match id {
|
||||||
0i32 => Some(Self::Desert),
|
0i32 => Some(Self::Desert),
|
||||||
1i32 => Some(Self::Jungle),
|
1i32 => Some(Self::Jungle),
|
||||||
|
|||||||
@ -93,6 +93,7 @@ impl ItemStack {
|
|||||||
}
|
}
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
#[must_use]
|
||||||
pub fn get_data_component_mut<T: DataComponentImpl + 'static>(&mut self) -> Option<&mut T> {
|
pub fn get_data_component_mut<T: DataComponentImpl + 'static>(&mut self) -> Option<&mut T> {
|
||||||
let to_get_id = T::get_enum();
|
let to_get_id = T::get_enum();
|
||||||
if let Some(index) = self.patch.iter().position(|(id, _)| *id == to_get_id) {
|
if let Some(index) = self.patch.iter().position(|(id, _)| *id == to_get_id) {
|
||||||
@ -148,6 +149,7 @@ impl ItemStack {
|
|||||||
patch: Vec::new(),
|
patch: Vec::new(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn split_off(&mut self, amount: u8) -> Self {
|
pub fn split_off(&mut self, amount: u8) -> Self {
|
||||||
let count = amount.min(self.item_count);
|
let count = amount.min(self.item_count);
|
||||||
let result = self.copy_with_count(count);
|
let result = self.copy_with_count(count);
|
||||||
@ -235,7 +237,7 @@ impl ItemStack {
|
|||||||
/// Core logic: apply Unbreaking chance with precomputed armor category and level.
|
/// Core logic: apply Unbreaking chance with precomputed armor category and level.
|
||||||
/// Extracted for use in damage_item where these values are hoisted outside the loop.
|
/// Extracted for use in damage_item where these values are hoisted outside the loop.
|
||||||
/// Private to prevent incorrect usage; only call through damage_item.
|
/// Private to prevent incorrect usage; only call through damage_item.
|
||||||
fn should_apply_durability_damage_with(&self, is_armor: bool, unbreaking_level: i32) -> bool {
|
fn should_apply_durability_damage_with(is_armor: bool, unbreaking_level: i32) -> bool {
|
||||||
if unbreaking_level <= 0 {
|
if unbreaking_level <= 0 {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -251,8 +253,8 @@ impl ItemStack {
|
|||||||
|
|
||||||
/// Apply durability damage to this item and return the outcome.
|
/// Apply durability damage to this item and return the outcome.
|
||||||
/// Callers must check the return value to handle break broadcasts and item stack updates.
|
/// Callers must check the return value to handle break broadcasts and item stack updates.
|
||||||
/// TODO: Restore #[must_use] once all callsites (esp. tool/mob block-hit/damage sites)
|
/// TODO: Restore `#[must_use]` once all callsites (esp. tool/mob block-hit/damage sites)
|
||||||
/// implement proper DamageResult::Broken handling instead of suppressing with let _ =.
|
/// implement proper `DamageResult::Broken` handling instead of suppressing with `let _ =`.
|
||||||
/// Without this enforcement, the fix is incomplete vs vanilla break behavior.
|
/// Without this enforcement, the fix is incomplete vs vanilla break behavior.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn damage_item(&mut self, amount: i32) -> DamageResult {
|
pub fn damage_item(&mut self, amount: i32) -> DamageResult {
|
||||||
@ -272,7 +274,7 @@ impl ItemStack {
|
|||||||
// TODO: Short-circuit once applied >= (max_damage - current_damage) to avoid
|
// TODO: Short-circuit once applied >= (max_damage - current_damage) to avoid
|
||||||
// iterating the full amount for high-damage hits on high-durability items.
|
// iterating the full amount for high-damage hits on high-durability items.
|
||||||
for _ in 0..amount {
|
for _ in 0..amount {
|
||||||
if self.should_apply_durability_damage_with(is_armor, unbreaking_level) {
|
if Self::should_apply_durability_damage_with(is_armor, unbreaking_level) {
|
||||||
applied += 1;
|
applied += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -92,6 +92,7 @@ pub mod meta_data_type;
|
|||||||
pub mod noise_parameter;
|
pub mod noise_parameter;
|
||||||
|
|
||||||
#[cfg(feature = "biome")]
|
#[cfg(feature = "biome")]
|
||||||
|
#[expect(clippy::unreachable)]
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
#[path = "generated/biome.rs"]
|
#[path = "generated/biome.rs"]
|
||||||
pub mod biome;
|
pub mod biome;
|
||||||
@ -208,6 +209,7 @@ pub mod damage;
|
|||||||
pub mod fluid;
|
pub mod fluid;
|
||||||
|
|
||||||
#[cfg(feature = "block")]
|
#[cfg(feature = "block")]
|
||||||
|
#[expect(clippy::unreachable)]
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
#[path = "generated/block.rs"]
|
#[path = "generated/block.rs"]
|
||||||
pub mod block_properties;
|
pub mod block_properties;
|
||||||
|
|||||||
@ -484,7 +484,9 @@ pub fn derive_serialize(input: TokenStream) -> TokenStream {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
unimplemented!()
|
return syn::Error::new(name.span(), "Only structs are supported")
|
||||||
|
.to_compile_error()
|
||||||
|
.into();
|
||||||
};
|
};
|
||||||
|
|
||||||
let expanded = quote! {
|
let expanded = quote! {
|
||||||
@ -539,7 +541,9 @@ pub fn derive_deserialize(input: TokenStream) -> TokenStream {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
unimplemented!()
|
return syn::Error::new(name.span(), "Only structs are supported")
|
||||||
|
.to_compile_error()
|
||||||
|
.into();
|
||||||
};
|
};
|
||||||
|
|
||||||
let expanded = quote! {
|
let expanded = quote! {
|
||||||
|
|||||||
@ -321,7 +321,7 @@ impl<'de, R: NbtReadHelper> de::Deserializer<'de> for &mut Deserializer<R> {
|
|||||||
INT_ARRAY_ID => INT_ID,
|
INT_ARRAY_ID => INT_ID,
|
||||||
LONG_ARRAY_ID => LONG_ID,
|
LONG_ARRAY_ID => LONG_ID,
|
||||||
BYTE_ARRAY_ID => BYTE_ID,
|
BYTE_ARRAY_ID => BYTE_ID,
|
||||||
_ => unreachable!(),
|
_ => return Err(Error::SerdeError("Unreachable state reached".to_string())),
|
||||||
};
|
};
|
||||||
|
|
||||||
let remaining_values = self.input.get_i32()?;
|
let remaining_values = self.input.get_i32()?;
|
||||||
@ -354,7 +354,7 @@ impl<'de, R: NbtReadHelper> de::Deserializer<'de> for &mut Deserializer<R> {
|
|||||||
NbtTag::Float(value) => visitor.visit_f32::<Error>(value)?,
|
NbtTag::Float(value) => visitor.visit_f32::<Error>(value)?,
|
||||||
NbtTag::Double(value) => visitor.visit_f64::<Error>(value)?,
|
NbtTag::Double(value) => visitor.visit_f64::<Error>(value)?,
|
||||||
NbtTag::String(value) => visitor.visit_string::<Error>(value.into())?,
|
NbtTag::String(value) => visitor.visit_string::<Error>(value.into())?,
|
||||||
_ => unreachable!(),
|
_ => return Err(Error::SerdeError("Unreachable state reached".to_string())),
|
||||||
};
|
};
|
||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -467,7 +467,7 @@ impl ListCollector {
|
|||||||
NbtTag::IntArray(list) => list.len(),
|
NbtTag::IntArray(list) => list.len(),
|
||||||
NbtTag::LongArray(list) => list.len(),
|
NbtTag::LongArray(list) => list.len(),
|
||||||
|
|
||||||
_ => unreachable!(),
|
_ => return None,
|
||||||
};
|
};
|
||||||
|
|
||||||
if len == 0 {
|
if len == 0 {
|
||||||
@ -481,7 +481,7 @@ impl ListCollector {
|
|||||||
NbtTag::IntArray(list) => Some(Self::Int(InnerIntListCollector::new(list))),
|
NbtTag::IntArray(list) => Some(Self::Int(InnerIntListCollector::new(list))),
|
||||||
NbtTag::LongArray(list) => Some(Self::Long(InnerLongListCollector::new(list))),
|
NbtTag::LongArray(list) => Some(Self::Long(InnerLongListCollector::new(list))),
|
||||||
|
|
||||||
_ => unreachable!(),
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -546,9 +546,8 @@ impl InnerListCollector for InnerGenericListCollector {
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
{
|
{
|
||||||
match &mut self.result {
|
if let NbtTag::List(list) = &mut self.result {
|
||||||
NbtTag::List(list) => list.push(tag),
|
list.push(tag);
|
||||||
_ => unreachable!(),
|
|
||||||
}
|
}
|
||||||
ListCollector::Generic(self)
|
ListCollector::Generic(self)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,7 +42,7 @@ impl Command {
|
|||||||
///
|
///
|
||||||
/// Registers `handler` so that it is called whenever this command is invoked.
|
/// Registers `handler` so that it is called whenever this command is invoked.
|
||||||
/// Returns `self` to allow builder-style chaining.
|
/// Returns `self` to allow builder-style chaining.
|
||||||
pub fn execute<H: CommandHandler + Send + Sync + 'static>(self, handler: H) -> Command {
|
pub fn execute<H: CommandHandler + Send + Sync + 'static>(self, handler: H) -> Self {
|
||||||
let id = NEXT_COMMAND_ID.fetch_add(1, Ordering::Relaxed);
|
let id = NEXT_COMMAND_ID.fetch_add(1, Ordering::Relaxed);
|
||||||
|
|
||||||
COMMAND_HANDLERS
|
COMMAND_HANDLERS
|
||||||
@ -62,7 +62,7 @@ impl CommandNode {
|
|||||||
/// Registers `handler` so that it is called when this specific node (subcommand
|
/// Registers `handler` so that it is called when this specific node (subcommand
|
||||||
/// or argument branch) is the final node matched during command dispatch.
|
/// or argument branch) is the final node matched during command dispatch.
|
||||||
/// Returns `self` to allow builder-style chaining.
|
/// Returns `self` to allow builder-style chaining.
|
||||||
pub fn execute<H: CommandHandler + Send + Sync + 'static>(self, handler: H) -> CommandNode {
|
pub fn execute<H: CommandHandler + Send + Sync + 'static>(self, handler: H) -> Self {
|
||||||
let id = NEXT_COMMAND_ID.fetch_add(1, Ordering::Relaxed);
|
let id = NEXT_COMMAND_ID.fetch_add(1, Ordering::Relaxed);
|
||||||
|
|
||||||
COMMAND_HANDLERS
|
COMMAND_HANDLERS
|
||||||
|
|||||||
@ -181,6 +181,7 @@ pub enum FormResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl FormResponse {
|
impl FormResponse {
|
||||||
|
#[must_use]
|
||||||
pub fn parse(data: Option<String>) -> Self {
|
pub fn parse(data: Option<String>) -> Self {
|
||||||
match data {
|
match data {
|
||||||
None => Self::Closed,
|
None => Self::Closed,
|
||||||
|
|||||||
@ -136,13 +136,14 @@ impl wit::Guest for Component {
|
|||||||
args: command::ConsumedArgs,
|
args: command::ConsumedArgs,
|
||||||
) -> Result<i32, command::CommandError> {
|
) -> Result<i32, command::CommandError> {
|
||||||
let handlers = COMMAND_HANDLERS.lock().unwrap();
|
let handlers = COMMAND_HANDLERS.lock().unwrap();
|
||||||
if let Some(handler) = handlers.get(&command_id) {
|
handlers.get(&command_id).map_or_else(
|
||||||
handler.handle(sender, server, args)
|
|| {
|
||||||
} else {
|
Err(command::CommandError::CommandFailed(TextComponent::text(
|
||||||
Err(command::CommandError::CommandFailed(TextComponent::text(
|
&format!("no handler registered for command id {command_id}"),
|
||||||
&format!("no handler registered for command id {command_id}"),
|
)))
|
||||||
)))
|
},
|
||||||
}
|
|handler| handler.handle(sender, server, args),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// WIT entry point — dispatches a scheduled task invocation to the registered handler for `handler_id`.
|
/// WIT entry point — dispatches a scheduled task invocation to the registered handler for `handler_id`.
|
||||||
|
|||||||
@ -13,7 +13,7 @@ pub(crate) struct WitSubscriber {
|
|||||||
|
|
||||||
impl WitSubscriber {
|
impl WitSubscriber {
|
||||||
/// Creates a new `WitSubscriber` with the span ID counter starting at `1`.
|
/// Creates a new `WitSubscriber` with the span ID counter starting at `1`.
|
||||||
pub fn new() -> Self {
|
pub const fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
next_id: AtomicU64::new(1),
|
next_id: AtomicU64::new(1),
|
||||||
}
|
}
|
||||||
@ -69,13 +69,13 @@ pub enum LogLevel {
|
|||||||
|
|
||||||
impl LogLevel {
|
impl LogLevel {
|
||||||
/// Converts this level to the WIT-generated `Level` type expected by the host.
|
/// Converts this level to the WIT-generated `Level` type expected by the host.
|
||||||
fn to_wit(self) -> wit::pumpkin::plugin::logging::Level {
|
const fn to_wit(self) -> wit::pumpkin::plugin::logging::Level {
|
||||||
match self {
|
match self {
|
||||||
LogLevel::Trace => wit::pumpkin::plugin::logging::Level::Trace,
|
Self::Trace => wit::pumpkin::plugin::logging::Level::Trace,
|
||||||
LogLevel::Debug => wit::pumpkin::plugin::logging::Level::Debug,
|
Self::Debug => wit::pumpkin::plugin::logging::Level::Debug,
|
||||||
LogLevel::Info => wit::pumpkin::plugin::logging::Level::Info,
|
Self::Info => wit::pumpkin::plugin::logging::Level::Info,
|
||||||
LogLevel::Warn => wit::pumpkin::plugin::logging::Level::Warn,
|
Self::Warn => wit::pumpkin::plugin::logging::Level::Warn,
|
||||||
LogLevel::Error => wit::pumpkin::plugin::logging::Level::Error,
|
Self::Error => wit::pumpkin::plugin::logging::Level::Error,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -95,14 +95,14 @@ impl SchedulerExt for crate::Context {
|
|||||||
impl SchedulerExt for crate::Server {
|
impl SchedulerExt for crate::Server {
|
||||||
fn schedule_delayed_task<F>(&self, delay_ticks: u64, handler: F) -> u32
|
fn schedule_delayed_task<F>(&self, delay_ticks: u64, handler: F) -> u32
|
||||||
where
|
where
|
||||||
F: FnMut(Server) + Send + 'static,
|
F: FnMut(Self) + Send + 'static,
|
||||||
{
|
{
|
||||||
schedule_delayed_task(delay_ticks, handler)
|
schedule_delayed_task(delay_ticks, handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn schedule_repeating_task<F>(&self, delay_ticks: u64, period_ticks: u64, handler: F) -> u32
|
fn schedule_repeating_task<F>(&self, delay_ticks: u64, period_ticks: u64, handler: F) -> u32
|
||||||
where
|
where
|
||||||
F: FnMut(Server) + Send + 'static,
|
F: FnMut(Self) + Send + 'static,
|
||||||
{
|
{
|
||||||
schedule_repeating_task(delay_ticks, period_ticks, handler)
|
schedule_repeating_task(delay_ticks, period_ticks, handler)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -120,7 +120,7 @@ impl MetadataValue {
|
|||||||
Self::Int(v) => VarInt(*v).write(writer),
|
Self::Int(v) => VarInt(*v).write(writer),
|
||||||
Self::Float(v) => writer.write_all(&v.to_le_bytes()),
|
Self::Float(v) => writer.write_all(&v.to_le_bytes()),
|
||||||
Self::String(v) => v.write(writer),
|
Self::String(v) => v.write(writer),
|
||||||
Self::CompoundTag => todo!(),
|
Self::CompoundTag => Err(Error::other("CompoundTag not implemented")),
|
||||||
Self::BlockPos(v) => v.write(writer),
|
Self::BlockPos(v) => v.write(writer),
|
||||||
Self::Long(v) => VarLong(*v).write(writer),
|
Self::Long(v) => VarLong(*v).write(writer),
|
||||||
Self::Vec3(v) => {
|
Self::Vec3(v) => {
|
||||||
|
|||||||
@ -71,10 +71,8 @@ impl Frame {
|
|||||||
let mut header_buf = [0u8; 1];
|
let mut header_buf = [0u8; 1];
|
||||||
|
|
||||||
while match reader.read(&mut header_buf) {
|
while match reader.read(&mut header_buf) {
|
||||||
Ok(0) => false,
|
Ok(n) => n > 0,
|
||||||
Ok(1) => true,
|
|
||||||
Err(e) => return Err(e),
|
Err(e) => return Err(e),
|
||||||
_ => unreachable!(),
|
|
||||||
} {
|
} {
|
||||||
let header = header_buf[0];
|
let header = header_buf[0];
|
||||||
let mut frame = Self::default();
|
let mut frame = Self::default();
|
||||||
|
|||||||
@ -37,6 +37,8 @@ impl BitSet {
|
|||||||
|
|
||||||
impl Serialize for BitSet {
|
impl Serialize for BitSet {
|
||||||
fn serialize<S: Serializer>(&self, _serializer: S) -> Result<S::Ok, S::Error> {
|
fn serialize<S: Serializer>(&self, _serializer: S) -> Result<S::Ok, S::Error> {
|
||||||
todo!()
|
Err(serde::ser::Error::custom(
|
||||||
|
"BitSet serialization not implemented",
|
||||||
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -868,7 +868,10 @@ pub fn serialize<T: SerializeStruct>(
|
|||||||
DataComponent::StoredEnchantments => get::<StoredEnchantmentsImpl>(value).serialize(seq),
|
DataComponent::StoredEnchantments => get::<StoredEnchantmentsImpl>(value).serialize(seq),
|
||||||
DataComponent::UseCooldown => get::<UseCooldownImpl>(value).serialize(seq),
|
DataComponent::UseCooldown => get::<UseCooldownImpl>(value).serialize(seq),
|
||||||
DataComponent::MapId => get::<MapIdImpl>(value).serialize(seq),
|
DataComponent::MapId => get::<MapIdImpl>(value).serialize(seq),
|
||||||
_ => todo!("{} not yet implemented", id.to_name()),
|
_ => Err(serde::ser::Error::custom(format!(
|
||||||
|
"{} not yet implemented",
|
||||||
|
id.to_name()
|
||||||
|
))),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -166,9 +166,9 @@ impl ProtoNode<'_> {
|
|||||||
})?;
|
})?;
|
||||||
write.write_string(suggestion_type.resource_location())?;
|
write.write_string(suggestion_type.resource_location())?;
|
||||||
}
|
}
|
||||||
_ => unimplemented!(
|
_ => return Err(WritingError::Message(
|
||||||
"`ProtoNode::FLAG_HAS_SUGGESTION_TYPE` is only implemented for `ProtoNodeType::Argument`"
|
"`ProtoNode::FLAG_HAS_SUGGESTION_TYPE` is only implemented for `ProtoNodeType::Argument`".into()
|
||||||
),
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -115,7 +115,9 @@ impl<'de, T: Deserialize<'de>> Visitor<'de> for IdOrVisitor<T> {
|
|||||||
let value = T::deserialize(deserializer)?;
|
let value = T::deserialize(deserializer)?;
|
||||||
*self = IdOrStateDeserializer::Value(value);
|
*self = IdOrStateDeserializer::Value(value);
|
||||||
}
|
}
|
||||||
IdOrStateDeserializer::Value(_) => unreachable!(),
|
IdOrStateDeserializer::Value(_) => {
|
||||||
|
return Err(serde::de::Error::custom("Unreachable state reached"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -132,14 +134,14 @@ impl<'de, T: Deserialize<'de>> Visitor<'de> for IdOrVisitor<T> {
|
|||||||
return Ok(IdOr::Id(id - 1));
|
return Ok(IdOr::Id(id - 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => unreachable!(),
|
_ => return Err(serde::de::Error::custom("Unreachable state reached")),
|
||||||
}
|
}
|
||||||
|
|
||||||
let _ = seq.next_element_seed(&mut state)?;
|
let _ = seq.next_element_seed(&mut state)?;
|
||||||
|
|
||||||
match state {
|
match state {
|
||||||
IdOrStateDeserializer::Value(val) => Ok(IdOr::Value(val)),
|
IdOrStateDeserializer::Value(val) => Ok(IdOr::Value(val)),
|
||||||
_ => unreachable!(),
|
_ => Err(serde::de::Error::custom("Unreachable state reached")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,9 +26,10 @@ impl<'de, R: Read> de::Deserializer<'de> for &mut Deserializer<R> {
|
|||||||
type Error = ReadingError;
|
type Error = ReadingError;
|
||||||
|
|
||||||
fn deserialize_any<V: Visitor<'de>>(self, _visitor: V) -> Result<V::Value, Self::Error> {
|
fn deserialize_any<V: Visitor<'de>>(self, _visitor: V) -> Result<V::Value, Self::Error> {
|
||||||
unimplemented!(
|
Err(ReadingError::Message(
|
||||||
"This is impossible to do, since you cannot infer the data structure from the packet"
|
"This is impossible to do, since you cannot infer the data structure from the packet"
|
||||||
)
|
.into(),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn deserialize_bool<V: Visitor<'de>>(self, visitor: V) -> Result<V::Value, Self::Error> {
|
fn deserialize_bool<V: Visitor<'de>>(self, visitor: V) -> Result<V::Value, Self::Error> {
|
||||||
@ -104,11 +105,15 @@ impl<'de, R: Read> de::Deserializer<'de> for &mut Deserializer<R> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn deserialize_bytes<V: Visitor<'de>>(self, _visitor: V) -> Result<V::Value, Self::Error> {
|
fn deserialize_bytes<V: Visitor<'de>>(self, _visitor: V) -> Result<V::Value, Self::Error> {
|
||||||
unimplemented!()
|
Err(ReadingError::Message(
|
||||||
|
"deserialize_bytes not implemented".into(),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn deserialize_byte_buf<V: Visitor<'de>>(self, _visitor: V) -> Result<V::Value, Self::Error> {
|
fn deserialize_byte_buf<V: Visitor<'de>>(self, _visitor: V) -> Result<V::Value, Self::Error> {
|
||||||
unimplemented!()
|
Err(ReadingError::Message(
|
||||||
|
"deserialize_byte_buf not implemented".into(),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn deserialize_option<V: Visitor<'de>>(self, visitor: V) -> Result<V::Value, Self::Error> {
|
fn deserialize_option<V: Visitor<'de>>(self, visitor: V) -> Result<V::Value, Self::Error> {
|
||||||
@ -136,7 +141,9 @@ impl<'de, R: Read> de::Deserializer<'de> for &mut Deserializer<R> {
|
|||||||
_name: &'static str,
|
_name: &'static str,
|
||||||
_visitor: V,
|
_visitor: V,
|
||||||
) -> Result<V::Value, Self::Error> {
|
) -> Result<V::Value, Self::Error> {
|
||||||
unimplemented!()
|
Err(ReadingError::Message(
|
||||||
|
"deserialize_newtype_struct not implemented".into(),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn deserialize_seq<V: Visitor<'de>>(self, visitor: V) -> Result<V::Value, Self::Error> {
|
fn deserialize_seq<V: Visitor<'de>>(self, visitor: V) -> Result<V::Value, Self::Error> {
|
||||||
@ -254,14 +261,18 @@ impl<'de, R: Read> de::Deserializer<'de> for &mut Deserializer<R> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn deserialize_identifier<V: Visitor<'de>>(self, _visitor: V) -> Result<V::Value, Self::Error> {
|
fn deserialize_identifier<V: Visitor<'de>>(self, _visitor: V) -> Result<V::Value, Self::Error> {
|
||||||
unimplemented!()
|
Err(ReadingError::Message(
|
||||||
|
"deserialize_identifier not implemented".into(),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn deserialize_ignored_any<V: Visitor<'de>>(
|
fn deserialize_ignored_any<V: Visitor<'de>>(
|
||||||
self,
|
self,
|
||||||
_visitor: V,
|
_visitor: V,
|
||||||
) -> Result<V::Value, Self::Error> {
|
) -> Result<V::Value, Self::Error> {
|
||||||
unimplemented!()
|
Err(ReadingError::Message(
|
||||||
|
"deserialize_ignored_any not implemented".into(),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,13 +6,13 @@ use std::io::{Error, Read, Write};
|
|||||||
pub trait PacketWrite {
|
pub trait PacketWrite {
|
||||||
fn write<W: Write>(&self, writer: &mut W) -> Result<(), Error>;
|
fn write<W: Write>(&self, writer: &mut W) -> Result<(), Error>;
|
||||||
fn write_be<W: Write>(&self, _writer: &mut W) -> Result<(), Error> {
|
fn write_be<W: Write>(&self, _writer: &mut W) -> Result<(), Error> {
|
||||||
todo!()
|
Err(Error::other("Not implemented"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait PacketRead: Sized {
|
pub trait PacketRead: Sized {
|
||||||
fn read<R: Read>(reader: &mut R) -> Result<Self, Error>;
|
fn read<R: Read>(reader: &mut R) -> Result<Self, Error>;
|
||||||
fn read_be<R: Read>(_reader: &mut R) -> Result<Self, Error> {
|
fn read_be<R: Read>(_reader: &mut R) -> Result<Self, Error> {
|
||||||
todo!()
|
Err(Error::other("Not implemented"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -283,13 +283,17 @@ impl From<&BlockBox> for IntStream {
|
|||||||
|
|
||||||
impl FlatTryFrom<IntStream> for BlockBox {
|
impl FlatTryFrom<IntStream> for BlockBox {
|
||||||
fn flat_try_from(value: IntStream) -> DataResult<Self> {
|
fn flat_try_from(value: IntStream) -> DataResult<Self> {
|
||||||
validate_fixed_size(value.0, 6).map(|v| {
|
validate_fixed_size(value.0, 6).flat_map(|v| {
|
||||||
let [min_x, min_y, min_z, max_x, max_y, max_z]: [i32; 6] =
|
v.try_into().map_or_else(
|
||||||
v.try_into().unwrap_or_else(|_| unreachable!());
|
|_| DataResult::new_error("Expected 6 elements"),
|
||||||
Self {
|
|arr| {
|
||||||
min: Vector3::new(min_x, min_y, min_z),
|
let [min_x, min_y, min_z, max_x, max_y, max_z]: [i32; 6] = arr;
|
||||||
max: Vector3::new(max_x, max_y, max_z),
|
DataResult::new_success(Self {
|
||||||
}
|
min: Vector3::new(min_x, min_y, min_z),
|
||||||
|
max: Vector3::new(max_x, max_y, max_z),
|
||||||
|
})
|
||||||
|
},
|
||||||
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -93,13 +93,18 @@ impl From<&EulerAngle> for Vec<f32> {
|
|||||||
|
|
||||||
impl FlatTryFrom<Vec<f32>> for EulerAngle {
|
impl FlatTryFrom<Vec<f32>> for EulerAngle {
|
||||||
fn flat_try_from(value: Vec<f32>) -> DataResult<Self> {
|
fn flat_try_from(value: Vec<f32>) -> DataResult<Self> {
|
||||||
validate_fixed_size(value, 6).map(|v| {
|
validate_fixed_size(value, 3).flat_map(|v| {
|
||||||
let [x, y, z]: [f32; 3] = v.try_into().unwrap_or_else(|_| unreachable!());
|
v.try_into().map_or_else(
|
||||||
Self {
|
|_| DataResult::new_error("Expected 3 elements"),
|
||||||
pitch: x,
|
|arr| {
|
||||||
yaw: y,
|
let [x, y, z]: [f32; 3] = arr;
|
||||||
roll: z,
|
DataResult::new_success(Self {
|
||||||
}
|
pitch: x,
|
||||||
|
yaw: y,
|
||||||
|
roll: z,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -416,11 +416,14 @@ macro_rules! vector_codec_impl {
|
|||||||
|
|
||||||
impl<T> FlatTryFrom<Vec<T>> for $vector {
|
impl<T> FlatTryFrom<Vec<T>> for $vector {
|
||||||
fn flat_try_from(value: Vec<T>) -> DataResult<Self> {
|
fn flat_try_from(value: Vec<T>) -> DataResult<Self> {
|
||||||
validate_fixed_size(value, 2)
|
validate_fixed_size(value, $number).flat_map(|v| {
|
||||||
.map(|v| {
|
if let Ok(arr) = v.try_into() {
|
||||||
let [ $( $components, )+ ]: [T; $number] = v.try_into().unwrap_or_else(|_| unreachable!());
|
let [ $( $components, )+ ]: [T; $number] = arr;
|
||||||
Self { $( $components, )+ }
|
DataResult::new_success(Self { $( $components, )+ })
|
||||||
})
|
} else {
|
||||||
|
DataResult::new_error(format!("Expected {} elements", $number))
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -642,9 +642,14 @@ impl From<&BlockPos> for IntStream {
|
|||||||
|
|
||||||
impl FlatTryFrom<IntStream> for BlockPos {
|
impl FlatTryFrom<IntStream> for BlockPos {
|
||||||
fn flat_try_from(value: IntStream) -> DataResult<Self> {
|
fn flat_try_from(value: IntStream) -> DataResult<Self> {
|
||||||
validate_fixed_size(value.0, 3).map(|v| {
|
validate_fixed_size(value.0, 3).flat_map(|v| {
|
||||||
let [x, y, z]: [i32; 3] = v.try_into().unwrap_or_else(|_| unreachable!());
|
v.try_into().map_or_else(
|
||||||
Self(Vector3::new(x, y, z))
|
|_| DataResult::new_error("Expected 3 elements"),
|
||||||
|
|arr| {
|
||||||
|
let [x, y, z]: [i32; 3] = arr;
|
||||||
|
DataResult::new_success(Self(Vector3::new(x, y, z)))
|
||||||
|
},
|
||||||
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -373,14 +373,15 @@ mod test {
|
|||||||
|
|
||||||
let mut original_rand = LegacyRand::from_seed(0);
|
let mut original_rand = LegacyRand::from_seed(0);
|
||||||
{
|
{
|
||||||
let RandomDeriver::Legacy(splitter) = original_rand.next_splitter() else {
|
if let RandomDeriver::Legacy(splitter) = original_rand.next_splitter() {
|
||||||
unreachable!()
|
assert_eq!(splitter.seed, (-4962768465676381896i64) as u64);
|
||||||
};
|
|
||||||
assert_eq!(splitter.seed, (-4962768465676381896i64) as u64);
|
|
||||||
|
|
||||||
let mut rand = splitter.split_string("minecraft:offset");
|
let mut rand = splitter.split_string("minecraft:offset");
|
||||||
assert_eq!(rand.next_i32(), 103436829);
|
assert_eq!(rand.next_i32(), 103436829);
|
||||||
};
|
} else {
|
||||||
|
panic!("Expected RandomDeriver::Legacy");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let mut original_rand = LegacyRand::from_seed(0);
|
let mut original_rand = LegacyRand::from_seed(0);
|
||||||
let mut new_rand = original_rand.split();
|
let mut new_rand = original_rand.split();
|
||||||
|
|||||||
@ -333,7 +333,7 @@ impl<S: SingleChunkDataSerializer> LinearV2File<S> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Number of chunks in each bucket.
|
/// Number of chunks in each bucket.
|
||||||
fn chunks_per_bucket(grid_size: u8) -> usize {
|
const fn chunks_per_bucket(grid_size: u8) -> usize {
|
||||||
CHUNK_COUNT / Self::bucket_count(grid_size)
|
CHUNK_COUNT / Self::bucket_count(grid_size)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -268,7 +268,7 @@ where
|
|||||||
let chunk_serializer = match self.get_serializer(&path).await {
|
let chunk_serializer = match self.get_serializer(&path).await {
|
||||||
Ok(s) => s,
|
Ok(s) => s,
|
||||||
Err(ChunkReadingError::ChunkNotExist) => {
|
Err(ChunkReadingError::ChunkNotExist) => {
|
||||||
unreachable!("get_serializer always returns a default serializer")
|
return;
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
// Best-effort: report the error for the first coord in the batch.
|
// Best-effort: report the error for the first coord in the batch.
|
||||||
@ -332,7 +332,9 @@ where
|
|||||||
let chunk_serializer = match self.get_serializer(&path).await {
|
let chunk_serializer = match self.get_serializer(&path).await {
|
||||||
Ok(s) => s,
|
Ok(s) => s,
|
||||||
Err(ChunkReadingError::ChunkNotExist) => {
|
Err(ChunkReadingError::ChunkNotExist) => {
|
||||||
unreachable!("get_serializer always returns a default serializer")
|
return Err(ChunkWritingError::IoError(std::io::Error::other(
|
||||||
|
"get_serializer returned ChunkNotExist",
|
||||||
|
)));
|
||||||
}
|
}
|
||||||
Err(ChunkReadingError::IoError(err)) => {
|
Err(ChunkReadingError::IoError(err)) => {
|
||||||
error!("I/O error reading region before write: {err}");
|
error!("I/O error reading region before write: {err}");
|
||||||
@ -379,7 +381,7 @@ where
|
|||||||
serializer
|
serializer
|
||||||
.write(&path)
|
.write(&path)
|
||||||
.await
|
.await
|
||||||
.map_err(ChunkWritingError::IoError)?
|
.map_err(ChunkWritingError::IoError)?;
|
||||||
// Read-lock released here.
|
// Read-lock released here.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -645,7 +645,7 @@ impl GenerationSchedule {
|
|||||||
fn save_all_chunk(&mut self, save_proto_chunk: bool) {
|
fn save_all_chunk(&mut self, save_proto_chunk: bool) {
|
||||||
let mut chunks = Vec::with_capacity(self.chunk_map.len());
|
let mut chunks = Vec::with_capacity(self.chunk_map.len());
|
||||||
|
|
||||||
for (pos, holder) in self.chunk_map.iter_mut() {
|
for (pos, holder) in &mut self.chunk_map {
|
||||||
if let Some(chunk) = holder.chunk.take() {
|
if let Some(chunk) = holder.chunk.take() {
|
||||||
let should_save = match &chunk {
|
let should_save = match &chunk {
|
||||||
Chunk::Level(sync_chunk) => sync_chunk.is_dirty(),
|
Chunk::Level(sync_chunk) => sync_chunk.is_dirty(),
|
||||||
|
|||||||
@ -21,9 +21,9 @@ pub fn get_biome_blend(
|
|||||||
// &'ing 3 gives values of 0-3, it is also the data we removed when converting to biome coords
|
// &'ing 3 gives values of 0-3, it is also the data we removed when converting to biome coords
|
||||||
// This is effectively "quarters" into the biome
|
// This is effectively "quarters" into the biome
|
||||||
// Original was "/ 4.0" but we use "* 0.25" as multiplication can be faster
|
// Original was "/ 4.0" but we use "* 0.25" as multiplication can be faster
|
||||||
let biome_x_quarters = (offset_x & 0b11) as f64 * 0.25;
|
let quarters_x = (offset_x & 0b11) as f64 * 0.25;
|
||||||
let biome_y_quarters = (offset_y & 0b11) as f64 * 0.25;
|
let quarters_y = (offset_y & 0b11) as f64 * 0.25;
|
||||||
let biome_z_quarters = (offset_z & 0b11) as f64 * 0.25;
|
let quarters_z = (offset_z & 0b11) as f64 * 0.25;
|
||||||
|
|
||||||
let mut best_permutation = 0;
|
let mut best_permutation = 0;
|
||||||
let mut best_score = f64::INFINITY;
|
let mut best_score = f64::INFINITY;
|
||||||
@ -50,20 +50,20 @@ pub fn get_biome_blend(
|
|||||||
};
|
};
|
||||||
|
|
||||||
// And reflect the "quarters" across the shift
|
// And reflect the "quarters" across the shift
|
||||||
let shifted_biome_x_quarters = if should_maintain_x {
|
let shifted_quarters_x = if should_maintain_x {
|
||||||
biome_x_quarters
|
quarters_x
|
||||||
} else {
|
} else {
|
||||||
biome_x_quarters - 1.0
|
quarters_x - 1.0
|
||||||
};
|
};
|
||||||
let shifted_biome_y_quarters = if should_maintain_y {
|
let shifted_quarters_y = if should_maintain_y {
|
||||||
biome_y_quarters
|
quarters_y
|
||||||
} else {
|
} else {
|
||||||
biome_y_quarters - 1.0
|
quarters_y - 1.0
|
||||||
};
|
};
|
||||||
let shifted_biome_z_quarters = if should_maintain_z {
|
let shifted_quarters_z = if should_maintain_z {
|
||||||
biome_z_quarters
|
quarters_z
|
||||||
} else {
|
} else {
|
||||||
biome_z_quarters - 1.0
|
quarters_z - 1.0
|
||||||
};
|
};
|
||||||
|
|
||||||
let permutation_score = score_permutation(
|
let permutation_score = score_permutation(
|
||||||
@ -71,9 +71,9 @@ pub fn get_biome_blend(
|
|||||||
shifted_biome_x,
|
shifted_biome_x,
|
||||||
shifted_biome_y,
|
shifted_biome_y,
|
||||||
shifted_biome_z,
|
shifted_biome_z,
|
||||||
shifted_biome_x_quarters,
|
shifted_quarters_x,
|
||||||
shifted_biome_y_quarters,
|
shifted_quarters_y,
|
||||||
shifted_biome_z_quarters,
|
shifted_quarters_z,
|
||||||
);
|
);
|
||||||
|
|
||||||
if best_score > permutation_score {
|
if best_score > permutation_score {
|
||||||
|
|||||||
@ -256,7 +256,7 @@ impl CanyonCarver {
|
|||||||
) && !chunk.carving_mask.get(world_x, world_y, world_z)
|
) && !chunk.carving_mask.get(world_x, world_y, world_z)
|
||||||
{
|
{
|
||||||
chunk.carving_mask.set(world_x, world_y, world_z);
|
chunk.carving_mask.set(world_x, world_y, world_z);
|
||||||
self.carve_block(chunk, config, world_x, world_y, world_z);
|
Self::carve_block(chunk, config, world_x, world_y, world_z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -280,14 +280,7 @@ impl CanyonCarver {
|
|||||||
(xd * xd + zd * zd) * width_factor_per_height[y_index - 1] as f64 + yd * yd / 6.0 >= 1.0
|
(xd * xd + zd * zd) * width_factor_per_height[y_index - 1] as f64 + yd * yd / 6.0 >= 1.0
|
||||||
}
|
}
|
||||||
|
|
||||||
fn carve_block(
|
fn carve_block(chunk: &mut ProtoChunk, config: &CarverConfig, x: i32, y: i32, z: i32) -> bool {
|
||||||
&self,
|
|
||||||
chunk: &mut ProtoChunk,
|
|
||||||
config: &CarverConfig,
|
|
||||||
x: i32,
|
|
||||||
y: i32,
|
|
||||||
z: i32,
|
|
||||||
) -> bool {
|
|
||||||
let local_y = y - chunk.bottom_y() as i32;
|
let local_y = y - chunk.bottom_y() as i32;
|
||||||
let state_id = chunk.get_block_state_raw(x & 15, local_y, z & 15);
|
let state_id = chunk.get_block_state_raw(x & 15, local_y, z & 15);
|
||||||
let block = pumpkin_data::Block::from_state_id(state_id);
|
let block = pumpkin_data::Block::from_state_id(state_id);
|
||||||
|
|||||||
@ -21,7 +21,7 @@ impl Carver for CaveCarver {
|
|||||||
let (is_nether, cave_config) = match config.additional {
|
let (is_nether, cave_config) = match config.additional {
|
||||||
CarverAdditionalConfig::Cave(ref c) => (false, c),
|
CarverAdditionalConfig::Cave(ref c) => (false, c),
|
||||||
CarverAdditionalConfig::NetherCave(ref c) => (true, c),
|
CarverAdditionalConfig::NetherCave(ref c) => (true, c),
|
||||||
_ => return,
|
CarverAdditionalConfig::Canyon(_) => return,
|
||||||
};
|
};
|
||||||
|
|
||||||
let min_y = chunk.bottom_y() as i32;
|
let min_y = chunk.bottom_y() as i32;
|
||||||
@ -49,7 +49,7 @@ impl Carver for CaveCarver {
|
|||||||
if random.next_bounded_i32(4) == 0 {
|
if random.next_bounded_i32(4) == 0 {
|
||||||
let y_scale = config.y_scale.get(random) as f64;
|
let y_scale = config.y_scale.get(random) as f64;
|
||||||
let thickness = 1.0 + random.next_f32() * 6.0;
|
let thickness = 1.0 + random.next_f32() * 6.0;
|
||||||
self.create_room(
|
Self::create_room(
|
||||||
chunk,
|
chunk,
|
||||||
x as f64,
|
x as f64,
|
||||||
y,
|
y,
|
||||||
@ -66,10 +66,10 @@ impl Carver for CaveCarver {
|
|||||||
for _ in 0..tunnels {
|
for _ in 0..tunnels {
|
||||||
let horizontal_rotation = random.next_f32() * PI * 2.0;
|
let horizontal_rotation = random.next_f32() * PI * 2.0;
|
||||||
let vertical_rotation = (random.next_f32() - 0.5) / 4.0;
|
let vertical_rotation = (random.next_f32() - 0.5) / 4.0;
|
||||||
let thickness = self.get_thickness(random, is_nether);
|
let thickness = Self::get_thickness(random, is_nether);
|
||||||
let distance = max_distance - random.next_bounded_i32(max_distance / 4);
|
let distance = max_distance - random.next_bounded_i32(max_distance / 4);
|
||||||
|
|
||||||
self.create_tunnel(
|
Self::create_tunnel(
|
||||||
config,
|
config,
|
||||||
chunk,
|
chunk,
|
||||||
random.next_i64(),
|
random.next_i64(),
|
||||||
@ -94,7 +94,7 @@ impl Carver for CaveCarver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl CaveCarver {
|
impl CaveCarver {
|
||||||
fn get_thickness(&self, random: &mut RandomGenerator, is_nether: bool) -> f32 {
|
fn get_thickness(random: &mut RandomGenerator, is_nether: bool) -> f32 {
|
||||||
if is_nether {
|
if is_nether {
|
||||||
(random.next_f32() * 2.0 + random.next_f32()) * 2.0
|
(random.next_f32() * 2.0 + random.next_f32()) * 2.0
|
||||||
} else {
|
} else {
|
||||||
@ -108,7 +108,6 @@ impl CaveCarver {
|
|||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn create_room(
|
fn create_room(
|
||||||
&self,
|
|
||||||
chunk: &mut ProtoChunk,
|
chunk: &mut ProtoChunk,
|
||||||
x: f64,
|
x: f64,
|
||||||
y: f64,
|
y: f64,
|
||||||
@ -121,7 +120,7 @@ impl CaveCarver {
|
|||||||
) {
|
) {
|
||||||
let horizontal_radius = 1.5 + (PI / 2.0).sin() * thickness;
|
let horizontal_radius = 1.5 + (PI / 2.0).sin() * thickness;
|
||||||
let vertical_radius = horizontal_radius as f64 * y_scale;
|
let vertical_radius = horizontal_radius as f64 * y_scale;
|
||||||
self.carve_ellipsoid(
|
Self::carve_ellipsoid(
|
||||||
chunk,
|
chunk,
|
||||||
config,
|
config,
|
||||||
x + 1.0,
|
x + 1.0,
|
||||||
@ -136,7 +135,6 @@ impl CaveCarver {
|
|||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn create_tunnel(
|
fn create_tunnel(
|
||||||
&self,
|
|
||||||
config: &CarverConfig,
|
config: &CarverConfig,
|
||||||
chunk: &mut ProtoChunk,
|
chunk: &mut ProtoChunk,
|
||||||
tunnel_seed: i64,
|
tunnel_seed: i64,
|
||||||
@ -165,7 +163,7 @@ impl CaveCarver {
|
|||||||
))
|
))
|
||||||
};
|
};
|
||||||
let split_point = random.next_bounded_i32(dist / 2) + dist / 4;
|
let split_point = random.next_bounded_i32(dist / 2) + dist / 4;
|
||||||
let steep = random.next_bounded_i32(6) == 0;
|
let is_steep = random.next_bounded_i32(6) == 0;
|
||||||
let mut y_rota = 0.0f32;
|
let mut y_rota = 0.0f32;
|
||||||
let mut x_rota = 0.0f32;
|
let mut x_rota = 0.0f32;
|
||||||
|
|
||||||
@ -178,7 +176,7 @@ impl CaveCarver {
|
|||||||
y += vertical_rotation.sin() as f64;
|
y += vertical_rotation.sin() as f64;
|
||||||
z += (horizontal_rotation.sin() * cos_x) as f64;
|
z += (horizontal_rotation.sin() * cos_x) as f64;
|
||||||
|
|
||||||
vertical_rotation *= if steep { 0.92 } else { 0.7 };
|
vertical_rotation *= if is_steep { 0.92 } else { 0.7 };
|
||||||
vertical_rotation += x_rota * 0.1;
|
vertical_rotation += x_rota * 0.1;
|
||||||
horizontal_rotation += y_rota * 0.1;
|
horizontal_rotation += y_rota * 0.1;
|
||||||
x_rota *= 0.9;
|
x_rota *= 0.9;
|
||||||
@ -187,7 +185,7 @@ impl CaveCarver {
|
|||||||
y_rota += (random.next_f32() - random.next_f32()) * random.next_f32() * 4.0;
|
y_rota += (random.next_f32() - random.next_f32()) * random.next_f32() * 4.0;
|
||||||
|
|
||||||
if current_step == split_point && thickness > 1.0 {
|
if current_step == split_point && thickness > 1.0 {
|
||||||
self.create_tunnel(
|
Self::create_tunnel(
|
||||||
config,
|
config,
|
||||||
chunk,
|
chunk,
|
||||||
random.next_i64(),
|
random.next_i64(),
|
||||||
@ -206,7 +204,7 @@ impl CaveCarver {
|
|||||||
is_nether,
|
is_nether,
|
||||||
legacy_random_source,
|
legacy_random_source,
|
||||||
);
|
);
|
||||||
self.create_tunnel(
|
Self::create_tunnel(
|
||||||
config,
|
config,
|
||||||
chunk,
|
chunk,
|
||||||
random.next_i64(),
|
random.next_i64(),
|
||||||
@ -229,11 +227,11 @@ impl CaveCarver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if random.next_bounded_i32(4) != 0 {
|
if random.next_bounded_i32(4) != 0 {
|
||||||
if !self.can_reach(chunk.x, chunk.z, x, z, current_step, dist, thickness) {
|
if !Self::can_reach(chunk.x, chunk.z, x, z, current_step, dist, thickness) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.carve_ellipsoid(
|
Self::carve_ellipsoid(
|
||||||
chunk,
|
chunk,
|
||||||
config,
|
config,
|
||||||
x,
|
x,
|
||||||
@ -250,7 +248,6 @@ impl CaveCarver {
|
|||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn can_reach(
|
fn can_reach(
|
||||||
&self,
|
|
||||||
chunk_x: i32,
|
chunk_x: i32,
|
||||||
chunk_z: i32,
|
chunk_z: i32,
|
||||||
x: f64,
|
x: f64,
|
||||||
@ -270,7 +267,6 @@ impl CaveCarver {
|
|||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn carve_ellipsoid(
|
fn carve_ellipsoid(
|
||||||
&self,
|
|
||||||
chunk: &mut ProtoChunk,
|
chunk: &mut ProtoChunk,
|
||||||
config: &CarverConfig,
|
config: &CarverConfig,
|
||||||
x: f64,
|
x: f64,
|
||||||
@ -292,22 +288,22 @@ impl CaveCarver {
|
|||||||
let chunk_min_x = chunk.x << 4;
|
let chunk_min_x = chunk.x << 4;
|
||||||
let chunk_min_z = chunk.z << 4;
|
let chunk_min_z = chunk.z << 4;
|
||||||
|
|
||||||
let min_x_index = ((x - horizontal_radius).floor() as i32 - chunk_min_x - 1).max(0);
|
let min_x_idx = ((x - horizontal_radius).floor() as i32 - chunk_min_x - 1).max(0);
|
||||||
let max_x_index = ((x + horizontal_radius).floor() as i32 - chunk_min_x).min(15);
|
let max_x_idx = ((x + horizontal_radius).floor() as i32 - chunk_min_x).min(15);
|
||||||
|
|
||||||
let min_y = ((y - vertical_radius).floor() as i32 - 1).max(chunk.bottom_y() as i32 + 1);
|
let min_y = ((y - vertical_radius).floor() as i32 - 1).max(chunk.bottom_y() as i32 + 1);
|
||||||
let protected_blocks_on_top = 7;
|
let protected_blocks_on_top = 7;
|
||||||
let max_y = ((y + vertical_radius).floor() as i32 + 1)
|
let max_y = ((y + vertical_radius).floor() as i32 + 1)
|
||||||
.min(chunk.bottom_y() as i32 + chunk.height() as i32 - 1 - protected_blocks_on_top);
|
.min(chunk.bottom_y() as i32 + chunk.height() as i32 - 1 - protected_blocks_on_top);
|
||||||
|
|
||||||
let min_z_index = ((z - horizontal_radius).floor() as i32 - chunk_min_z - 1).max(0);
|
let min_z_idx = ((z - horizontal_radius).floor() as i32 - chunk_min_z - 1).max(0);
|
||||||
let max_z_index = ((z + horizontal_radius).floor() as i32 - chunk_min_z).min(15);
|
let max_z_idx = ((z + horizontal_radius).floor() as i32 - chunk_min_z).min(15);
|
||||||
|
|
||||||
for x_index in min_x_index..=max_x_index {
|
for x_index in min_x_idx..=max_x_idx {
|
||||||
let world_x = chunk_min_x + x_index;
|
let world_x = chunk_min_x + x_index;
|
||||||
let xd = (world_x as f64 + 0.5 - x) / horizontal_radius;
|
let xd = (world_x as f64 + 0.5 - x) / horizontal_radius;
|
||||||
|
|
||||||
for z_index in min_z_index..=max_z_index {
|
for z_index in min_z_idx..=max_z_idx {
|
||||||
let world_z = chunk_min_z + z_index;
|
let world_z = chunk_min_z + z_index;
|
||||||
let zd = (world_z as f64 + 0.5 - z) / horizontal_radius;
|
let zd = (world_z as f64 + 0.5 - z) / horizontal_radius;
|
||||||
|
|
||||||
@ -317,11 +313,11 @@ impl CaveCarver {
|
|||||||
for world_y in (min_y + 1..=max_y).rev() {
|
for world_y in (min_y + 1..=max_y).rev() {
|
||||||
let yd = (world_y as f64 - 0.5 - y) / vertical_radius;
|
let yd = (world_y as f64 - 0.5 - y) / vertical_radius;
|
||||||
|
|
||||||
if !self.should_skip(xd, yd, zd, floor_level)
|
if !Self::should_skip(xd, yd, zd, floor_level)
|
||||||
&& !chunk.carving_mask.get(world_x, world_y, world_z)
|
&& !chunk.carving_mask.get(world_x, world_y, world_z)
|
||||||
{
|
{
|
||||||
chunk.carving_mask.set(world_x, world_y, world_z);
|
chunk.carving_mask.set(world_x, world_y, world_z);
|
||||||
self.carve_block(
|
Self::carve_block(
|
||||||
chunk,
|
chunk,
|
||||||
config,
|
config,
|
||||||
world_x,
|
world_x,
|
||||||
@ -337,7 +333,7 @@ impl CaveCarver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn should_skip(&self, xd: f64, yd: f64, zd: f64, floor_level: f64) -> bool {
|
fn should_skip(xd: f64, yd: f64, zd: f64, floor_level: f64) -> bool {
|
||||||
if yd <= floor_level {
|
if yd <= floor_level {
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
@ -347,7 +343,6 @@ impl CaveCarver {
|
|||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn carve_block(
|
fn carve_block(
|
||||||
&self,
|
|
||||||
chunk: &mut ProtoChunk,
|
chunk: &mut ProtoChunk,
|
||||||
config: &CarverConfig,
|
config: &CarverConfig,
|
||||||
x: i32,
|
x: i32,
|
||||||
|
|||||||
@ -48,7 +48,8 @@ impl GeneratorInit for VanillaGenerator {
|
|||||||
} else if dimension == Dimension::THE_END {
|
} else if dimension == Dimension::THE_END {
|
||||||
END_BASE_NOISE_ROUTER
|
END_BASE_NOISE_ROUTER
|
||||||
} else {
|
} else {
|
||||||
unreachable!()
|
tracing::error!("Unsupported dimension for noise router: {:?}", dimension);
|
||||||
|
OVERWORLD_BASE_NOISE_ROUTER
|
||||||
};
|
};
|
||||||
let terrain_cache = TerrainCache::from_random(&random_config);
|
let terrain_cache = TerrainCache::from_random(&random_config);
|
||||||
|
|
||||||
|
|||||||
@ -474,11 +474,13 @@ impl<'a> ChunkNoiseRouter<'a> {
|
|||||||
for cell_cache_index in indices {
|
for cell_cache_index in indices {
|
||||||
let (component_stack, component) = components.split_at_mut(*cell_cache_index);
|
let (component_stack, component) = components.split_at_mut(*cell_cache_index);
|
||||||
|
|
||||||
let ChunkNoiseFunctionComponent::Chunk(chunk) = component.first_mut().unwrap() else {
|
let Some(ChunkNoiseFunctionComponent::Chunk(chunk)) = component.first_mut() else {
|
||||||
unreachable!();
|
tracing::error!("Expected ChunkNoiseFunctionComponent::Chunk");
|
||||||
|
continue;
|
||||||
};
|
};
|
||||||
let ChunkSpecificNoiseFunctionComponent::CellCache(cell_cache) = chunk else {
|
let ChunkSpecificNoiseFunctionComponent::CellCache(cell_cache) = chunk else {
|
||||||
unreachable!();
|
tracing::error!("Expected ChunkSpecificNoiseFunctionComponent::CellCache");
|
||||||
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
ChunkNoiseFunctionComponent::fill_from_stack(
|
ChunkNoiseFunctionComponent::fill_from_stack(
|
||||||
@ -502,13 +504,17 @@ impl<'a> ChunkNoiseRouter<'a> {
|
|||||||
for interpolator_index in indices {
|
for interpolator_index in indices {
|
||||||
let (component_stack, component) = components.split_at_mut(*interpolator_index);
|
let (component_stack, component) = components.split_at_mut(*interpolator_index);
|
||||||
|
|
||||||
let ChunkNoiseFunctionComponent::Chunk(chunk) = component.first_mut().unwrap() else {
|
let Some(ChunkNoiseFunctionComponent::Chunk(chunk)) = component.first_mut() else {
|
||||||
unreachable!();
|
tracing::error!("Expected ChunkNoiseFunctionComponent::Chunk");
|
||||||
|
continue;
|
||||||
};
|
};
|
||||||
let ChunkSpecificNoiseFunctionComponent::DensityInterpolator(density_interpolator) =
|
let ChunkSpecificNoiseFunctionComponent::DensityInterpolator(density_interpolator) =
|
||||||
chunk
|
chunk
|
||||||
else {
|
else {
|
||||||
unreachable!();
|
tracing::error!(
|
||||||
|
"Expected ChunkSpecificNoiseFunctionComponent::DensityInterpolator"
|
||||||
|
);
|
||||||
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
let start_index = density_interpolator.yz_to_buf_index(0, cell_z);
|
let start_index = density_interpolator.yz_to_buf_index(0, cell_z);
|
||||||
@ -535,13 +541,17 @@ impl<'a> ChunkNoiseRouter<'a> {
|
|||||||
for interpolator_index in indices {
|
for interpolator_index in indices {
|
||||||
let ChunkNoiseFunctionComponent::Chunk(chunk) = &mut components[*interpolator_index]
|
let ChunkNoiseFunctionComponent::Chunk(chunk) = &mut components[*interpolator_index]
|
||||||
else {
|
else {
|
||||||
unreachable!();
|
tracing::error!("Expected ChunkNoiseFunctionComponent::Chunk");
|
||||||
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
let ChunkSpecificNoiseFunctionComponent::DensityInterpolator(density_interpolator) =
|
let ChunkSpecificNoiseFunctionComponent::DensityInterpolator(density_interpolator) =
|
||||||
chunk
|
chunk
|
||||||
else {
|
else {
|
||||||
unreachable!();
|
tracing::error!(
|
||||||
|
"Expected ChunkSpecificNoiseFunctionComponent::DensityInterpolator"
|
||||||
|
);
|
||||||
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
density_interpolator.interpolate_x(delta);
|
density_interpolator.interpolate_x(delta);
|
||||||
@ -554,13 +564,17 @@ impl<'a> ChunkNoiseRouter<'a> {
|
|||||||
for interpolator_index in indices {
|
for interpolator_index in indices {
|
||||||
let ChunkNoiseFunctionComponent::Chunk(chunk) = &mut components[*interpolator_index]
|
let ChunkNoiseFunctionComponent::Chunk(chunk) = &mut components[*interpolator_index]
|
||||||
else {
|
else {
|
||||||
unreachable!();
|
tracing::error!("Expected ChunkNoiseFunctionComponent::Chunk");
|
||||||
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
let ChunkSpecificNoiseFunctionComponent::DensityInterpolator(density_interpolator) =
|
let ChunkSpecificNoiseFunctionComponent::DensityInterpolator(density_interpolator) =
|
||||||
chunk
|
chunk
|
||||||
else {
|
else {
|
||||||
unreachable!();
|
tracing::error!(
|
||||||
|
"Expected ChunkSpecificNoiseFunctionComponent::DensityInterpolator"
|
||||||
|
);
|
||||||
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
density_interpolator.interpolate_y(delta);
|
density_interpolator.interpolate_y(delta);
|
||||||
@ -573,12 +587,16 @@ impl<'a> ChunkNoiseRouter<'a> {
|
|||||||
for interpolator_index in indices {
|
for interpolator_index in indices {
|
||||||
let ChunkNoiseFunctionComponent::Chunk(chunk) = &mut components[*interpolator_index]
|
let ChunkNoiseFunctionComponent::Chunk(chunk) = &mut components[*interpolator_index]
|
||||||
else {
|
else {
|
||||||
unreachable!();
|
tracing::error!("Expected ChunkNoiseFunctionComponent::Chunk");
|
||||||
|
continue;
|
||||||
};
|
};
|
||||||
let ChunkSpecificNoiseFunctionComponent::DensityInterpolator(density_interpolator) =
|
let ChunkSpecificNoiseFunctionComponent::DensityInterpolator(density_interpolator) =
|
||||||
chunk
|
chunk
|
||||||
else {
|
else {
|
||||||
unreachable!();
|
tracing::error!(
|
||||||
|
"Expected ChunkSpecificNoiseFunctionComponent::DensityInterpolator"
|
||||||
|
);
|
||||||
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
density_interpolator.interpolate_z(delta);
|
density_interpolator.interpolate_z(delta);
|
||||||
@ -591,12 +609,16 @@ impl<'a> ChunkNoiseRouter<'a> {
|
|||||||
for interpolator_index in indices {
|
for interpolator_index in indices {
|
||||||
let ChunkNoiseFunctionComponent::Chunk(chunk) = &mut components[*interpolator_index]
|
let ChunkNoiseFunctionComponent::Chunk(chunk) = &mut components[*interpolator_index]
|
||||||
else {
|
else {
|
||||||
unreachable!();
|
tracing::error!("Expected ChunkNoiseFunctionComponent::Chunk");
|
||||||
|
continue;
|
||||||
};
|
};
|
||||||
let ChunkSpecificNoiseFunctionComponent::DensityInterpolator(density_interpolator) =
|
let ChunkSpecificNoiseFunctionComponent::DensityInterpolator(density_interpolator) =
|
||||||
chunk
|
chunk
|
||||||
else {
|
else {
|
||||||
unreachable!();
|
tracing::error!(
|
||||||
|
"Expected ChunkSpecificNoiseFunctionComponent::DensityInterpolator"
|
||||||
|
);
|
||||||
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
density_interpolator.on_sampled_cell_corners(cell_y_position, cell_z_position);
|
density_interpolator.on_sampled_cell_corners(cell_y_position, cell_z_position);
|
||||||
@ -609,12 +631,16 @@ impl<'a> ChunkNoiseRouter<'a> {
|
|||||||
for interpolator_index in indices {
|
for interpolator_index in indices {
|
||||||
let ChunkNoiseFunctionComponent::Chunk(chunk) = &mut components[*interpolator_index]
|
let ChunkNoiseFunctionComponent::Chunk(chunk) = &mut components[*interpolator_index]
|
||||||
else {
|
else {
|
||||||
unreachable!();
|
tracing::error!("Expected ChunkNoiseFunctionComponent::Chunk");
|
||||||
|
continue;
|
||||||
};
|
};
|
||||||
let ChunkSpecificNoiseFunctionComponent::DensityInterpolator(density_interpolator) =
|
let ChunkSpecificNoiseFunctionComponent::DensityInterpolator(density_interpolator) =
|
||||||
chunk
|
chunk
|
||||||
else {
|
else {
|
||||||
unreachable!();
|
tracing::error!(
|
||||||
|
"Expected ChunkSpecificNoiseFunctionComponent::DensityInterpolator"
|
||||||
|
);
|
||||||
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
density_interpolator.swap_buffers();
|
density_interpolator.swap_buffers();
|
||||||
|
|||||||
@ -408,7 +408,7 @@ impl ProtoChunk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn top_block_height_exclusive(&self, x: i32, z: i32) -> i32 {
|
pub const fn top_block_height_exclusive(&self, x: i32, z: i32) -> i32 {
|
||||||
let local_x = x & 15;
|
let local_x = x & 15;
|
||||||
let local_z = z & 15;
|
let local_z = z & 15;
|
||||||
let index = Self::local_position_to_height_map_index(local_x, local_z);
|
let index = Self::local_position_to_height_map_index(local_x, local_z);
|
||||||
@ -416,7 +416,7 @@ impl ProtoChunk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn ocean_floor_height_exclusive(&self, x: i32, z: i32) -> i32 {
|
pub const fn ocean_floor_height_exclusive(&self, x: i32, z: i32) -> i32 {
|
||||||
let local_x = x & 15;
|
let local_x = x & 15;
|
||||||
let local_z = z & 15;
|
let local_z = z & 15;
|
||||||
let index = Self::local_position_to_height_map_index(local_x, local_z);
|
let index = Self::local_position_to_height_map_index(local_x, local_z);
|
||||||
@ -424,7 +424,7 @@ impl ProtoChunk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn top_motion_blocking_block_height_exclusive(&self, x: i32, z: i32) -> i32 {
|
pub const fn top_motion_blocking_block_height_exclusive(&self, x: i32, z: i32) -> i32 {
|
||||||
let local_x = x & 15;
|
let local_x = x & 15;
|
||||||
let local_z = z & 15;
|
let local_z = z & 15;
|
||||||
let index = Self::local_position_to_height_map_index(local_x, local_z);
|
let index = Self::local_position_to_height_map_index(local_x, local_z);
|
||||||
@ -432,7 +432,11 @@ impl ProtoChunk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn top_motion_blocking_block_no_leaves_height_exclusive(&self, x: i32, z: i32) -> i32 {
|
pub const fn top_motion_blocking_block_no_leaves_height_exclusive(
|
||||||
|
&self,
|
||||||
|
x: i32,
|
||||||
|
z: i32,
|
||||||
|
) -> i32 {
|
||||||
let local_x = x & 15;
|
let local_x = x & 15;
|
||||||
let local_z = z & 15;
|
let local_z = z & 15;
|
||||||
let index = Self::local_position_to_height_map_index(local_x, local_z);
|
let index = Self::local_position_to_height_map_index(local_x, local_z);
|
||||||
|
|||||||
@ -387,7 +387,7 @@ impl StructurePieceBase for JungleTemplePiece {
|
|||||||
};
|
};
|
||||||
self.piece.add_block(chunk, r_state, 9, -3, 5, bb);
|
self.piece.add_block(chunk, r_state, 9, -3, 5, bb);
|
||||||
self.piece
|
self.piece
|
||||||
.add_block(chunk, Block::MOSSY_COBBLESTONE.default_state, 9, -3, 4, bb)
|
.add_block(chunk, Block::MOSSY_COBBLESTONE.default_state, 9, -3, 4, bb);
|
||||||
};
|
};
|
||||||
self.piece.add_block(chunk, redstone_wire_ns, 9, -2, 4, bb);
|
self.piece.add_block(chunk, redstone_wire_ns, 9, -2, 4, bb);
|
||||||
/*if !self.placed_trap_2 {
|
/*if !self.placed_trap_2 {
|
||||||
|
|||||||
@ -8,20 +8,20 @@ use pumpkin_util::math::position::BlockPos;
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
pub struct DynamicLightEngine {
|
pub struct DynamicLightEngine {
|
||||||
decrease_block_light_queue: SegQueue<(BlockPos, u8)>,
|
block_decrease: SegQueue<(BlockPos, u8)>,
|
||||||
increase_block_light_queue: SegQueue<(BlockPos, u8)>,
|
block_increase: SegQueue<(BlockPos, u8)>,
|
||||||
decrease_sky_light_queue: SegQueue<(BlockPos, u8)>,
|
sky_decrease: SegQueue<(BlockPos, u8)>,
|
||||||
increase_sky_light_queue: SegQueue<(BlockPos, u8)>,
|
sky_increase: SegQueue<(BlockPos, u8)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DynamicLightEngine {
|
impl DynamicLightEngine {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn new() -> Self {
|
pub const fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
decrease_block_light_queue: SegQueue::new(),
|
block_decrease: SegQueue::new(),
|
||||||
increase_block_light_queue: SegQueue::new(),
|
block_increase: SegQueue::new(),
|
||||||
decrease_sky_light_queue: SegQueue::new(),
|
sky_decrease: SegQueue::new(),
|
||||||
increase_sky_light_queue: SegQueue::new(),
|
sky_increase: SegQueue::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -32,7 +32,7 @@ impl Default for DynamicLightEngine {
|
|||||||
}
|
}
|
||||||
impl DynamicLightEngine {
|
impl DynamicLightEngine {
|
||||||
/// Checks if there is an open sky above the given position (no opaque blocks blocking sky light).
|
/// Checks if there is an open sky above the given position (no opaque blocks blocking sky light).
|
||||||
async fn has_open_sky_above(&self, level: &Arc<Level>, pos: &BlockPos) -> bool {
|
fn has_open_sky_above(level: &Arc<Level>, pos: &BlockPos) -> bool {
|
||||||
let max_y = 319; // Maximum build height in Minecraft, can be adjusted if needed
|
let max_y = 319; // Maximum build height in Minecraft, can be adjusted if needed
|
||||||
let mut current_pos = *pos;
|
let mut current_pos = *pos;
|
||||||
|
|
||||||
@ -51,40 +51,40 @@ impl DynamicLightEngine {
|
|||||||
|
|
||||||
/// Handles all lighting updates triggered by a block change (placement/break).
|
/// Handles all lighting updates triggered by a block change (placement/break).
|
||||||
/// This updates Block Light, Sky Light, and ensures the source block is valid.
|
/// This updates Block Light, Sky Light, and ensures the source block is valid.
|
||||||
pub async fn update_lighting_at(&self, level: &Arc<Level>, pos: BlockPos) {
|
pub fn update_lighting_at(&self, level: &Arc<Level>, pos: BlockPos) {
|
||||||
// Block Light
|
// Block Light
|
||||||
self.check_block_light_updates(level, pos).await;
|
self.check_block_light_updates(level, pos);
|
||||||
self.perform_block_light_updates(level).await;
|
self.perform_block_light_updates(level);
|
||||||
|
|
||||||
// Sky Light
|
// Sky Light
|
||||||
self.check_sky_light_updates(level, pos).await;
|
self.check_sky_light_updates(level, pos);
|
||||||
self.perform_sky_light_updates(level).await;
|
self.perform_sky_light_updates(level);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn queue_block_light_decrease(&self, pos: BlockPos, level: u8) {
|
pub fn queue_block_light_decrease(&self, pos: BlockPos, level: u8) {
|
||||||
self.decrease_block_light_queue.push((pos, level));
|
self.block_decrease.push((pos, level));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn queue_block_light_increase(&self, pos: BlockPos, level: u8) {
|
pub fn queue_block_light_increase(&self, pos: BlockPos, level: u8) {
|
||||||
self.increase_block_light_queue.push((pos, level));
|
self.block_increase.push((pos, level));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn queue_sky_light_decrease(&self, pos: BlockPos, level: u8) {
|
pub fn queue_sky_light_decrease(&self, pos: BlockPos, level: u8) {
|
||||||
self.decrease_sky_light_queue.push((pos, level));
|
self.sky_decrease.push((pos, level));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn queue_sky_light_increase(&self, pos: BlockPos, level: u8) {
|
pub fn queue_sky_light_increase(&self, pos: BlockPos, level: u8) {
|
||||||
self.increase_sky_light_queue.push((pos, level));
|
self.sky_increase.push((pos, level));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn perform_block_light_updates(&self, level: &Arc<Level>) -> i32 {
|
pub fn perform_block_light_updates(&self, level: &Arc<Level>) -> i32 {
|
||||||
let mut updates = 0;
|
let mut updates = 0;
|
||||||
|
|
||||||
// Keep processing until both queues are empty
|
// Keep processing until both queues are empty
|
||||||
// Light propagation queues new updates, so we need to process until convergence
|
// Light propagation queues new updates, so we need to process until convergence
|
||||||
loop {
|
loop {
|
||||||
let decrease_updates = self.perform_block_light_decrease_updates(level).await;
|
let decrease_updates = self.perform_block_light_decrease_updates(level);
|
||||||
let increase_updates = self.perform_block_light_increase_updates(level).await;
|
let increase_updates = self.perform_block_light_increase_updates(level);
|
||||||
|
|
||||||
updates += decrease_updates + increase_updates;
|
updates += decrease_updates + increase_updates;
|
||||||
|
|
||||||
@ -97,36 +97,29 @@ impl DynamicLightEngine {
|
|||||||
updates
|
updates
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn perform_block_light_decrease_updates(&self, level: &Arc<Level>) -> i32 {
|
fn perform_block_light_decrease_updates(&self, level: &Arc<Level>) -> i32 {
|
||||||
let mut updates = 0;
|
let mut updates = 0;
|
||||||
|
|
||||||
while let Some((pos, expected_light)) = self.decrease_block_light_queue.pop() {
|
while let Some((pos, expected_light)) = self.block_decrease.pop() {
|
||||||
self.propagate_block_light_decrease(level, &pos, expected_light)
|
self.propagate_block_light_decrease(level, &pos, expected_light);
|
||||||
.await;
|
|
||||||
updates += 1;
|
updates += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
updates
|
updates
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn perform_block_light_increase_updates(&self, level: &Arc<Level>) -> i32 {
|
fn perform_block_light_increase_updates(&self, level: &Arc<Level>) -> i32 {
|
||||||
let mut updates = 0;
|
let mut updates = 0;
|
||||||
|
|
||||||
while let Some((pos, expected_light)) = self.increase_block_light_queue.pop() {
|
while let Some((pos, expected_light)) = self.block_increase.pop() {
|
||||||
self.propagate_block_light_increase(level, &pos, expected_light)
|
self.propagate_block_light_increase(level, &pos, expected_light);
|
||||||
.await;
|
|
||||||
updates += 1;
|
updates += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
updates
|
updates
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn propagate_block_light_increase(
|
fn propagate_block_light_increase(&self, level: &Arc<Level>, pos: &BlockPos, light_level: u8) {
|
||||||
&self,
|
|
||||||
level: &Arc<Level>,
|
|
||||||
pos: &BlockPos,
|
|
||||||
light_level: u8,
|
|
||||||
) {
|
|
||||||
for dir in BlockDirection::all() {
|
for dir in BlockDirection::all() {
|
||||||
let neighbor_pos = pos.offset(dir.to_offset());
|
let neighbor_pos = pos.offset(dir.to_offset());
|
||||||
|
|
||||||
@ -148,7 +141,7 @@ impl DynamicLightEngine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn propagate_block_light_decrease(
|
fn propagate_block_light_decrease(
|
||||||
&self,
|
&self,
|
||||||
level: &Arc<Level>,
|
level: &Arc<Level>,
|
||||||
pos: &BlockPos,
|
pos: &BlockPos,
|
||||||
@ -196,7 +189,7 @@ impl DynamicLightEngine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn check_block_light_updates(&self, level: &Arc<Level>, pos: BlockPos) {
|
pub fn check_block_light_updates(&self, level: &Arc<Level>, pos: BlockPos) {
|
||||||
match level.lighting_config {
|
match level.lighting_config {
|
||||||
LightingEngineConfig::Full => {
|
LightingEngineConfig::Full => {
|
||||||
self.set_block_light_level(level, &pos, 15).ok();
|
self.set_block_light_level(level, &pos, 15).ok();
|
||||||
@ -227,12 +220,11 @@ impl DynamicLightEngine {
|
|||||||
// Only check neighbors if we didn't trigger a decrease
|
// Only check neighbors if we didn't trigger a decrease
|
||||||
// Decrease propagation handles re-validating neighbors
|
// Decrease propagation handles re-validating neighbors
|
||||||
if expected_light >= current_light {
|
if expected_light >= current_light {
|
||||||
self.check_neighbors_light_updates(level, pos, expected_light)
|
self.check_neighbors_light_updates(level, pos, expected_light);
|
||||||
.await;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn check_neighbors_light_updates(
|
pub fn check_neighbors_light_updates(
|
||||||
&self,
|
&self,
|
||||||
level: &Arc<Level>,
|
level: &Arc<Level>,
|
||||||
pos: BlockPos,
|
pos: BlockPos,
|
||||||
@ -248,11 +240,11 @@ impl DynamicLightEngine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn perform_sky_light_updates(&self, level: &Arc<Level>) -> i32 {
|
pub fn perform_sky_light_updates(&self, level: &Arc<Level>) -> i32 {
|
||||||
let mut updates = 0;
|
let mut updates = 0;
|
||||||
loop {
|
loop {
|
||||||
let decrease_updates = self.perform_sky_light_decrease_updates(level).await;
|
let decrease_updates = self.perform_sky_light_decrease_updates(level);
|
||||||
let increase_updates = self.perform_sky_light_increase_updates(level).await;
|
let increase_updates = self.perform_sky_light_increase_updates(level);
|
||||||
|
|
||||||
updates += decrease_updates + increase_updates;
|
updates += decrease_updates + increase_updates;
|
||||||
|
|
||||||
@ -263,32 +255,25 @@ impl DynamicLightEngine {
|
|||||||
updates
|
updates
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn perform_sky_light_decrease_updates(&self, level: &Arc<Level>) -> i32 {
|
fn perform_sky_light_decrease_updates(&self, level: &Arc<Level>) -> i32 {
|
||||||
let mut updates = 0;
|
let mut updates = 0;
|
||||||
while let Some((pos, expected_light)) = self.decrease_sky_light_queue.pop() {
|
while let Some((pos, expected_light)) = self.sky_decrease.pop() {
|
||||||
self.propagate_sky_light_decrease(level, &pos, expected_light)
|
self.propagate_sky_light_decrease(level, &pos, expected_light);
|
||||||
.await;
|
|
||||||
updates += 1;
|
updates += 1;
|
||||||
}
|
}
|
||||||
updates
|
updates
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn perform_sky_light_increase_updates(&self, level: &Arc<Level>) -> i32 {
|
fn perform_sky_light_increase_updates(&self, level: &Arc<Level>) -> i32 {
|
||||||
let mut updates = 0;
|
let mut updates = 0;
|
||||||
while let Some((pos, expected_light)) = self.increase_sky_light_queue.pop() {
|
while let Some((pos, expected_light)) = self.sky_increase.pop() {
|
||||||
self.propagate_sky_light_increase(level, &pos, expected_light)
|
self.propagate_sky_light_increase(level, &pos, expected_light);
|
||||||
.await;
|
|
||||||
updates += 1;
|
updates += 1;
|
||||||
}
|
}
|
||||||
updates
|
updates
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn propagate_sky_light_increase(
|
fn propagate_sky_light_increase(&self, level: &Arc<Level>, pos: &BlockPos, light_level: u8) {
|
||||||
&self,
|
|
||||||
level: &Arc<Level>,
|
|
||||||
pos: &BlockPos,
|
|
||||||
light_level: u8,
|
|
||||||
) {
|
|
||||||
for dir in BlockDirection::all() {
|
for dir in BlockDirection::all() {
|
||||||
let neighbor_pos = pos.offset(dir.to_offset());
|
let neighbor_pos = pos.offset(dir.to_offset());
|
||||||
|
|
||||||
@ -317,12 +302,7 @@ impl DynamicLightEngine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn propagate_sky_light_decrease(
|
fn propagate_sky_light_decrease(&self, level: &Arc<Level>, pos: &BlockPos, removed_light: u8) {
|
||||||
&self,
|
|
||||||
level: &Arc<Level>,
|
|
||||||
pos: &BlockPos,
|
|
||||||
removed_light: u8,
|
|
||||||
) {
|
|
||||||
for dir in BlockDirection::all() {
|
for dir in BlockDirection::all() {
|
||||||
let neighbor_pos = pos.offset(dir.to_offset());
|
let neighbor_pos = pos.offset(dir.to_offset());
|
||||||
|
|
||||||
@ -353,7 +333,7 @@ impl DynamicLightEngine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn check_sky_light_updates(&self, level: &Arc<Level>, pos: BlockPos) {
|
pub fn check_sky_light_updates(&self, level: &Arc<Level>, pos: BlockPos) {
|
||||||
match level.lighting_config {
|
match level.lighting_config {
|
||||||
LightingEngineConfig::Full => {
|
LightingEngineConfig::Full => {
|
||||||
self.set_sky_light_level(level, &pos, 15).ok();
|
self.set_sky_light_level(level, &pos, 15).ok();
|
||||||
@ -376,7 +356,7 @@ impl DynamicLightEngine {
|
|||||||
0
|
0
|
||||||
} else {
|
} else {
|
||||||
// Check if there's open sky above
|
// Check if there's open sky above
|
||||||
let has_sky = self.has_open_sky_above(level, &pos).await;
|
let has_sky = Self::has_open_sky_above(level, &pos);
|
||||||
|
|
||||||
if has_sky {
|
if has_sky {
|
||||||
// Direct sunlight, reduced by opacity
|
// Direct sunlight, reduced by opacity
|
||||||
@ -419,12 +399,11 @@ impl DynamicLightEngine {
|
|||||||
|
|
||||||
// Notify neighbors if light increased or stayed same
|
// Notify neighbors if light increased or stayed same
|
||||||
if expected_light >= current_light {
|
if expected_light >= current_light {
|
||||||
self.check_neighbors_sky_light_updates(pos, expected_light)
|
self.check_neighbors_sky_light_updates(pos, expected_light);
|
||||||
.await;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn check_neighbors_sky_light_updates(&self, pos: BlockPos, current_light: u8) {
|
pub fn check_neighbors_sky_light_updates(&self, pos: BlockPos, current_light: u8) {
|
||||||
// When we update a position, propagate to neighbors
|
// When we update a position, propagate to neighbors
|
||||||
if current_light > 0 {
|
if current_light > 0 {
|
||||||
self.queue_sky_light_increase(pos, current_light);
|
self.queue_sky_light_increase(pos, current_light);
|
||||||
|
|||||||
@ -181,7 +181,13 @@ fn compute_flanking_rail_new_shape(
|
|||||||
}
|
}
|
||||||
1 => [connected_towards[0], flanking_from],
|
1 => [connected_towards[0], flanking_from],
|
||||||
0 => [flanking_from, flanking_from.opposite()],
|
0 => [flanking_from, flanking_from.opposite()],
|
||||||
_ => unreachable!("Rails only have two sides"),
|
_ => {
|
||||||
|
tracing::error!(
|
||||||
|
"Rails only have two sides, but got {}",
|
||||||
|
connected_towards.len()
|
||||||
|
);
|
||||||
|
return rail.properties.shape();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle rails that want to be straight
|
// Handle rails that want to be straight
|
||||||
|
|||||||
@ -152,10 +152,14 @@ impl Rail {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_ => unreachable!(
|
_ => {
|
||||||
"Invalid rail direction combination: {:?}, {:?}",
|
tracing::error!(
|
||||||
first, second
|
"Invalid rail direction combination: {:?}, {:?}",
|
||||||
),
|
first,
|
||||||
|
second
|
||||||
|
);
|
||||||
|
RailShape::NorthSouth
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -259,7 +263,10 @@ impl RailProperties {
|
|||||||
RailShape::AscendingWest => RailShapeStraight::AscendingWest,
|
RailShape::AscendingWest => RailShapeStraight::AscendingWest,
|
||||||
RailShape::AscendingNorth => RailShapeStraight::AscendingNorth,
|
RailShape::AscendingNorth => RailShapeStraight::AscendingNorth,
|
||||||
RailShape::AscendingSouth => RailShapeStraight::AscendingSouth,
|
RailShape::AscendingSouth => RailShapeStraight::AscendingSouth,
|
||||||
_ => unreachable!("Trying to make a straight rail curved: {:?}", shape),
|
_ => {
|
||||||
|
tracing::error!("Trying to make a straight rail curved: {:?}", shape);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -118,7 +118,10 @@ impl RedstoneWireTurbo {
|
|||||||
2 | 5 => Self::EAST,
|
2 | 5 => Self::EAST,
|
||||||
3 | 4 => Self::WEST,
|
3 | 4 => Self::WEST,
|
||||||
6..=8 => Self::SOUTH,
|
6..=8 => Self::SOUTH,
|
||||||
_ => unreachable!(),
|
_ => {
|
||||||
|
tracing::error!("Invalid turbo heading code: {}", code);
|
||||||
|
Self::NORTH
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -317,7 +317,7 @@ impl BlockBehaviour for SignBlock {
|
|||||||
crate::net::ClientPlatform::Java(java) => {
|
crate::net::ClientPlatform::Java(java) => {
|
||||||
java.send_sign_packet(*args.position, true).await;
|
java.send_sign_packet(*args.position, true).await;
|
||||||
}
|
}
|
||||||
crate::net::ClientPlatform::Bedrock(_bedrock) => todo!(),
|
crate::net::ClientPlatform::Bedrock(_bedrock) => {}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -458,7 +458,7 @@ impl BlockBehaviour for SignBlock {
|
|||||||
java.send_sign_packet(*args.position, is_facing_front_text)
|
java.send_sign_packet(*args.position, is_facing_front_text)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
ClientPlatform::Bedrock(_bedrock) => todo!(),
|
ClientPlatform::Bedrock(_bedrock) => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockActionResult::SuccessServer
|
BlockActionResult::SuccessServer
|
||||||
|
|||||||
@ -38,7 +38,10 @@ impl BlockBehaviour for WitherSkeletonSkullBlock {
|
|||||||
0 => *pos,
|
0 => *pos,
|
||||||
1 => pos.offset(opposite.to_offset()),
|
1 => pos.offset(opposite.to_offset()),
|
||||||
2 => pos.offset(dir.to_offset()),
|
2 => pos.offset(dir.to_offset()),
|
||||||
_ => unreachable!(),
|
_ => {
|
||||||
|
tracing::error!("Invalid offset in wither skull check: {}", offset);
|
||||||
|
*pos
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let top_middle = center_skull_pos.down();
|
let top_middle = center_skull_pos.down();
|
||||||
|
|||||||
@ -120,7 +120,7 @@ impl FromStr for EntityFilter {
|
|||||||
}
|
}
|
||||||
Ok(Self::Sort(sort))
|
Ok(Self::Sort(sort))
|
||||||
}
|
}
|
||||||
_ => todo!("{key}"),
|
_ => Err(format!("Unimplemented key: {key}")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -80,7 +80,7 @@ impl CommandExecutor for Executor {
|
|||||||
// };
|
// };
|
||||||
// let lock = target.entity_equipment.lock().await.get(&EquipmentSlot::MAIN_HAND); TODO this dont work
|
// let lock = target.entity_equipment.lock().await.get(&EquipmentSlot::MAIN_HAND); TODO this dont work
|
||||||
let Some(player) = target.get_player() else {
|
let Some(player) = target.get_player() else {
|
||||||
todo!()
|
continue;
|
||||||
};
|
};
|
||||||
let lock = player.inventory.held_item();
|
let lock = player.inventory.held_item();
|
||||||
let mut item = lock.lock().await;
|
let mut item = lock.lock().await;
|
||||||
|
|||||||
@ -572,9 +572,7 @@ impl SnbtParser<'_, '_> {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EscapeSequenceBranch::UnicodeName(_name) => {
|
EscapeSequenceBranch::UnicodeName(_name) => None,
|
||||||
todo!("Unicode Name functionality has not been implemented yet")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -839,9 +837,13 @@ impl SnbtParser<'_, '_> {
|
|||||||
Number::Short(short) => NbtTag::Short(short),
|
Number::Short(short) => NbtTag::Short(short),
|
||||||
Number::Int(int) => NbtTag::Int(int),
|
Number::Int(int) => NbtTag::Int(int),
|
||||||
Number::Long(long) => NbtTag::Long(long),
|
Number::Long(long) => NbtTag::Long(long),
|
||||||
_ => unreachable!(
|
_ => {
|
||||||
"Got a floating-point number when only integers should be returned"
|
self.store_dynamic_error(
|
||||||
),
|
&INVALID_CODEPOINT,
|
||||||
|
"Expected integer".to_string(),
|
||||||
|
);
|
||||||
|
return None;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Literal::String(string) => NbtTag::String(string.into()),
|
Literal::String(string) => NbtTag::String(string.into()),
|
||||||
|
|||||||
@ -400,7 +400,10 @@ impl Suggestions {
|
|||||||
(Some(text), Some(integer)) => match text.0.cmp(&integer.0) {
|
(Some(text), Some(integer)) => match text.0.cmp(&integer.0) {
|
||||||
Ordering::Less => PushSide::Text,
|
Ordering::Less => PushSide::Text,
|
||||||
Ordering::Greater => PushSide::Integer,
|
Ordering::Greater => PushSide::Integer,
|
||||||
Ordering::Equal => unreachable!(),
|
Ordering::Equal => {
|
||||||
|
tracing::error!("Duplicate suggestion found during merge");
|
||||||
|
PushSide::Text
|
||||||
|
}
|
||||||
},
|
},
|
||||||
(Some(_), None) => PushSide::Text,
|
(Some(_), None) => PushSide::Text,
|
||||||
(None, Some(_)) => PushSide::Integer,
|
(None, Some(_)) => PushSide::Integer,
|
||||||
|
|||||||
@ -123,7 +123,8 @@ impl Controls {
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unreachable!()
|
tracing::error!("Controls::idx called with no controls set");
|
||||||
|
0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -41,7 +41,10 @@ impl BoatItem {
|
|||||||
val if val == Item::PALE_OAK_CHEST_BOAT.id => &EntityType::PALE_OAK_CHEST_BOAT,
|
val if val == Item::PALE_OAK_CHEST_BOAT.id => &EntityType::PALE_OAK_CHEST_BOAT,
|
||||||
val if val == Item::BAMBOO_RAFT.id => &EntityType::BAMBOO_RAFT,
|
val if val == Item::BAMBOO_RAFT.id => &EntityType::BAMBOO_RAFT,
|
||||||
val if val == Item::BAMBOO_CHEST_RAFT.id => &EntityType::BAMBOO_CHEST_RAFT,
|
val if val == Item::BAMBOO_CHEST_RAFT.id => &EntityType::BAMBOO_CHEST_RAFT,
|
||||||
_ => unreachable!(),
|
_ => {
|
||||||
|
tracing::error!("Unknown boat item ID: {}", item.id);
|
||||||
|
&EntityType::OAK_BOAT
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -28,7 +28,10 @@ impl MinecartItem {
|
|||||||
val if val == Item::HOPPER_MINECART.id => &EntityType::HOPPER_MINECART,
|
val if val == Item::HOPPER_MINECART.id => &EntityType::HOPPER_MINECART,
|
||||||
val if val == Item::FURNACE_MINECART.id => &EntityType::FURNACE_MINECART,
|
val if val == Item::FURNACE_MINECART.id => &EntityType::FURNACE_MINECART,
|
||||||
val if val == Item::COMMAND_BLOCK_MINECART.id => &EntityType::COMMAND_BLOCK_MINECART,
|
val if val == Item::COMMAND_BLOCK_MINECART.id => &EntityType::COMMAND_BLOCK_MINECART,
|
||||||
_ => unreachable!(),
|
_ => {
|
||||||
|
tracing::error!("Unknown minecart item ID: {}", item.id);
|
||||||
|
&EntityType::MINECART
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2397,7 +2397,10 @@ impl JavaClient {
|
|||||||
6 => EquipmentSlot::CHEST,
|
6 => EquipmentSlot::CHEST,
|
||||||
7 => EquipmentSlot::LEGS,
|
7 => EquipmentSlot::LEGS,
|
||||||
8 => EquipmentSlot::FEET,
|
8 => EquipmentSlot::FEET,
|
||||||
_ => unreachable!(),
|
_ => {
|
||||||
|
tracing::error!("Invalid armor slot: {}", packet.slot);
|
||||||
|
EquipmentSlot::HEAD
|
||||||
|
}
|
||||||
},
|
},
|
||||||
&item_stack,
|
&item_stack,
|
||||||
)
|
)
|
||||||
|
|||||||
@ -126,21 +126,21 @@ impl ClientPlatform {
|
|||||||
/// This function should only be used where you know that the client is bedrock!
|
/// This function should only be used where you know that the client is bedrock!
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn bedrock(&self) -> &Arc<BedrockClient> {
|
pub const fn bedrock(&self) -> Option<&Arc<BedrockClient>> {
|
||||||
if let Self::Bedrock(client) = self {
|
if let Self::Bedrock(client) = self {
|
||||||
return client;
|
return Some(client);
|
||||||
}
|
}
|
||||||
unreachable!()
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This function should only be used where you know that the client is java!
|
/// This function should only be used where you know that the client is java!
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn java(&self) -> &JavaClient {
|
pub const fn java(&self) -> Option<&JavaClient> {
|
||||||
if let Self::Java(client) = self {
|
if let Self::Java(client) = self {
|
||||||
return client;
|
return Some(client);
|
||||||
}
|
}
|
||||||
unreachable!()
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
|
|||||||
@ -345,15 +345,9 @@ impl pumpkin::plugin::command::HostCommandSender for PluginHostState {
|
|||||||
&mut self,
|
&mut self,
|
||||||
_res: Resource<CommandSender>,
|
_res: Resource<CommandSender>,
|
||||||
) -> wasmtime::Result<CommandSenderType> {
|
) -> wasmtime::Result<CommandSenderType> {
|
||||||
// let sender = &self.get_sender_res(&res)?.provider;
|
Err(wasmtime::Error::msg(
|
||||||
// Ok(match sender {
|
"get_command_sender_type not implemented",
|
||||||
// crate::command::CommandSender::Player(_) => CommandSenderType::Player,
|
))
|
||||||
// crate::command::CommandSender::Console => CommandSenderType::Console,
|
|
||||||
// crate::command::CommandSender::Rcon(_) => CommandSenderType::Rcon,
|
|
||||||
// crate::command::CommandSender::CommandBlock(.._) => CommandSenderType::CommandBlock,
|
|
||||||
// crate::command::CommandSender::Dummy => CommandSenderType::Dummy,
|
|
||||||
// })
|
|
||||||
todo!()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_name(&mut self, sender: Resource<CommandSender>) -> wasmtime::Result<String> {
|
async fn get_name(&mut self, sender: Resource<CommandSender>) -> wasmtime::Result<String> {
|
||||||
@ -604,7 +598,11 @@ impl pumpkin::plugin::command::HostCommandNode for PluginHostState {
|
|||||||
ArgumentType::Gamemode => argument(name, GamemodeArgumentConsumer),
|
ArgumentType::Gamemode => argument(name, GamemodeArgumentConsumer),
|
||||||
ArgumentType::Difficulty => argument(name, DifficultyArgumentConsumer),
|
ArgumentType::Difficulty => argument(name, DifficultyArgumentConsumer),
|
||||||
ArgumentType::Time(_) => argument(name, TimeArgumentConsumer),
|
ArgumentType::Time(_) => argument(name, TimeArgumentConsumer),
|
||||||
_ => todo!("Unimplemented argument type: {:?}", arg_type),
|
_ => {
|
||||||
|
return Err(wasmtime::Error::msg(format!(
|
||||||
|
"Unimplemented argument type: {arg_type:?}"
|
||||||
|
)));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
self.add_command_node(node)
|
self.add_command_node(node)
|
||||||
.map_err(|_| wasmtime::Error::msg("Failed to add argument node"))
|
.map_err(|_| wasmtime::Error::msg("Failed to add argument node"))
|
||||||
@ -653,7 +651,9 @@ impl pumpkin::plugin::command::HostCommandNode for PluginHostState {
|
|||||||
_node: Resource<CommandNode>,
|
_node: Resource<CommandNode>,
|
||||||
_handler_id: u32,
|
_handler_id: u32,
|
||||||
) -> wasmtime::Result<()> {
|
) -> wasmtime::Result<()> {
|
||||||
todo!("Implement require_with_handler_id")
|
Err(wasmtime::Error::msg(
|
||||||
|
"require_with_handler_id not implemented",
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn drop(&mut self, rep: Resource<CommandNode>) -> wasmtime::Result<()> {
|
async fn drop(&mut self, rep: Resource<CommandNode>) -> wasmtime::Result<()> {
|
||||||
|
|||||||
@ -149,7 +149,9 @@ async fn register_player_event(
|
|||||||
register_typed_event::<PlayerToggleSprintEvent>(resource, handler, priority, blocking)
|
register_typed_event::<PlayerToggleSprintEvent>(resource, handler, priority, blocking)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
_ => unreachable!("non-player event should not be routed to register_player_event"),
|
_ => {
|
||||||
|
tracing::error!("non-player event should not be routed to register_player_event");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,7 +183,9 @@ async fn register_world_event(
|
|||||||
EventType::SpawnChangeEvent => {
|
EventType::SpawnChangeEvent => {
|
||||||
register_typed_event::<SpawnChangeEvent>(resource, handler, priority, blocking).await;
|
register_typed_event::<SpawnChangeEvent>(resource, handler, priority, blocking).await;
|
||||||
}
|
}
|
||||||
_ => unreachable!("non-world event should not be routed to register_world_event"),
|
_ => {
|
||||||
|
tracing::error!("non-world event should not be routed to register_world_event");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,7 +221,9 @@ async fn register_block_event(
|
|||||||
EventType::BlockPlaceEvent => {
|
EventType::BlockPlaceEvent => {
|
||||||
register_typed_event::<BlockPlaceEvent>(resource, handler, priority, blocking).await;
|
register_typed_event::<BlockPlaceEvent>(resource, handler, priority, blocking).await;
|
||||||
}
|
}
|
||||||
_ => unreachable!("non-block event should not be routed to register_block_event"),
|
_ => {
|
||||||
|
tracing::error!("non-block event should not be routed to register_block_event");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async fn register_server_event(
|
async fn register_server_event(
|
||||||
@ -244,7 +250,9 @@ async fn register_server_event(
|
|||||||
register_typed_event::<ServerTickStartEvent>(resource, handler, priority, blocking)
|
register_typed_event::<ServerTickStartEvent>(resource, handler, priority, blocking)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
_ => unreachable!("non-server event should not be routed to register_server_event"),
|
_ => {
|
||||||
|
tracing::error!("non-server event should not be routed to register_server_event");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user