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