1
2
Fork 0
mirror of https://github.com/mat-1/azalea.git synced 2025-08-02 23:44:38 +00:00
This commit is contained in:
mat 2025-01-20 00:15:12 +00:00
commit be10d5f94b
23 changed files with 1575 additions and 1051 deletions

42
Cargo.lock generated
View file

@ -208,7 +208,7 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
[[package]]
name = "azalea"
version = "0.11.0+mc25w02a"
version = "0.11.0+mc25w03a"
dependencies = [
"anyhow",
"azalea-auth",
@ -248,7 +248,7 @@ dependencies = [
[[package]]
name = "azalea-auth"
version = "0.11.0+mc25w02a"
version = "0.11.0+mc25w03a"
dependencies = [
"azalea-buf",
"azalea-crypto",
@ -268,7 +268,7 @@ dependencies = [
[[package]]
name = "azalea-block"
version = "0.11.0+mc25w02a"
version = "0.11.0+mc25w03a"
dependencies = [
"azalea-block-macros",
"azalea-buf",
@ -277,7 +277,7 @@ dependencies = [
[[package]]
name = "azalea-block-macros"
version = "0.11.0+mc25w02a"
version = "0.11.0+mc25w03a"
dependencies = [
"proc-macro2",
"quote",
@ -286,7 +286,7 @@ dependencies = [
[[package]]
name = "azalea-brigadier"
version = "0.11.0+mc25w02a"
version = "0.11.0+mc25w03a"
dependencies = [
"azalea-buf",
"azalea-chat",
@ -297,7 +297,7 @@ dependencies = [
[[package]]
name = "azalea-buf"
version = "0.11.0+mc25w02a"
version = "0.11.0+mc25w03a"
dependencies = [
"azalea-buf-macros",
"byteorder",
@ -310,7 +310,7 @@ dependencies = [
[[package]]
name = "azalea-buf-macros"
version = "0.11.0+mc25w02a"
version = "0.11.0+mc25w03a"
dependencies = [
"proc-macro2",
"quote",
@ -319,7 +319,7 @@ dependencies = [
[[package]]
name = "azalea-chat"
version = "0.11.0+mc25w02a"
version = "0.11.0+mc25w03a"
dependencies = [
"azalea-buf",
"azalea-language",
@ -332,7 +332,7 @@ dependencies = [
[[package]]
name = "azalea-client"
version = "0.11.0+mc25w02a"
version = "0.11.0+mc25w03a"
dependencies = [
"anyhow",
"azalea-auth",
@ -366,7 +366,7 @@ dependencies = [
[[package]]
name = "azalea-core"
version = "0.11.0+mc25w02a"
version = "0.11.0+mc25w03a"
dependencies = [
"azalea-buf",
"azalea-chat",
@ -381,7 +381,7 @@ dependencies = [
[[package]]
name = "azalea-crypto"
version = "0.11.0+mc25w02a"
version = "0.11.0+mc25w03a"
dependencies = [
"aes",
"azalea-buf",
@ -398,7 +398,7 @@ dependencies = [
[[package]]
name = "azalea-entity"
version = "0.11.0+mc25w02a"
version = "0.11.0+mc25w03a"
dependencies = [
"azalea-block",
"azalea-buf",
@ -421,7 +421,7 @@ dependencies = [
[[package]]
name = "azalea-inventory"
version = "0.11.0+mc25w02a"
version = "0.11.0+mc25w03a"
dependencies = [
"azalea-buf",
"azalea-chat",
@ -435,7 +435,7 @@ dependencies = [
[[package]]
name = "azalea-inventory-macros"
version = "0.11.0+mc25w02a"
version = "0.11.0+mc25w03a"
dependencies = [
"proc-macro2",
"quote",
@ -444,7 +444,7 @@ dependencies = [
[[package]]
name = "azalea-language"
version = "0.11.0+mc25w02a"
version = "0.11.0+mc25w03a"
dependencies = [
"serde",
"serde_json",
@ -452,7 +452,7 @@ dependencies = [
[[package]]
name = "azalea-physics"
version = "0.11.0+mc25w02a"
version = "0.11.0+mc25w03a"
dependencies = [
"azalea-block",
"azalea-core",
@ -470,7 +470,7 @@ dependencies = [
[[package]]
name = "azalea-protocol"
version = "0.11.0+mc25w02a"
version = "0.11.0+mc25w03a"
dependencies = [
"anyhow",
"async-recursion",
@ -505,7 +505,7 @@ dependencies = [
[[package]]
name = "azalea-protocol-macros"
version = "0.11.0+mc25w02a"
version = "0.11.0+mc25w03a"
dependencies = [
"proc-macro2",
"quote",
@ -514,7 +514,7 @@ dependencies = [
[[package]]
name = "azalea-registry"
version = "0.11.0+mc25w02a"
version = "0.11.0+mc25w03a"
dependencies = [
"azalea-buf",
"azalea-registry-macros",
@ -524,7 +524,7 @@ dependencies = [
[[package]]
name = "azalea-registry-macros"
version = "0.11.0+mc25w02a"
version = "0.11.0+mc25w03a"
dependencies = [
"quote",
"syn",
@ -532,7 +532,7 @@ dependencies = [
[[package]]
name = "azalea-world"
version = "0.11.0+mc25w02a"
version = "0.11.0+mc25w03a"
dependencies = [
"azalea-block",
"azalea-buf",

View file

@ -22,7 +22,7 @@ resolver = "2"
# --- Workspace Settings ---
[workspace.package]
version = "0.11.0+mc25w02a"
version = "0.11.0+mc25w03a"
edition = "2021"
license = "MIT"
repository = "https://github.com/azalea-rs/azalea"

View file

@ -11,7 +11,7 @@ A collection of Rust crates for making Minecraft bots, clients, and tools.
<!-- The line below is automatically read and updated by the migrate script, so don't change it manually. -->
_Currently supported Minecraft version: `25w02a`._
_Currently supported Minecraft version: `25w03a`._
> [!WARNING]
> Azalea is still unfinished, though most crates are in a useable state

View file

@ -1718,6 +1718,12 @@ make_block_states! {
NorthUp,
SouthUp,
},
"test_block_mode" => TestBlockMode {
Start,
Log,
Fail,
Accept,
},
"level" => ComposterLevel {
_0,
_1,
@ -4792,6 +4798,10 @@ make_block_states! {
jigsaw => BlockBehavior::new().requires_correct_tool_for_drops().strength(-1.0, 3600000.0), {
"orientation": Orientation::NorthUp,
},
test_block => BlockBehavior::new(), {
"test_block_mode": TestBlockMode::Start,
},
test_instance_block => BlockBehavior::new(), {},
composter => BlockBehavior::new().strength(0.6, 0.6), {
"level": ComposterLevel::_0,
},

View file

@ -1566,6 +1566,7 @@ pub fn process_packet_events(ecs: &mut World) {
ClientboundGamePacket::RecipeBookAdd(_) => {}
ClientboundGamePacket::RecipeBookRemove(_) => {}
ClientboundGamePacket::RecipeBookSettings(_) => {}
ClientboundGamePacket::TestInstanceBlockStatus(_) => {}
}
}
}

View file

@ -392,6 +392,18 @@ impl BlockPos {
}
}
/// Similar to [`BlockPos`] but it's serialized as 3 varints instead of one
/// 64-bit integer, so it can represent a bigger range of numbers.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, AzBuf)]
pub struct Vec3i {
#[var]
pub x: i32,
#[var]
pub y: i32,
#[var]
pub z: i32,
}
/// Chunk coordinates are used to represent where a chunk is in the world. You
/// can convert the x and z to block coordinates by multiplying them by 16.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]

View file

@ -1496,8 +1496,6 @@ pub struct Eating(pub bool);
pub struct AbstractHorseStanding(pub bool);
#[derive(Component, Deref, DerefMut, Clone, Copy)]
pub struct Bred(pub bool);
#[derive(Component, Deref, DerefMut, Clone, Copy)]
pub struct Saddled(pub bool);
#[derive(Component, Deref, DerefMut, Clone)]
pub struct Dash(pub bool);
#[derive(Component, Deref, DerefMut, Clone)]
@ -1584,7 +1582,6 @@ impl Default for CamelMetadataBundle {
eating: Eating(false),
abstract_horse_standing: AbstractHorseStanding(false),
bred: Bred(false),
saddled: Saddled(false),
},
dash: Dash(false),
last_pose_change_tick: LastPoseChangeTick(0),
@ -2710,7 +2707,6 @@ impl Default for DonkeyMetadataBundle {
eating: Eating(false),
abstract_horse_standing: AbstractHorseStanding(false),
bred: Bred(false),
saddled: Saddled(false),
},
chest: Chest(false),
},
@ -3485,6 +3481,8 @@ impl Default for ExperienceBottleMetadataBundle {
}
}
#[derive(Component, Deref, DerefMut, Clone)]
pub struct Value(pub i32);
#[derive(Component)]
pub struct ExperienceOrb;
impl ExperienceOrb {
@ -3494,6 +3492,9 @@ impl ExperienceOrb {
) -> Result<(), UpdateMetadataError> {
match d.index {
0..=7 => AbstractEntity::apply_metadata(entity, d)?,
8 => {
entity.insert(Value(d.value.into_int()?));
}
_ => {}
}
Ok(())
@ -3504,6 +3505,7 @@ impl ExperienceOrb {
pub struct ExperienceOrbMetadataBundle {
_marker: ExperienceOrb,
parent: AbstractEntityMetadataBundle,
value: Value,
}
impl Default for ExperienceOrbMetadataBundle {
fn default() -> Self {
@ -3526,6 +3528,7 @@ impl Default for ExperienceOrbMetadataBundle {
pose: Pose::default(),
ticks_frozen: TicksFrozen(Default::default()),
},
value: Value(0),
}
}
}
@ -4749,7 +4752,6 @@ impl Default for HorseMetadataBundle {
eating: Eating(false),
abstract_horse_standing: AbstractHorseStanding(false),
bred: Bred(false),
saddled: Saddled(false),
},
horse_type_variant: HorseTypeVariant(0),
}
@ -5542,7 +5544,6 @@ impl Default for LlamaMetadataBundle {
eating: Eating(false),
abstract_horse_standing: AbstractHorseStanding(false),
bred: Bred(false),
saddled: Saddled(false),
},
chest: Chest(false),
},
@ -5882,7 +5883,7 @@ impl Default for MinecartMetadataBundle {
}
#[derive(Component, Deref, DerefMut, Clone)]
pub struct MooshroomKind(pub String);
pub struct MooshroomKind(pub i32);
#[derive(Component)]
pub struct Mooshroom;
impl Mooshroom {
@ -5893,7 +5894,7 @@ impl Mooshroom {
match d.index {
0..=16 => Cow::apply_metadata(entity, d)?,
17 => {
entity.insert(MooshroomKind(d.value.into_string()?));
entity.insert(MooshroomKind(d.value.into_int()?));
}
_ => {}
}
@ -6041,7 +6042,6 @@ impl Default for MuleMetadataBundle {
eating: Eating(false),
abstract_horse_standing: AbstractHorseStanding(false),
bred: Bred(false),
saddled: Saddled(false),
},
chest: Chest(false),
},
@ -6744,8 +6744,6 @@ impl Default for PhantomMetadataBundle {
}
}
#[derive(Component, Deref, DerefMut, Clone)]
pub struct PigSaddle(pub bool);
#[derive(Component, Deref, DerefMut, Clone)]
pub struct PigBoostTime(pub i32);
#[derive(Component, Deref, DerefMut, Clone)]
@ -6760,12 +6758,9 @@ impl Pig {
match d.index {
0..=16 => AbstractAnimal::apply_metadata(entity, d)?,
17 => {
entity.insert(PigSaddle(d.value.into_boolean()?));
}
18 => {
entity.insert(PigBoostTime(d.value.into_int()?));
}
19 => {
18 => {
entity.insert(PigVariant(d.value.into_pig_variant()?));
}
_ => {}
@ -6778,7 +6773,6 @@ impl Pig {
pub struct PigMetadataBundle {
_marker: Pig,
parent: AbstractAnimalMetadataBundle,
pig_saddle: PigSaddle,
pig_boost_time: PigBoostTime,
pig_variant: PigVariant,
}
@ -6830,7 +6824,6 @@ impl Default for PigMetadataBundle {
abstract_ageable_baby: AbstractAgeableBaby(false),
},
},
pig_saddle: PigSaddle(false),
pig_boost_time: PigBoostTime(0),
pig_variant: PigVariant(Default::default()),
}
@ -8045,7 +8038,6 @@ impl Default for SkeletonHorseMetadataBundle {
eating: Eating(false),
abstract_horse_standing: AbstractHorseStanding(false),
bred: Bred(false),
saddled: Saddled(false),
},
}
}
@ -8818,8 +8810,6 @@ impl Default for StrayMetadataBundle {
pub struct StriderBoostTime(pub i32);
#[derive(Component, Deref, DerefMut, Clone)]
pub struct Suffocating(pub bool);
#[derive(Component, Deref, DerefMut, Clone)]
pub struct StriderSaddle(pub bool);
#[derive(Component)]
pub struct Strider;
impl Strider {
@ -8835,9 +8825,6 @@ impl Strider {
18 => {
entity.insert(Suffocating(d.value.into_boolean()?));
}
19 => {
entity.insert(StriderSaddle(d.value.into_boolean()?));
}
_ => {}
}
Ok(())
@ -8850,7 +8837,6 @@ pub struct StriderMetadataBundle {
parent: AbstractAnimalMetadataBundle,
strider_boost_time: StriderBoostTime,
suffocating: Suffocating,
strider_saddle: StriderSaddle,
}
impl Default for StriderMetadataBundle {
fn default() -> Self {
@ -8902,7 +8888,6 @@ impl Default for StriderMetadataBundle {
},
strider_boost_time: StriderBoostTime(0),
suffocating: Suffocating(false),
strider_saddle: StriderSaddle(false),
}
}
}
@ -9294,7 +9279,6 @@ impl Default for TraderLlamaMetadataBundle {
eating: Eating(false),
abstract_horse_standing: AbstractHorseStanding(false),
bred: Bred(false),
saddled: Saddled(false),
},
chest: Chest(false),
},
@ -9442,7 +9426,7 @@ impl Default for TropicalFishMetadataBundle {
},
abstract_fish_from_bucket: AbstractFishFromBucket(false),
},
tropical_fish_type_variant: TropicalFishTypeVariant(0),
tropical_fish_type_variant: TropicalFishTypeVariant(Default::default()),
}
}
}
@ -10620,7 +10604,6 @@ impl Default for ZombieHorseMetadataBundle {
eating: Eating(false),
abstract_horse_standing: AbstractHorseStanding(false),
bred: Bred(false),
saddled: Saddled(false),
},
}
}
@ -11139,7 +11122,6 @@ impl Default for AbstractChestedHorseMetadataBundle {
eating: Eating(false),
abstract_horse_standing: AbstractHorseStanding(false),
bred: Bred(false),
saddled: Saddled(false),
},
chest: Chest(false),
}
@ -11519,7 +11501,6 @@ impl AbstractHorse {
entity.insert(Eating(bitfield & 0x10 != 0));
entity.insert(AbstractHorseStanding(bitfield & 0x20 != 0));
entity.insert(Bred(bitfield & 0x8 != 0));
entity.insert(Saddled(bitfield & 0x4 != 0));
}
_ => {}
}
@ -11535,7 +11516,6 @@ pub struct AbstractHorseMetadataBundle {
eating: Eating,
abstract_horse_standing: AbstractHorseStanding,
bred: Bred,
saddled: Saddled,
}
impl Default for AbstractHorseMetadataBundle {
fn default() -> Self {
@ -11589,7 +11569,6 @@ impl Default for AbstractHorseMetadataBundle {
eating: Eating(false),
abstract_horse_standing: AbstractHorseStanding(false),
bred: Bred(false),
saddled: Saddled(false),
}
}
}

View file

@ -5,8 +5,8 @@ use azalea_buf::{AzBuf, AzaleaRead, AzaleaWrite, BufReadError};
use azalea_chat::FormattedText;
use azalea_core::{position::GlobalPos, resource_location::ResourceLocation};
use azalea_registry::{
Attribute, Block, ConsumeEffectKind, DataComponentKind, Enchantment, EntityKind, HolderSet,
Item, MobEffect, Potion, SoundEvent, TrimMaterial, TrimPattern,
self as registry, Attribute, Block, ConsumeEffectKind, DataComponentKind, Enchantment,
EntityKind, HolderSet, Item, MobEffect, Potion, SoundEvent, TrimMaterial, TrimPattern,
};
use simdnbt::owned::{Nbt, NbtCompound};
use uuid::Uuid;
@ -48,7 +48,7 @@ where
}
pub fn from_kind(
kind: azalea_registry::DataComponentKind,
kind: registry::DataComponentKind,
buf: &mut Cursor<&[u8]>,
) -> Result<Box<dyn EncodableDataComponent>, BufReadError> {
// if this is causing a compile-time error, look at DataComponents.java in the
@ -135,6 +135,31 @@ pub fn from_kind(
DataComponentKind::DeathProtection => Box::new(DeathProtection::azalea_read(buf)?),
DataComponentKind::Weapon => Box::new(Weapon::azalea_read(buf)?),
DataComponentKind::PotionDurationScale => Box::new(PotionDurationScale::azalea_read(buf)?),
DataComponentKind::VillagerVariant => Box::new(VillagerVariant::azalea_read(buf)?),
DataComponentKind::WolfVariant => Box::new(WolfVariant::azalea_read(buf)?),
DataComponentKind::WolfCollar => Box::new(WolfCollar::azalea_read(buf)?),
DataComponentKind::FoxVariant => Box::new(FoxVariant::azalea_read(buf)?),
DataComponentKind::SalmonSize => Box::new(SalmonSize::azalea_read(buf)?),
DataComponentKind::ParrotVariant => Box::new(ParrotVariant::azalea_read(buf)?),
DataComponentKind::TropicalFishPattern => Box::new(TropicalFishPattern::azalea_read(buf)?),
DataComponentKind::TropicalFishBaseColor => {
Box::new(TropicalFishBaseColor::azalea_read(buf)?)
}
DataComponentKind::TropicalFishPatternColor => {
Box::new(TropicalFishPatternColor::azalea_read(buf)?)
}
DataComponentKind::MooshroomVariant => Box::new(MooshroomVariant::azalea_read(buf)?),
DataComponentKind::RabbitVariant => Box::new(RabbitVariant::azalea_read(buf)?),
DataComponentKind::PigVariant => Box::new(PigVariant::azalea_read(buf)?),
DataComponentKind::FrogVariant => Box::new(FrogVariant::azalea_read(buf)?),
DataComponentKind::HorseVariant => Box::new(HorseVariant::azalea_read(buf)?),
DataComponentKind::PaintingVariant => Box::new(PaintingVariant::azalea_read(buf)?),
DataComponentKind::LlamaVariant => Box::new(LlamaVariant::azalea_read(buf)?),
DataComponentKind::AxolotlVariant => Box::new(AxolotlVariant::azalea_read(buf)?),
DataComponentKind::CatVariant => Box::new(CatVariant::azalea_read(buf)?),
DataComponentKind::CatCollar => Box::new(CatCollar::azalea_read(buf)?),
DataComponentKind::SheepColor => Box::new(SheepColor::azalea_read(buf)?),
DataComponentKind::ShulkerColor => Box::new(ShulkerColor::azalea_read(buf)?),
})
}
@ -592,7 +617,7 @@ impl DataComponent for BlockEntityData {
#[derive(Clone, PartialEq, AzBuf)]
pub struct Instrument {
pub instrument: azalea_registry::Instrument,
pub instrument: registry::Instrument,
}
impl DataComponent for Instrument {
const KIND: DataComponentKind = DataComponentKind::Instrument;
@ -783,7 +808,7 @@ impl DataComponent for ContainerLoot {
#[derive(Clone, PartialEq, AzBuf)]
pub struct JukeboxPlayable {
pub song: azalea_registry::JukeboxSong,
pub song: registry::JukeboxSong,
pub show_in_tooltip: bool,
}
impl DataComponent for JukeboxPlayable {
@ -941,3 +966,184 @@ pub struct PotionDurationScale {
impl DataComponent for PotionDurationScale {
const KIND: DataComponentKind = DataComponentKind::PotionDurationScale;
}
#[derive(Clone, PartialEq, AzBuf)]
pub struct VillagerVariant {
pub variant: registry::VillagerKind,
}
impl DataComponent for VillagerVariant {
const KIND: DataComponentKind = DataComponentKind::VillagerVariant;
}
#[derive(Clone, PartialEq, AzBuf)]
pub struct WolfVariant {
pub variant: registry::WolfVariant,
}
impl DataComponent for WolfVariant {
const KIND: DataComponentKind = DataComponentKind::WolfVariant;
}
#[derive(Clone, PartialEq, AzBuf)]
pub struct WolfCollar {
pub color: DyeColor,
}
impl DataComponent for WolfCollar {
const KIND: DataComponentKind = DataComponentKind::WolfCollar;
}
#[derive(Clone, PartialEq, AzBuf)]
pub struct FoxVariant {
pub variant: registry::FoxVariant,
}
impl DataComponent for FoxVariant {
const KIND: DataComponentKind = DataComponentKind::FoxVariant;
}
#[derive(Clone, Copy, PartialEq, AzBuf)]
pub enum SalmonSize {
Small,
Medium,
Large,
}
impl DataComponent for SalmonSize {
const KIND: DataComponentKind = DataComponentKind::SalmonSize;
}
#[derive(Clone, PartialEq, AzBuf)]
pub struct ParrotVariant {
pub variant: registry::ParrotVariant,
}
impl DataComponent for ParrotVariant {
const KIND: DataComponentKind = DataComponentKind::ParrotVariant;
}
#[derive(Clone, Copy, PartialEq, AzBuf)]
pub enum TropicalFishPattern {
Kob,
Sunstreak,
Snooper,
Dasher,
Brinely,
Spotty,
Flopper,
Stripey,
Glitter,
Blockfish,
Betty,
Clayfish,
}
impl DataComponent for TropicalFishPattern {
const KIND: DataComponentKind = DataComponentKind::TropicalFishPattern;
}
#[derive(Clone, PartialEq, AzBuf)]
pub struct TropicalFishBaseColor {
pub color: DyeColor,
}
impl DataComponent for TropicalFishBaseColor {
const KIND: DataComponentKind = DataComponentKind::TropicalFishBaseColor;
}
#[derive(Clone, PartialEq, AzBuf)]
pub struct TropicalFishPatternColor {
pub color: DyeColor,
}
impl DataComponent for TropicalFishPatternColor {
const KIND: DataComponentKind = DataComponentKind::TropicalFishPatternColor;
}
#[derive(Clone, PartialEq, AzBuf)]
pub struct MooshroomVariant {
pub variant: registry::MooshroomVariant,
}
impl DataComponent for MooshroomVariant {
const KIND: DataComponentKind = DataComponentKind::MooshroomVariant;
}
#[derive(Clone, PartialEq, AzBuf)]
pub struct RabbitVariant {
pub variant: registry::RabbitVariant,
}
impl DataComponent for RabbitVariant {
const KIND: DataComponentKind = DataComponentKind::RabbitVariant;
}
#[derive(Clone, PartialEq, AzBuf)]
pub struct PigVariant {
pub variant: registry::PigVariant,
}
impl DataComponent for PigVariant {
const KIND: DataComponentKind = DataComponentKind::PigVariant;
}
#[derive(Clone, PartialEq, AzBuf)]
pub struct FrogVariant {
pub variant: registry::FrogVariant,
}
impl DataComponent for FrogVariant {
const KIND: DataComponentKind = DataComponentKind::FrogVariant;
}
#[derive(Clone, PartialEq, AzBuf)]
pub struct HorseVariant {
pub variant: registry::HorseVariant,
}
impl DataComponent for HorseVariant {
const KIND: DataComponentKind = DataComponentKind::HorseVariant;
}
#[derive(Clone, PartialEq, AzBuf)]
pub struct PaintingVariant {
pub variant: registry::PaintingVariant,
}
impl DataComponent for PaintingVariant {
const KIND: DataComponentKind = DataComponentKind::PaintingVariant;
}
#[derive(Clone, PartialEq, AzBuf)]
pub struct LlamaVariant {
pub variant: registry::LlamaVariant,
}
impl DataComponent for LlamaVariant {
const KIND: DataComponentKind = DataComponentKind::LlamaVariant;
}
#[derive(Clone, PartialEq, AzBuf)]
pub struct AxolotlVariant {
pub variant: registry::AxolotlVariant,
}
impl DataComponent for AxolotlVariant {
const KIND: DataComponentKind = DataComponentKind::AxolotlVariant;
}
#[derive(Clone, PartialEq, AzBuf)]
pub struct CatVariant {
pub variant: registry::CatVariant,
}
impl DataComponent for CatVariant {
const KIND: DataComponentKind = DataComponentKind::CatVariant;
}
#[derive(Clone, PartialEq, AzBuf)]
pub struct CatCollar {
pub color: DyeColor,
}
impl DataComponent for CatCollar {
const KIND: DataComponentKind = DataComponentKind::CatCollar;
}
#[derive(Clone, PartialEq, AzBuf)]
pub struct SheepColor {
pub color: DyeColor,
}
impl DataComponent for SheepColor {
const KIND: DataComponentKind = DataComponentKind::SheepColor;
}
#[derive(Clone, PartialEq, AzBuf)]
pub struct ShulkerColor {
pub color: DyeColor,
}
impl DataComponent for ShulkerColor {
const KIND: DataComponentKind = DataComponentKind::ShulkerColor;
}

View file

@ -374,6 +374,7 @@
"argument.range.swapped": "Min cannot be bigger than max",
"argument.resource_or_id.failed_to_parse": "Failed to parse structure: %s",
"argument.resource_or_id.invalid": "Invalid id or tag",
"argument.resource_selector.not_found": "No matches for selector '%s' of type '%s'",
"argument.resource_tag.invalid_type": "Tag '%s' has wrong type '%s' (expected '%s')",
"argument.resource_tag.not_found": "Can't find tag '%s' of type '%s'",
"argument.resource.invalid_type": "Element '%s' has wrong type '%s' (expected '%s')",
@ -2198,6 +2199,8 @@
"block.minecraft.tall_seagrass": "Tall Seagrass",
"block.minecraft.target": "Target",
"block.minecraft.terracotta": "Terracotta",
"block.minecraft.test_block": "Test Block",
"block.minecraft.test_instance_block": "Test Instance Block",
"block.minecraft.tinted_glass": "Tinted Glass",
"block.minecraft.tnt": "TNT",
"block.minecraft.torch": "Torch",
@ -2850,6 +2853,27 @@
"commands.teleport.success.entity.single": "Teleported %s to %s",
"commands.teleport.success.location.multiple": "Teleported %s entities to %s, %s, %s",
"commands.teleport.success.location.single": "Teleported %s to %s, %s, %s",
"commands.test.batch.starting": "Starting environment %s batch %s",
"commands.test.clear.error.no_tests": "Could not find any tests to clear",
"commands.test.clear.success": "Cleared %s structures",
"commands.test.coordinates": "%s, %s, %s",
"commands.test.coordinates.copy": "Click to copy to clipboard",
"commands.test.error.no_test_containing_pos": "Can't find a test instance that contains %s, %s, %s",
"commands.test.error.no_test_instances": "Found no test instances",
"commands.test.error.non_existant_test": "Test %s could not be found",
"commands.test.error.structure_not_found": "Test structure %s could not be found",
"commands.test.error.test_instance_not_found": "Test instance block entity could not be found",
"commands.test.error.test_instance_not_found.position": "Test instance block entity could not be found for test at %s, %s, %s",
"commands.test.locate.done": "Finished locating, found %s structure(s)",
"commands.test.locate.found": "Found structure at: %s (distance: %s)",
"commands.test.locate.started": "Started locating test structures, this might take a while...",
"commands.test.relative_position": "Position relative to %s: %s",
"commands.test.run.no_tests": "No tests found",
"commands.test.run.running": "Running %s tests...",
"commands.test.summary": "Game Test complete! %s tests were run",
"commands.test.summary.all_required_passed": "All required tests passed :)",
"commands.test.summary.failed": "%s required tests failed :(",
"commands.test.summary.optional_failed": "%s optional tests failed",
"commands.tick.query.percentiles": "Percentiles: P50: %sms P95: %sms P99: %sms, sample: %s",
"commands.tick.query.rate.running": "Target tick rate: %s per second.\nAverage time per tick: %sms (Target: %sms)",
"commands.tick.query.rate.sprinting": "Target tick rate: %s per second (ignored, reference only).\nAverage time per tick: %sms",
@ -6936,6 +6960,75 @@
"telemetry.property.user_id.title": "User ID",
"telemetry.property.world_load_time_ms.title": "World Load Time (Milliseconds)",
"telemetry.property.world_session_id.title": "World Session ID",
"test_block.error.missing": "Test structure missing %s block",
"test_block.error.too_many": "Too many %s blocks",
"test_block.invalid_timeout": "Invalid timeout (%s) - must be a positive number of ticks",
"test_block.message": "Message:",
"test_block.mode_info.accept": "Accept Mode - Accept success for (part of) a test",
"test_block.mode_info.fail": "Fail Mode - Fail the test",
"test_block.mode_info.log": "Log Mode - Log a message",
"test_block.mode_info.start": "Start Mode - The starting point for a test",
"test_block.mode.accept": "Accept",
"test_block.mode.fail": "Fail",
"test_block.mode.log": "Log",
"test_block.mode.start": "Start",
"test_instance_block.entities": "Entities:",
"test_instance_block.error.no_test": "Unable to run test instance at %s, %s, %s since it has defined test",
"test_instance_block.error.unable_to_save": "Unable to save test structure template for test instance at %s, %s, %s",
"test_instance_block.invalid": "[invalid]",
"test_instance_block.reset_success": "Reset succeded for test: %s",
"test_instance_block.rotation": "Rotation:",
"test_instance_block.size": "Test Structure Size",
"test_instance_block.starting": "Starting test %s",
"test_instance_block.test_id": "Test Instance ID",
"test_instance.description.batch": "Batch: %s",
"test_instance.description.failed": "Failed: %s",
"test_instance.description.function": "Function: %s",
"test_instance.description.no_test": "No such test",
"test_instance.description.structure": "Structure: %s",
"test_instance.description.type": "Type: %s",
"test_instance.type.block_based": "Block-Based Test",
"test_instance.type.function": "Built-in Function Test",
"test.error.block_property_mismatch": "Expected property %s to be %s, was %s",
"test.error.block_property_missing": "Block property missing, expected property %s to be %s",
"test.error.entity_property": "Entity %s failed test: %s",
"test.error.entity_property_details": "Entity %s failed test: %s, expected: %s, was: %s",
"test.error.expected_block": "Expected block %s, got %s",
"test.error.expected_block_tag": "Expected block in #%s, got %s",
"test.error.expected_container_contents": "Container should contain: %s",
"test.error.expected_container_contents_single": "Container should contain a single: %s",
"test.error.expected_empty_container": "Container should be empty",
"test.error.expected_entity": "Expected %s",
"test.error.expected_entity_around": "Expected %s to exist around %s, %s, %s",
"test.error.expected_entity_count": "Expected %s entities of type %s, found %s",
"test.error.expected_entity_data": "Expected entity data to be: %s, was: %s",
"test.error.expected_entity_data_predicate": "Entity data mismatch for %s",
"test.error.expected_entity_effect": "Expected %s to have effect %s %s",
"test.error.expected_entity_having": "Entity inventory should contain %s",
"test.error.expected_entity_holding": "Entity should be holding %s",
"test.error.expected_entity_in_test": "Expected %s to exist in test",
"test.error.expected_entity_not_touching": "Did not expect %s touching %s, %s, %s (relative: %s, %s, %s)",
"test.error.expected_entity_touching": "Expected %s touching %s, %s, %s (relative: %s, %s, %s)",
"test.error.expected_item": "Expected item of type %s",
"test.error.expected_items_count": "Expected %s items of type %s, found %s",
"test.error.fail": "Fail conditions met",
"test.error.invalid_block_type": "Unexpected block type found: %s",
"test.error.missing_block_entity": "Missing block entity",
"test.error.position": "%s at %s, %s, %s (relative: %s, %s, %s) on tick %s",
"test.error.sequence.condition_already_triggered": "Condition already triggered at %s",
"test.error.sequence.condition_not_triggered": "Condition not triggered",
"test.error.sequence.invalid_tick": "Succeeded in invalid tick: expected %s",
"test.error.sequence.not_completed": "Test timed out before sequence completed",
"test.error.set_biome": "Failed to set biome for test",
"test.error.spawn_failure": "Failed to create entity %s",
"test.error.state_not_equal": "Incorrect state. Expected %s, was %s",
"test.error.tick": "%s on tick %s",
"test.error.too_many_entities": "Expected only one %s to exist around %s, %s, %s but found %s",
"test.error.unexpected_block": "Did not expect block to be %s",
"test.error.unexpected_entity": "Did not expect %s to exist",
"test.error.unexpected_item": "Did not expect item of type %s",
"test.error.value_not_equal": "Expected %s to be %s, was %s",
"test.error.wrong_block_entity": "Wrong block entity type: %s",
"title.32bit.deprecation": "32-bit system detected: this may prevent you from playing in the future as a 64-bit system will be required!",
"title.32bit.deprecation.realms": "Minecraft will soon require a 64-bit system, which will prevent you from playing or using Realms on this device. You will need to manually cancel any Realms subscription.",
"title.32bit.deprecation.realms.check": "Do not show this screen again",

File diff suppressed because it is too large Load diff

View file

@ -91,6 +91,7 @@ pub enum BrigadierString {
GreedyPhrase = 2,
}
// see ArgumentTypeInfo
#[derive(Debug, Clone, AzBuf, PartialEq)]
pub enum BrigadierParser {
Bool,
@ -140,6 +141,7 @@ pub enum BrigadierParser {
ResourceOrTagKey { registry_key: ResourceLocation },
Resource { registry_key: ResourceLocation },
ResourceKey { registry_key: ResourceLocation },
ResourceSelector { registry_key: ResourceLocation },
TemplateMirror,
TemplateRotation,
Heightmap,
@ -182,7 +184,7 @@ impl AzaleaRead for BrigadierNodeStub {
fn azalea_read(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> {
let flags = FixedBitSet::<{ 8_usize.div_ceil(8) }>::azalea_read(buf)?;
if flags.index(5) || flags.index(6) || flags.index(7) {
warn!("Warning: The flags from a Brigadier node are over 31. This is probably a bug.",);
warn!("The flags from a Brigadier node are over 31. This is a bug, BrigadierParser probably needs updating.",);
}
let node_type = u8::from(flags.index(0)) + (u8::from(flags.index(1)) * 2);

View file

@ -0,0 +1,10 @@
use azalea_buf::AzBuf;
use azalea_chat::FormattedText;
use azalea_core::position::Vec3;
use azalea_protocol_macros::ClientboundGamePacket;
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
pub struct ClientboundTestInstanceBlockStatus {
pub status: FormattedText,
pub size: Option<Vec3>,
}

View file

@ -13,6 +13,7 @@ pub struct ClientboundUpdateAdvancements {
pub added: Vec<AdvancementHolder>,
pub removed: Vec<ResourceLocation>,
pub progress: HashMap<ResourceLocation, AdvancementProgress>,
pub show_advancements: bool,
}
#[derive(Clone, Debug, AzBuf)]

View file

@ -124,17 +124,18 @@ declare_state_packets!(GamePacket,
tag_query, // 0x74
take_item_entity, // 0x75
teleport_entity, // 0x76
ticking_state, // 0x77
ticking_step, // 0x78
transfer, // 0x79
update_advancements, // 0x7A
update_attributes, // 0x7B
update_mob_effect, // 0x7C
update_recipes, // 0x7D
update_tags, // 0x7E
projectile_power, // 0x7F
custom_report_details, // 0x80
server_links, // 0x81
test_instance_block_status, // 0x77
ticking_state, // 0x78
ticking_step, // 0x79
transfer, // 0x7A
update_advancements, // 0x7B
update_attributes, // 0x7C
update_mob_effect, // 0x7D
update_recipes, // 0x7E
update_tags, // 0x7F
projectile_power, // 0x80
custom_report_details, // 0x81
server_links, // 0x82
],
Serverbound => [
accept_teleportation, // 0x00
@ -194,10 +195,12 @@ declare_state_packets!(GamePacket,
set_creative_mode_slot, // 0x36
set_jigsaw_block, // 0x37
set_structure_block, // 0x38
sign_update, // 0x39
swing, // 0x3A
teleport_to_entity, // 0x3B
use_item_on, // 0x3C
use_item, // 0x3D
set_test_block, // 0x39
sign_update, // 0x3A
swing, // 0x3B
teleport_to_entity, // 0x3C
test_instance_block_action, // 0x3D
use_item_on, // 0x3E
use_item, // 0x3F
]
);

View file

@ -47,15 +47,17 @@ pub enum StructureMode {
Data = 3,
}
#[derive(AzBuf, Clone, Copy, Debug)]
#[derive(AzBuf, Clone, Copy, Debug, Default)]
pub enum Mirror {
#[default]
None = 0,
LeftRight = 1,
FrontBack = 2,
}
#[derive(AzBuf, Clone, Copy, Debug)]
#[derive(AzBuf, Clone, Copy, Debug, Default)]
pub enum Rotation {
#[default]
None = 0,
Clockwise90 = 1,
Clockwise180 = 2,

View file

@ -0,0 +1,19 @@
use azalea_buf::AzBuf;
use azalea_core::position::BlockPos;
use azalea_protocol_macros::ServerboundGamePacket;
#[derive(Clone, Debug, AzBuf, ServerboundGamePacket)]
pub struct ServerboundSetTestBlock {
pub position: BlockPos,
pub mode: TestBlockMode,
pub message: String,
}
#[derive(Clone, Copy, Debug, AzBuf, Default)]
pub enum TestBlockMode {
#[default]
Start,
Log,
Fail,
Accept,
}

View file

@ -0,0 +1,44 @@
use azalea_buf::AzBuf;
use azalea_chat::FormattedText;
use azalea_core::position::{BlockPos, Vec3i};
use azalea_protocol_macros::ServerboundGamePacket;
use azalea_registry::TestInstanceKind;
use super::s_set_structure_block::Rotation;
#[derive(Clone, Debug, AzBuf, ServerboundGamePacket)]
pub struct ServerboundTestInstanceBlockAction {
pub pos: BlockPos,
pub action: Action,
pub data: TestInstanceBlockEntityData,
}
#[derive(Clone, Copy, Debug, AzBuf, Default)]
pub enum Action {
#[default]
Init,
Qurey,
Set,
Reset,
Save,
Export,
Run,
}
#[derive(Clone, Debug, AzBuf, Default)]
pub struct TestInstanceBlockEntityData {
pub test: Option<TestInstanceKind>,
pub size: Vec3i,
pub rotation: Rotation,
pub ignore_entities: bool,
pub status: TestInstanceBlockEntityStatus,
pub error_message: Option<FormattedText>,
}
#[derive(Clone, Copy, Debug, AzBuf, Default)]
pub enum TestInstanceBlockEntityStatus {
#[default]
Cleared,
Running,
Finished,
}

View file

@ -11,8 +11,8 @@ use azalea_buf::{AzaleaReadVar, AzaleaWrite, AzaleaWriteVar, BufReadError};
use crate::read::ReadPacketError;
pub const PROTOCOL_VERSION: i32 = 1073742053;
pub const VERSION_NAME: &str = "25w02a";
pub const PROTOCOL_VERSION: i32 = 1073742054;
pub const VERSION_NAME: &str = "25w03a";
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum ConnectionProtocol {

View file

@ -8,24 +8,28 @@ use syn::{
Attribute, Ident, LitStr, Token,
};
struct RegistryItem {
name: Ident,
id: String,
}
struct Registry {
name: Ident,
items: Vec<RegistryItem>,
attributes: Vec<Attribute>,
attrs: Vec<Attribute>,
}
struct RegistryItem {
attrs: Vec<Attribute>,
name: Ident,
id: String,
}
impl Parse for RegistryItem {
// Air => "minecraft:air"
fn parse(input: ParseStream) -> Result<Self> {
// parse annotations like #[default]
let attrs = input.call(Attribute::parse_outer).unwrap_or_default();
let name = input.parse()?;
input.parse::<Token![=>]>()?;
let id = input.parse::<LitStr>()?.value();
Ok(RegistryItem { name, id })
Ok(RegistryItem { attrs, name, id })
}
}
@ -37,7 +41,7 @@ impl Parse for Registry {
// }
// this also includes docs
let attributes = input.call(Attribute::parse_outer).unwrap_or_default();
let attrs = input.call(Attribute::parse_outer).unwrap_or_default();
input.parse::<Token![enum]>()?;
let name = input.parse()?;
@ -49,7 +53,7 @@ impl Parse for Registry {
Ok(Registry {
name,
items: items.into_iter().collect(),
attributes,
attrs,
})
}
}
@ -66,13 +70,15 @@ pub fn registry(input: TokenStream) -> TokenStream {
// }
let mut enum_items = quote! {};
for (i, item) in input.items.iter().enumerate() {
let attrs = &item.attrs;
let name = &item.name;
let protocol_id = i as u32;
enum_items.extend(quote! {
#(#attrs)*
#name = #protocol_id,
});
}
let attributes = input.attributes;
let attributes = input.attrs;
generated.extend(quote! {
#(#attributes)*
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, azalea_buf::AzBuf, simdnbt::ToNbtTag, simdnbt::FromNbtTag)]

View file

@ -7,7 +7,9 @@ use azalea_registry_macros::registry;
use crate::Registry;
registry! {
#[derive(Default)]
enum WolfVariant {
#[default]
Pale => "minecraft:wolf",
Spotted => "minecraft:wolf_spotted",
Snowy => "minecraft:wolf_snowy",
@ -20,26 +22,93 @@ enum WolfVariant {
}
}
#[allow(clippy::derivable_impls)]
impl Default for WolfVariant {
fn default() -> Self {
WolfVariant::Pale
}
}
registry! {
#[derive(Default)]
enum PigVariant {
#[default]
Temperate => "minecraft:pig",
Warm => "minecraft:warm_pig",
Cold => "minecraft:cold_pig",
}
}
#[allow(clippy::derivable_impls)]
impl Default for PigVariant {
fn default() -> Self {
PigVariant::Temperate
}
registry! {
#[derive(Default)]
enum FoxVariant {
#[default]
Red => "minecraft:red",
Snow => "minecraft:snow",
}
}
registry! {
enum ParrotVariant {
RedBlue => "minecraft:red_blue",
Blue => "minecraft:blue",
Green => "minecraft:green",
YellowBlue => "minecraft:yellow_blue",
Gray => "minecraft:gray",
}
}
registry! {
#[derive(Default)]
enum MooshroomVariant {
#[default]
Red => "minecraft:red",
Brown => "minecraft:brown",
}
}
registry! {
#[derive(Default)]
enum RabbitVariant {
#[default]
Brown => "minecraft:brown",
White => "minecraft:white",
Black => "minecraft:black",
WhiteSplotched => "minecraft:white_splotched",
Gold => "minecraft:gold",
Salt => "minecraft:salt",
Evil => "minecraft:evil",
}
}
registry! {
#[derive(Default)]
enum HorseVariant {
#[default]
White => "minecraft:white",
Creamy => "minecraft:creamy",
Chestnut => "minecraft:chestnut",
Brown => "minecraft:brown",
Black => "minecraft:black",
Gray => "minecraft:gray",
DarkBrown => "minecraft:dark_brown",
}
}
registry! {
#[derive(Default)]
enum LlamaVariant {
#[default]
Creamy => "minecraft:creamy",
White => "minecraft:white",
Brown => "minecraft:brown",
Gray => "minecraft:gray",
}
}
registry! {
#[derive(Default)]
enum AxolotlVariant {
#[default]
Lucy => "minecraft:lucy",
Wild => "minecraft:wild",
Gold => "minecraft:gold",
Cyan => "minecraft:cyan",
Blue => "minecraft:blue",
}
}
registry! {

View file

@ -1177,6 +1177,8 @@ enum Block {
WarpedWallSign => "minecraft:warped_wall_sign",
StructureBlock => "minecraft:structure_block",
Jigsaw => "minecraft:jigsaw",
TestBlock => "minecraft:test_block",
TestInstanceBlock => "minecraft:test_instance_block",
Composter => "minecraft:composter",
Target => "minecraft:target",
BeeNest => "minecraft:bee_nest",
@ -1465,6 +1467,8 @@ enum BlockEntityKind {
Crafter => "minecraft:crafter",
TrialSpawner => "minecraft:trial_spawner",
Vault => "minecraft:vault",
TestBlock => "minecraft:test_block",
TestInstanceBlock => "minecraft:test_instance_block",
}
}
@ -1568,6 +1572,7 @@ enum CommandArgumentKind {
ResourceOrTagKey => "minecraft:resource_or_tag_key",
Resource => "minecraft:resource",
ResourceKey => "minecraft:resource_key",
ResourceSelector => "minecraft:resource_selector",
TemplateMirror => "minecraft:template_mirror",
TemplateRotation => "minecraft:template_rotation",
Heightmap => "minecraft:heightmap",
@ -2816,6 +2821,8 @@ enum Item {
BambooChestRaft => "minecraft:bamboo_chest_raft",
StructureBlock => "minecraft:structure_block",
Jigsaw => "minecraft:jigsaw",
TestBlock => "minecraft:test_block",
TestInstanceBlock => "minecraft:test_instance_block",
TurtleHelmet => "minecraft:turtle_helmet",
TurtleScute => "minecraft:turtle_scute",
ArmadilloScute => "minecraft:armadillo_scute",
@ -3500,6 +3507,7 @@ enum MemoryModuleKind {
NearestPlayers => "minecraft:nearest_players",
NearestVisiblePlayer => "minecraft:nearest_visible_player",
NearestVisibleTargetablePlayer => "minecraft:nearest_visible_targetable_player",
NearestVisibleTargetablePlayers => "minecraft:nearest_visible_targetable_players",
WalkTarget => "minecraft:walk_target",
LookTarget => "minecraft:look_target",
AttackTarget => "minecraft:attack_target",
@ -6370,6 +6378,8 @@ enum BlockKind {
TallGrass => "minecraft:tall_grass",
TallSeagrass => "minecraft:tall_seagrass",
Target => "minecraft:target",
Test => "minecraft:test",
TestInstance => "minecraft:test_instance",
TintedGlass => "minecraft:tinted_glass",
Tnt => "minecraft:tnt",
TorchflowerCrop => "minecraft:torchflower_crop",
@ -6573,6 +6583,27 @@ enum DataComponentKind {
Bees => "minecraft:bees",
Lock => "minecraft:lock",
ContainerLoot => "minecraft:container_loot",
VillagerVariant => "minecraft:villager/variant",
WolfVariant => "minecraft:wolf/variant",
WolfCollar => "minecraft:wolf/collar",
FoxVariant => "minecraft:fox/variant",
SalmonSize => "minecraft:salmon/size",
ParrotVariant => "minecraft:parrot/variant",
TropicalFishPattern => "minecraft:tropical_fish/pattern",
TropicalFishBaseColor => "minecraft:tropical_fish/base_color",
TropicalFishPatternColor => "minecraft:tropical_fish/pattern_color",
MooshroomVariant => "minecraft:mooshroom/variant",
RabbitVariant => "minecraft:rabbit/variant",
PigVariant => "minecraft:pig/variant",
FrogVariant => "minecraft:frog/variant",
HorseVariant => "minecraft:horse/variant",
PaintingVariant => "minecraft:painting/variant",
LlamaVariant => "minecraft:llama/variant",
AxolotlVariant => "minecraft:axolotl/variant",
CatVariant => "minecraft:cat/variant",
CatCollar => "minecraft:cat/collar",
SheepColor => "minecraft:sheep/color",
ShulkerColor => "minecraft:shulker/color",
}
}
@ -6584,21 +6615,6 @@ enum EntitySubPredicateKind {
Slime => "minecraft:slime",
Raider => "minecraft:raider",
Sheep => "minecraft:sheep",
Axolotl => "minecraft:axolotl",
Fox => "minecraft:fox",
Mooshroom => "minecraft:mooshroom",
Rabbit => "minecraft:rabbit",
Horse => "minecraft:horse",
Llama => "minecraft:llama",
Villager => "minecraft:villager",
Parrot => "minecraft:parrot",
Salmon => "minecraft:salmon",
TropicalFish => "minecraft:tropical_fish",
Painting => "minecraft:painting",
Cat => "minecraft:cat",
Frog => "minecraft:frog",
Wolf => "minecraft:wolf",
Pig => "minecraft:pig",
}
}
@ -6853,3 +6869,26 @@ enum TicketKind {
Unknown => "minecraft:unknown",
}
}
registry! {
enum TestEnvironmentDefinitionKind {
AllOf => "minecraft:all_of",
GameRules => "minecraft:game_rules",
TimeOfDay => "minecraft:time_of_day",
Raining => "minecraft:raining",
Function => "minecraft:function",
}
}
registry! {
enum TestFunction {
AlwaysPass => "minecraft:always_pass",
}
}
registry! {
enum TestInstanceKind {
BlockBased => "minecraft:block_based",
Function => "minecraft:function",
}
}

View file

@ -3030,6 +3030,7 @@ pub static REPLACEABLE_BY_MUSHROOMS: LazyLock<HashSet<Block>> = LazyLock::new(||
Block::WarpedRoots,
Block::NetherSprouts,
Block::CrimsonRoots,
Block::LeafLitter,
Block::JungleLeaves,
Block::OakLeaves,
Block::SpruceLeaves,

View file

@ -14,6 +14,8 @@ MOJMAP_TO_AZALEA_STATE_NAME_MAPPING = {
}
AZALEA_TO_MOJMAP_STATE_NAME_MAPPING = {v: k for k, v in MOJMAP_TO_AZALEA_STATE_NAME_MAPPING.items()}
PACKETS_DIR = '../azalea-protocol/src/packets'
def generate_packet(packets_report, packet_name, direction, state):
mojmap_state = AZALEA_TO_MOJMAP_STATE_NAME_MAPPING.get(state, state)
_packet_report = packets_report[mojmap_state][direction]['minecraft:' + packet_name]
@ -24,7 +26,7 @@ def generate_packet(packets_report, packet_name, direction, state):
packet_derive_name = f'{to_camel_case(direction)}{to_camel_case(state)}Packet'
packet_struct_name = to_camel_case(f'{direction}_{packet_name}')
packet_module_name = f'{direction[0]}_{packet_name}'
packet_module_name = get_packet_module_name(packet_name, direction)
code.append(f'use azalea_buf::AzBuf;')
code.append(f'use azalea_protocol_macros::{packet_derive_name};')
@ -42,11 +44,16 @@ def generate_packet(packets_report, packet_name, direction, state):
# this won't handle writing to the packets/{state}/mod.rs file since we'd need to know the full packet list
def set_packets(packets_report):
def get_packet_module_name(packet_name: str, direction: str):
return f'{direction[0]}_{packet_name}'
def set_packets(packets_report):
for mojmap_state in packets_report:
state = MOJMAP_TO_AZALEA_STATE_NAME_MAPPING.get(mojmap_state, mojmap_state)
mod_rs_dir = get_dir_location(
f'../azalea-protocol/src/packets/{state}/mod.rs')
expected_packet_module_names = set()
state_dir = get_dir_location(f'{PACKETS_DIR}/{state}')
mod_rs_dir = get_dir_location(f'{state_dir}/mod.rs')
serverbound_packets = packet_direction_report_to_packet_names(packets_report[mojmap_state]['serverbound'])
clientbound_packets = packet_direction_report_to_packet_names(packets_report[mojmap_state].get('clientbound', {}))
@ -61,10 +68,12 @@ def set_packets(packets_report):
code.append(' Clientbound => [')
for packet_id, packet_name in enumerate(clientbound_packets):
code.append(f' {packet_name}, // {padded_hex(packet_id)}')
expected_packet_module_names.add(get_packet_module_name(packet_name, 'clientbound'))
code.append(' ],')
code.append(' Serverbound => [')
for packet_id, packet_name in enumerate(serverbound_packets):
code.append(f' {packet_name}, // {padded_hex(packet_id)}')
expected_packet_module_names.add(get_packet_module_name(packet_name, 'serverbound'))
code.append(' ]')
code.append(');')
code.append('')
@ -72,6 +81,23 @@ def set_packets(packets_report):
with open(mod_rs_dir, 'w') as f:
f.write('\n'.join(code))
existing_packet_module_names = set()
# iterate over the directory
for file in os.listdir(state_dir):
if file.endswith('.rs') and file != 'mod.rs':
existing_packet_module_names.add(file[:-len('.rs')])
for packet_module_name in expected_packet_module_names - existing_packet_module_names:
direction = None
if packet_module_name.startswith('c_'):
direction = 'clientbound'
elif packet_module_name.startswith('s_'):
direction = 'serverbound'
else:
raise Exception(f'Invalid packet module name: {packet_module_name}')
packet = packet_module_name[2:]
generate_packet(packets_report, packet, direction, state)
def packet_direction_report_to_packet_names(report):
name_to_id = {}
for resource_location, packet in report.items():
@ -82,8 +108,7 @@ def packet_direction_report_to_packet_names(report):
return names_sorted
def get_packets(direction: str, state: str):
mod_rs_dir = get_dir_location(
f'../azalea-protocol/src/packets/{state}/mod.rs')
mod_rs_dir = get_dir_location(f'{PACKETS_DIR}/{state}/mod.rs')
with open(mod_rs_dir, 'r') as f:
mod_rs = f.read().splitlines()