use super::GameVersion;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum PhysicsRules {
V1_8,
V1_12,
V1_16_5,
Modern26_1,
Modern26_2,
Modern26_3,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum UseStop {
AtSelect,
HeldReplaced,
HeldItemChanged,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum CooldownReset {
AtSelect,
ItemAndDamage,
Item,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum ItemCooldownRules {
None,
PerItem,
Groups,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum InvulnerableEating {
Never,
Always,
Hunger,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum DataSet {
V1_8,
V1_12,
V1_16_5,
V26_1,
V26_2,
V26_3,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum ItemModel {
LegacyNbt,
FlatNbt,
Components,
}
#[derive(Debug, Clone, Copy, PartialEq)]
#[non_exhaustive]
pub struct Capabilities {
pub version: GameVersion,
pub protocol: i32,
pub physics: PhysicsRules,
pub data: DataSet,
pub item_model: ItemModel,
pub combat_1_9: bool,
pub entity_pick_root_vehicle: bool,
pub eye_height: f64,
pub sneak_eye_height: f64,
pub chat_limit: usize,
pub immediate_respawn_rule: bool,
pub seed_planting_prediction: bool,
pub teleport_confirm: bool,
pub window_confirm: bool,
pub configuration_state: bool,
pub sneak_via_player_input: bool,
pub sends_tick_end: bool,
pub player_loaded_gate: bool,
pub chunk_batch_ack: bool,
pub block_sequence: bool,
pub chat_acknowledgements: bool,
pub drop_prediction: bool,
pub client_entity_push: bool,
pub spectator_block_click_swings: bool,
pub spectator_switch_stops_use: bool,
pub attack_knockback_enchantment: bool,
pub use_equip_swings: bool,
pub own_inventory_passes_keys: bool,
pub use_stop: UseStop,
pub creative_instant_dig: bool,
pub invulnerable_eating: InvulnerableEating,
pub living_flags_drive_use: bool,
pub cooldown_reset: CooldownReset,
pub item_cooldowns: ItemCooldownRules,
pub pick_head_yaw: bool,
pub legacy_pick_block: bool,
pub sends_swing: bool,
pub teleport_confirm_pose: bool,
pub dig_change_direction: bool,
pub creative_attack_dig_delay: bool,
pub sends_punch: bool,
pub boss_bars: bool,
pub sign_editor: crate::sign::SignRules,
pub book: crate::book::BookRules,
pub sleep_levels_pitch: bool,
}
const fn f(v: f32) -> f64 {
v as f64
}
pub(crate) const V1_12_1: Capabilities = Capabilities {
version: GameVersion::V1_12_1,
protocol: 338,
..V1_12_2
};
pub(crate) const V1_16_2: Capabilities = Capabilities {
version: GameVersion::V1_16_2,
protocol: 751,
..V1_16_5
};
pub(crate) const V1_16_3: Capabilities = Capabilities {
version: GameVersion::V1_16_3,
protocol: 753,
..V1_16_5
};
pub(crate) const V1_8_9: Capabilities = Capabilities {
version: GameVersion::V1_8_9,
protocol: 47,
physics: PhysicsRules::V1_8,
data: DataSet::V1_8,
item_model: ItemModel::LegacyNbt,
combat_1_9: false,
entity_pick_root_vehicle: false,
eye_height: f(1.62),
sneak_eye_height: f(1.62 - 0.08),
chat_limit: 100,
own_inventory_passes_keys: false,
immediate_respawn_rule: false,
seed_planting_prediction: false,
teleport_confirm: false,
window_confirm: true,
configuration_state: false,
sneak_via_player_input: false,
sends_tick_end: false,
player_loaded_gate: false,
chunk_batch_ack: false,
block_sequence: false,
chat_acknowledgements: false,
client_entity_push: false,
drop_prediction: false,
spectator_block_click_swings: true,
spectator_switch_stops_use: false,
attack_knockback_enchantment: true,
use_equip_swings: false,
use_stop: UseStop::HeldReplaced,
creative_instant_dig: true,
invulnerable_eating: InvulnerableEating::Never,
living_flags_drive_use: false,
cooldown_reset: CooldownReset::AtSelect,
item_cooldowns: ItemCooldownRules::None,
pick_head_yaw: true,
legacy_pick_block: true,
sends_swing: true,
teleport_confirm_pose: false,
dig_change_direction: false,
creative_attack_dig_delay: false,
sends_punch: false,
boss_bars: false,
sign_editor: crate::sign::SignRules::Legacy { json: true },
book: crate::book::BookRules::Legacy18,
sleep_levels_pitch: false,
};
pub(crate) const V1_12_2: Capabilities = Capabilities {
version: GameVersion::V1_12_2,
protocol: 340,
physics: PhysicsRules::V1_12,
data: DataSet::V1_12,
combat_1_9: true,
entity_pick_root_vehicle: true,
chat_limit: 256,
seed_planting_prediction: false,
teleport_confirm: true,
client_entity_push: true,
living_flags_drive_use: true,
cooldown_reset: CooldownReset::ItemAndDamage,
item_cooldowns: ItemCooldownRules::PerItem,
pick_head_yaw: false,
boss_bars: true,
sign_editor: crate::sign::SignRules::Legacy { json: false },
book: crate::book::BookRules::Legacy112,
..V1_8_9
};
pub(crate) const V1_16_5: Capabilities = Capabilities {
version: GameVersion::V1_16_5,
protocol: 754,
own_inventory_passes_keys: true,
physics: PhysicsRules::V1_16_5,
data: DataSet::V1_16_5,
item_model: ItemModel::FlatNbt,
sneak_eye_height: f(1.27),
immediate_respawn_rule: true,
client_entity_push: true,
drop_prediction: true,
use_equip_swings: true,
invulnerable_eating: InvulnerableEating::Always,
use_stop: UseStop::HeldItemChanged,
cooldown_reset: CooldownReset::Item,
pick_head_yaw: false,
sign_editor: crate::sign::SignRules::FirstTickCheck,
book: crate::book::BookRules::Stack116,
sleep_levels_pitch: true,
..V1_12_2
};
pub(crate) const V26_1: Capabilities = Capabilities {
version: GameVersion::V26_1,
protocol: 775,
own_inventory_passes_keys: false,
physics: PhysicsRules::Modern26_1,
data: DataSet::V26_1,
item_model: ItemModel::Components,
window_confirm: false,
configuration_state: true,
sneak_via_player_input: true,
sends_tick_end: true,
player_loaded_gate: true,
chunk_batch_ack: true,
block_sequence: true,
chat_acknowledgements: true,
client_entity_push: true,
spectator_block_click_swings: false,
spectator_switch_stops_use: true,
attack_knockback_enchantment: false,
creative_instant_dig: true,
invulnerable_eating: InvulnerableEating::Hunger,
living_flags_drive_use: false,
cooldown_reset: CooldownReset::AtSelect,
item_cooldowns: ItemCooldownRules::Groups,
pick_head_yaw: false,
use_stop: UseStop::AtSelect,
legacy_pick_block: false,
sign_editor: crate::sign::SignRules::Sided,
book: crate::book::BookRules::Pages,
..V1_16_5
};
pub(crate) const V26_2: Capabilities = Capabilities {
version: GameVersion::V26_2,
protocol: 776,
physics: PhysicsRules::Modern26_2,
data: DataSet::V26_2,
..V26_1
};
pub(crate) const V26_3: Capabilities = Capabilities {
version: GameVersion::V26_3,
protocol: 777,
physics: PhysicsRules::Modern26_3,
data: DataSet::V26_3,
sends_swing: false,
teleport_confirm_pose: true,
dig_change_direction: true,
creative_attack_dig_delay: true,
sends_punch: true,
..V26_2
};