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
Prev Previous commit
Next Next commit
fix all the broken packets and clippy (mojang please don't do an upda…
…te like this again or i will murder someone)
  • Loading branch information
mat-1 committed Apr 17, 2024
commit 8bf0c0c1e5bb02aed46e6274457ecdc255c79491
4 changes: 2 additions & 2 deletions azalea-brigadier/src/context/command_context_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl<'a, S> CommandContextBuilder<'a, S> {
}

pub fn with_command(&mut self, command: &Command<S>) -> &Self {
self.command = command.clone();
self.command.clone_from(command);
self
}
pub fn with_child(&mut self, child: Rc<CommandContextBuilder<'a, S>>) -> &Self {
Expand All @@ -80,7 +80,7 @@ impl<'a, S> CommandContextBuilder<'a, S> {
range,
});
self.range = StringRange::encompassing(&self.range, &range);
self.modifier = node.read().modifier.clone();
self.modifier.clone_from(&node.read().modifier);
self.forks = node.read().forks;
self
}
Expand Down
4 changes: 2 additions & 2 deletions azalea-buf/src/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl McBufVarWritable for i32 {
}
while value != 0 {
buffer[0] = (value & 0b0111_1111) as u8;
value = (value >> 7) & (i32::max_value() >> 6);
value = (value >> 7) & (i32::MAX >> 6);
if value != 0 {
buffer[0] |= 0b1000_0000;
}
Expand Down Expand Up @@ -137,7 +137,7 @@ impl McBufVarWritable for i64 {
}
while value != 0 {
buffer[0] = (value & 0b0111_1111) as u8;
value = (value >> 7) & (i64::max_value() >> 6);
value = (value >> 7) & (i64::MAX >> 6);
if value != 0 {
buffer[0] |= 0b1000_0000;
}
Expand Down
2 changes: 1 addition & 1 deletion azalea-client/src/inventory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ impl InventoryComponent {
// && slot.may_place(item_stack)
&& (
self.quick_craft_kind == QuickCraftKind::Middle
|| item_stack.count() as i32 >= self.quick_craft_slots.len() as i32
|| item_stack.count() >= self.quick_craft_slots.len() as i32
)
{
break;
Expand Down
2 changes: 1 addition & 1 deletion azalea-client/src/packet_handling/game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ pub fn process_packet_events(ecs: &mut World) {
info.latency = updated_info.latency;
}
if p.actions.update_display_name {
info.display_name = updated_info.display_name.clone();
info.display_name.clone_from(&updated_info.display_name);
}
update_player_events.send(UpdatePlayerEvent {
entity: player_entity,
Expand Down
4 changes: 2 additions & 2 deletions azalea-client/src/task_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl Default for TaskPoolOptions {
TaskPoolOptions {
// By default, use however many cores are available on the system
min_total_threads: 1,
max_total_threads: std::usize::MAX,
max_total_threads: usize::MAX,

// Use 25% of cores for IO, at least 1, no more than 4
io: TaskPoolThreadAssignmentPolicy {
Expand All @@ -77,7 +77,7 @@ impl Default for TaskPoolOptions {
// Use all remaining cores for compute (at least 1)
compute: TaskPoolThreadAssignmentPolicy {
min_threads: 1,
max_threads: std::usize::MAX,
max_threads: usize::MAX,
percent: 1.0, // This 1.0 here means "whatever is left over"
},
}
Expand Down
2 changes: 1 addition & 1 deletion azalea-core/src/registry_holder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl RegistryHolder {
id: ResourceLocation,
entries: HashMap<ResourceLocation, Option<NbtCompound>>,
) {
let map = self.map.entry(id).or_insert_with(HashMap::new);
let map = self.map.entry(id).or_default();
for (key, value) in entries {
if let Some(value) = value {
map.insert(key, value);
Expand Down
6 changes: 3 additions & 3 deletions azalea-inventory/src/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,9 @@ pub enum AttributeModifierOperation {
MultiplyTotal,
}

// TODO: this is duplicated in azalea-entity (but we can't use the one from
// azalea-entity because it would create a circular dependency), this should
// maybe be put in its own crate or something
// this is duplicated in azalea-entity, BUT the one there has a different
// protocol format (and we can't use it anyways because it would cause a
// circular dependency)
#[derive(Clone, PartialEq, McBuf)]
pub struct AttributeModifier {
pub uuid: Uuid,
Expand Down
13 changes: 5 additions & 8 deletions azalea-inventory/src/slot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ impl McBufReadable for ItemSlot {
let kind = azalea_registry::Item::read_from(buf)?;
let components = DataComponentPatch::read_from(buf)?;
Ok(ItemSlot::Present(ItemSlotData {
count: count as i32,
count,
kind,
components,
}))
Expand Down Expand Up @@ -176,11 +176,8 @@ pub struct DataComponentPatch {
}

impl DataComponentPatch {
pub fn get(
&self,
kind: DataComponentKind,
) -> Option<&Box<dyn components::EncodableDataComponent>> {
self.components.get(&kind).and_then(|c| c.as_ref())
pub fn get(&self, kind: DataComponentKind) -> Option<&dyn components::EncodableDataComponent> {
self.components.get(&kind).and_then(|c| c.as_deref())
}
}

Expand Down Expand Up @@ -213,7 +210,7 @@ impl McBufWritable for DataComponentPatch {
fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
let mut components_with_data_count = 0;
let mut components_without_data_count = 0;
for (_, component) in &self.components {
for component in self.components.values() {
if component.is_some() {
components_with_data_count += 1;
} else {
Expand Down Expand Up @@ -247,7 +244,7 @@ impl Clone for DataComponentPatch {
fn clone(&self) -> Self {
let mut components = HashMap::with_capacity(self.components.len());
for (kind, component) in &self.components {
components.insert(kind.clone(), component.as_ref().map(|c| (*c).clone()));
components.insert(*kind, component.as_ref().map(|c| (*c).clone()));
}
DataComponentPatch { components }
}
Expand Down
2 changes: 1 addition & 1 deletion azalea-physics/src/collision/shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ impl Shapes {
coords: coords1.to_vec(),
}
} else {
IndexMerger::new_indirect(&coords1, &coords2, var3, var4)
IndexMerger::new_indirect(coords1, coords2, var3, var4)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ use azalea_buf::McBuf;
use azalea_protocol_macros::ClientboundConfigurationPacket;

#[derive(Clone, Debug, McBuf, ClientboundConfigurationPacket)]
pub struct ClientboundResetChatPacket {}
pub struct ClientboundResetChatPacket;
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
use azalea_buf::McBuf;
use azalea_protocol_macros::ClientboundGamePacket;
use std::collections::HashMap;

#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
pub struct ClientboundAwardStatsPacket {}
pub struct ClientboundAwardStatsPacket {
#[var]
pub stats: HashMap<Stat, i32>,
}

#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, McBuf)]
pub enum Stat {
Mined(azalea_registry::Block),
Crafted(azalea_registry::Item),
Used(azalea_registry::Item),
Broken(azalea_registry::Item),
PickedUp(azalea_registry::Item),
Dropped(azalea_registry::Item),
Killed(azalea_registry::EntityKind),
KilledBy(azalea_registry::EntityKind),
Custom(azalea_registry::CustomStat),
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
use azalea_buf::McBuf;
use azalea_core::position::BlockPos;
use azalea_protocol_macros::ClientboundGamePacket;

#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
pub struct ClientboundBlockDestructionPacket {
/// The ID of the entity breaking the block.
#[var]
pub id: u32,
pub pos: u64, // TODO: Does BlockPos::asLong, may not be implemented
pub pos: BlockPos,
/// 0–9 to set it, any other value to remove it.
pub progress: u8,
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
use azalea_buf::McBuf;
use azalea_core::position::BlockPos;
use azalea_protocol_macros::ClientboundGamePacket;
use simdnbt::owned::Nbt;

#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
pub struct ClientboundBlockEntityDataPacket {}
pub struct ClientboundBlockEntityDataPacket {
pub pos: BlockPos,
pub block_entity_type: azalea_registry::BlockEntityKind,
pub tag: Nbt,
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use azalea_buf::McBuf;
use azalea_core::position::BlockPos;
use azalea_protocol_macros::ClientboundGamePacket;
use azalea_registry::Block;

#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
pub struct ClientboundBlockEventPacket {
pub pos: u64, // TODO: Does BlockPos::asLong, may not be implemented
#[var]
pub b0: u32,
#[var]
pub b1: u32,
pub pos: BlockPos,
pub action_id: u8,
pub action_parameter: u8,
pub block: Block,
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ use azalea_buf::McBuf;
use azalea_protocol_macros::ClientboundGamePacket;

#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
pub struct ClientboundCooldownPacket {}
pub struct ClientboundCooldownPacket {
pub item: azalea_registry::Item,
#[var]
pub duration: u32,
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
use azalea_buf::McBuf;
use azalea_buf::UnsizedByteArray;
use azalea_core::resource_location::ResourceLocation;
use azalea_protocol_macros::ClientboundGamePacket;

#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
pub struct ClientboundCustomPayloadPacket {}
pub struct ClientboundCustomPayloadPacket {
pub identifier: ResourceLocation,
pub data: UnsizedByteArray,
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use azalea_buf::McBuf;
use azalea_protocol_macros::ClientboundGamePacket;
use azalea_registry::ParticleKind;

#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
pub struct ClientboundLevelParticlesPacket {
Expand All @@ -13,4 +14,5 @@ pub struct ClientboundLevelParticlesPacket {
pub max_speed: f32,
#[var]
pub count: u32,
pub particle: ParticleKind,
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
use azalea_buf::McBuf;
use azalea_inventory::ItemSlot;
use azalea_protocol_macros::ClientboundGamePacket;

#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
pub struct ClientboundMerchantOffersPacket {
#[var]
pub container_id: u32,
pub offers: Vec<MerchantOffer>,
#[var]
pub villager_level: u32,
#[var]
pub villager_xp: u32,
pub show_progress: bool,
pub can_restock: bool,
}

#[derive(Clone, Debug, McBuf)]
pub struct MerchantOffer {
pub base_cost_a: ItemSlot,
pub result: ItemSlot,
pub cost_b: ItemSlot,
pub out_of_stock: bool,
pub uses: u32,
pub max_uses: u32,
pub xp: u32,
pub special_price_diff: i32,
pub price_multiplier: f32,
pub demand: u32,
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use azalea_buf::McBuf;
use azalea_core::position::BlockPos;
use azalea_protocol_macros::ClientboundGamePacket;

#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
pub struct ClientboundOpenSignEditorPacket {
pub pos: u64, // TODO: Does BlockPos::asLong, may not be implemented
pub pos: BlockPos,
pub is_front_text: bool,
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ use azalea_buf::McBuf;
use azalea_protocol_macros::ClientboundGamePacket;

#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
pub struct ClientboundRemoveMobEffectPacket {}
pub struct ClientboundRemoveMobEffectPacket {
#[var]
pub entity_id: u32,
pub effect: azalea_registry::MobEffect,
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use azalea_buf::McBuf;
use azalea_protocol_macros::ClientboundGamePacket;
use uuid::Uuid;

#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
pub struct ClientboundResourcePackPopPacket {}
pub struct ClientboundResourcePackPopPacket {
pub id: Option<Uuid>,
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use azalea_buf::McBuf;
use azalea_core::position::BlockPos;
use azalea_protocol_macros::ClientboundGamePacket;

#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
pub struct ClientboundSetDefaultSpawnPositionPacket {
pub pos: u64, // TODO: Does BlockPos::asLong, may not be implemented
pub pos: BlockPos,
pub angle: f32,
}
Loading
Loading