Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.20.5 #127

Merged
merged 16 commits into from
Apr 23, 2024
Merged
Next Next commit
23w51b
  • Loading branch information
mat-1 committed Jan 18, 2024
commit ad14036fe66118014c5c0e01e40c4c0a29648211
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,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: `1.20.4`._
_Currently supported Minecraft version: `23w51b`._

> [!WARNING]
> Azalea is still very unfinished, though most crates are in a somewhat useable state
Expand Down
11 changes: 11 additions & 0 deletions azalea-entity/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ pub enum EntityDataValue {
OptionalGlobalPos(Option<GlobalPos>),
PaintingVariant(azalea_registry::PaintingVariant),
SnifferState(SnifferState),
ArmadilloState(ArmadilloStateKind),
Vector3(Vec3),
Quaternion(Quaternion),
}
Expand All @@ -107,6 +108,16 @@ pub struct Quaternion {
pub w: f32,
}

// mojang just calls this ArmadilloState but i added "Kind" since otherwise it
// collides with a name in metadata.rs
#[derive(Clone, Debug, Copy, Default, McBuf)]
pub enum ArmadilloStateKind {
#[default]
Idle,
Rolling,
Scared,
}

impl McBufReadable for OptionalUnsignedInt {
fn read_from(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> {
let val = u32::var_read_from(buf)?;
Expand Down
110 changes: 102 additions & 8 deletions azalea-entity/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
// Don't change it manually!

use super::{
EntityDataItem, EntityDataValue, OptionalUnsignedInt, Pose, Quaternion, Rotations,
SnifferState, VillagerData,
ArmadilloStateKind, EntityDataItem, EntityDataValue, OptionalUnsignedInt, Pose, Quaternion,
Rotations, SnifferState, VillagerData,
};
use azalea_chat::FormattedText;
use azalea_core::{
Expand Down Expand Up @@ -228,6 +228,87 @@ impl Default for AreaEffectCloudMetadataBundle {
}
}

#[derive(Component, Deref, DerefMut, Clone)]
pub struct AbstractAgeableBaby(pub bool);
#[derive(Component, Deref, DerefMut, Clone)]
pub struct ArmadilloState(pub ArmadilloStateKind);
#[derive(Component)]
pub struct Armadillo;
impl Armadillo {
pub fn apply_metadata(
entity: &mut bevy_ecs::system::EntityCommands,
d: EntityDataItem,
) -> Result<(), UpdateMetadataError> {
match d.index {
0..=16 => AbstractAnimal::apply_metadata(entity, d)?,
17 => {
entity.insert(ArmadilloState(d.value.into_armadillo_state()?));
}
_ => {}
}
Ok(())
}
}

#[derive(Bundle)]
pub struct ArmadilloMetadataBundle {
_marker: Armadillo,
parent: AbstractAnimalMetadataBundle,
armadillo_state: ArmadilloState,
}
impl Default for ArmadilloMetadataBundle {
fn default() -> Self {
Self {
_marker: Armadillo,
parent: AbstractAnimalMetadataBundle {
_marker: AbstractAnimal,
parent: AbstractAgeableMetadataBundle {
_marker: AbstractAgeable,
parent: AbstractCreatureMetadataBundle {
_marker: AbstractCreature,
parent: AbstractInsentientMetadataBundle {
_marker: AbstractInsentient,
parent: AbstractLivingMetadataBundle {
_marker: AbstractLiving,
parent: AbstractEntityMetadataBundle {
_marker: AbstractEntity,
on_fire: OnFire(false),
shift_key_down: ShiftKeyDown(false),
sprinting: Sprinting(false),
swimming: Swimming(false),
currently_glowing: CurrentlyGlowing(false),
invisible: Invisible(false),
fall_flying: FallFlying(false),
air_supply: AirSupply(Default::default()),
custom_name: CustomName(None),
custom_name_visible: CustomNameVisible(false),
silent: Silent(false),
no_gravity: NoGravity(false),
pose: Pose::default(),
ticks_frozen: TicksFrozen(0),
},
auto_spin_attack: AutoSpinAttack(false),
abstract_living_using_item: AbstractLivingUsingItem(false),
health: Health(1.0),
abstract_living_effect_color: AbstractLivingEffectColor(0),
effect_ambience: EffectAmbience(false),
arrow_count: ArrowCount(0),
stinger_count: StingerCount(0),
sleeping_pos: SleepingPos(None),
},
no_ai: NoAi(false),
left_handed: LeftHanded(false),
aggressive: Aggressive(false),
},
},
abstract_ageable_baby: AbstractAgeableBaby(false),
},
},
armadillo_state: ArmadilloState(Default::default()),
}
}
}

#[derive(Component, Deref, DerefMut, Clone, Copy)]
pub struct Small(pub bool);
#[derive(Component, Deref, DerefMut, Clone, Copy)]
Expand Down Expand Up @@ -426,8 +507,6 @@ impl Default for ArrowMetadataBundle {
}
}

#[derive(Component, Deref, DerefMut, Clone)]
pub struct AbstractAgeableBaby(pub bool);
#[derive(Component, Deref, DerefMut, Clone)]
pub struct AxolotlVariant(pub i32);
#[derive(Component, Deref, DerefMut, Clone)]
Expand Down Expand Up @@ -1986,7 +2065,7 @@ impl Default for DolphinMetadataBundle {
aggressive: Aggressive(false),
},
},
treasure_pos: TreasurePos(Default::default()),
treasure_pos: TreasurePos(BlockPos::new(0, 0, 0)),
got_fish: GotFish(false),
moistness_level: MoistnessLevel(2400),
}
Expand Down Expand Up @@ -3014,7 +3093,7 @@ impl Default for FallingBlockMetadataBundle {
pose: Pose::default(),
ticks_frozen: TicksFrozen(0),
},
start_pos: StartPos(Default::default()),
start_pos: StartPos(BlockPos::new(0, 0, 0)),
}
}
}
Expand Down Expand Up @@ -8604,10 +8683,10 @@ impl Default for TurtleMetadataBundle {
abstract_ageable_baby: AbstractAgeableBaby(false),
},
},
home_pos: HomePos(Default::default()),
home_pos: HomePos(BlockPos::new(0, 0, 0)),
has_egg: HasEgg(false),
laying_egg: LayingEgg(false),
travel_pos: TravelPos(Default::default()),
travel_pos: TravelPos(BlockPos::new(0, 0, 0)),
going_home: GoingHome(false),
travelling: Travelling(false),
}
Expand Down Expand Up @@ -9350,6 +9429,8 @@ pub struct WolfInterested(pub bool);
#[derive(Component, Deref, DerefMut, Clone)]
pub struct WolfCollarColor(pub i32);
#[derive(Component, Deref, DerefMut, Clone)]
pub struct HasArmor(pub bool);
#[derive(Component, Deref, DerefMut, Clone)]
pub struct WolfRemainingAngerTime(pub i32);
#[derive(Component)]
pub struct Wolf;
Expand All @@ -9367,6 +9448,9 @@ impl Wolf {
entity.insert(WolfCollarColor(d.value.into_int()?));
}
21 => {
entity.insert(HasArmor(d.value.into_boolean()?));
}
22 => {
entity.insert(WolfRemainingAngerTime(d.value.into_int()?));
}
_ => {}
Expand All @@ -9381,6 +9465,7 @@ pub struct WolfMetadataBundle {
parent: AbstractTameableMetadataBundle,
wolf_interested: WolfInterested,
wolf_collar_color: WolfCollarColor,
has_armor: HasArmor,
wolf_remaining_anger_time: WolfRemainingAngerTime,
}
impl Default for WolfMetadataBundle {
Expand Down Expand Up @@ -9439,6 +9524,7 @@ impl Default for WolfMetadataBundle {
},
wolf_interested: WolfInterested(false),
wolf_collar_color: WolfCollarColor(Default::default()),
has_armor: HasArmor(false),
wolf_remaining_anger_time: WolfRemainingAngerTime(0),
}
}
Expand Down Expand Up @@ -10548,6 +10634,11 @@ pub fn apply_metadata(
AreaEffectCloud::apply_metadata(entity, d)?;
}
}
azalea_registry::EntityKind::Armadillo => {
for d in items {
Armadillo::apply_metadata(entity, d)?;
}
}
azalea_registry::EntityKind::ArmorStand => {
for d in items {
ArmorStand::apply_metadata(entity, d)?;
Expand Down Expand Up @@ -11183,6 +11274,9 @@ pub fn apply_default_metadata(
azalea_registry::EntityKind::AreaEffectCloud => {
entity.insert(AreaEffectCloudMetadataBundle::default());
}
azalea_registry::EntityKind::Armadillo => {
entity.insert(ArmadilloMetadataBundle::default());
}
azalea_registry::EntityKind::ArmorStand => {
entity.insert(ArmorStandMetadataBundle::default());
}
Expand Down
Loading
Loading