mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 23:44:38 +00:00
fix all the broken packets and clippy (mojang please don't do an update like this again or i will murder someone)
This commit is contained in:
parent
dfba6e369a
commit
8bf0c0c1e5
42 changed files with 379 additions and 104 deletions
|
@ -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 {
|
||||
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 {
|
||||
|
@ -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"
|
||||
},
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
}))
|
||||
|
@ -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())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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 }
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,4 +2,4 @@ use azalea_buf::McBuf;
|
|||
use azalea_protocol_macros::ClientboundConfigurationPacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundConfigurationPacket)]
|
||||
pub struct ClientboundResetChatPacket {}
|
||||
pub struct ClientboundResetChatPacket;
|
||||
|
|
|
@ -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),
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
@ -13,4 +14,5 @@ pub struct ClientboundLevelParticlesPacket {
|
|||
pub max_speed: f32,
|
||||
#[var]
|
||||
pub count: u32,
|
||||
pub particle: ParticleKind,
|
||||
}
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
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]
|
||||
|
@ -12,3 +14,17 @@ pub struct ClientboundMerchantOffersPacket {
|
|||
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,
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
|
|
@ -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>,
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
|
|
@ -1,17 +1,80 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_buf::{BufReadError, McBuf};
|
||||
use azalea_buf::{McBufReadable, McBufWritable};
|
||||
use azalea_inventory::ItemSlot;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
use std::io::Cursor;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundSetEquipmentPacket {
|
||||
#[var]
|
||||
pub entity: u32,
|
||||
// TODO: {'operation': 'store', 'type': 'int', 'value': 'this.d.size()', 'var': 'var2'}
|
||||
// TODO: {'operation': 'store', 'type': 'int', 'value': '0', 'var': 'var3'}
|
||||
// TODO: {'condition': 'var3 < var2', 'instructions': [{'operation': 'store', 'type': 'Object',
|
||||
// 'value': '((com.mojang.datafixers.util.Pair)this.d.get(var3))', 'var': 'var4'},
|
||||
// {'operation': 'store', 'type': 'Object', 'value': '((bnv)var4.getFirst())', 'var': 'var5'},
|
||||
// {'operation': 'store', 'type': 'int', 'value': '((var3 != (var2 - 1)) ? 1 : 0)', 'var':
|
||||
// 'var6'}, {'operation': 'store', 'type': 'int', 'value': 'var5.ordinal()', 'var': 'var7'},
|
||||
// {'field': '(var6) ? (var7 | -128) : var7', 'operation': 'write', 'type': 'varint'},
|
||||
// {'amount': '1', 'field': 'var3', 'operation': 'increment'}], 'operation': 'loop'}
|
||||
pub entity_id: u32,
|
||||
pub slots: EquipmentSlots,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct EquipmentSlots {
|
||||
pub slots: Vec<(EquipmentSlot, ItemSlot)>,
|
||||
}
|
||||
|
||||
impl McBufReadable for EquipmentSlots {
|
||||
fn read_from(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> {
|
||||
let mut slots = vec![];
|
||||
|
||||
loop {
|
||||
let equipment_byte = u8::read_from(buf)?;
|
||||
let equipment_slot =
|
||||
EquipmentSlot::from_byte(equipment_byte & 127).ok_or_else(|| {
|
||||
BufReadError::UnexpectedEnumVariant {
|
||||
id: equipment_byte.into(),
|
||||
}
|
||||
})?;
|
||||
let item = ItemSlot::read_from(buf)?;
|
||||
slots.push((equipment_slot, item));
|
||||
if equipment_byte & 128 == 0 {
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
Ok(EquipmentSlots { slots })
|
||||
}
|
||||
}
|
||||
impl McBufWritable for EquipmentSlots {
|
||||
fn write_into(&self, buf: &mut impl std::io::Write) -> Result<(), std::io::Error> {
|
||||
for i in 0..self.slots.len() {
|
||||
let (equipment_slot, item) = &self.slots[i];
|
||||
let mut equipment_byte = *equipment_slot as u8;
|
||||
if i != self.slots.len() - 1 {
|
||||
equipment_byte |= 128;
|
||||
}
|
||||
equipment_byte.write_into(buf)?;
|
||||
item.write_into(buf)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Copy, McBuf)]
|
||||
pub enum EquipmentSlot {
|
||||
MainHand = 0,
|
||||
OffHand = 1,
|
||||
Feet = 2,
|
||||
Legs = 3,
|
||||
Chest = 4,
|
||||
Head = 5,
|
||||
}
|
||||
|
||||
impl EquipmentSlot {
|
||||
#[must_use]
|
||||
pub fn from_byte(byte: u8) -> Option<Self> {
|
||||
match byte {
|
||||
0 => Some(EquipmentSlot::MainHand),
|
||||
1 => Some(EquipmentSlot::OffHand),
|
||||
2 => Some(EquipmentSlot::Feet),
|
||||
3 => Some(EquipmentSlot::Legs),
|
||||
4 => Some(EquipmentSlot::Chest),
|
||||
5 => Some(EquipmentSlot::Head),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,82 @@
|
|||
use azalea_buf::McBuf;
|
||||
use std::io::{Cursor, Write};
|
||||
|
||||
use azalea_buf::{McBuf, McBufReadable, McBufWritable};
|
||||
use azalea_chat::{numbers::NumberFormat, FormattedText};
|
||||
use azalea_core::objectives::ObjectiveCriteria;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundSetObjectivePacket {
|
||||
pub objective_name: String,
|
||||
#[var]
|
||||
pub method: u32,
|
||||
// TODO: {'condition': 'i', 'instructions': [{'field': 'f', 'operation': 'write', 'type':
|
||||
// 'chatcomponent'}, {'field': 'g', 'operation': 'write', 'type': 'enum'}], 'operation': 'if'}
|
||||
pub method: Method,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, McBuf)]
|
||||
pub enum MethodKind {
|
||||
Add,
|
||||
Remove,
|
||||
Change,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum Method {
|
||||
Add {
|
||||
display_name: FormattedText,
|
||||
render_type: ObjectiveCriteria,
|
||||
number_format: NumberFormat,
|
||||
},
|
||||
Remove,
|
||||
Change {
|
||||
display_name: FormattedText,
|
||||
render_type: ObjectiveCriteria,
|
||||
number_format: NumberFormat,
|
||||
},
|
||||
}
|
||||
|
||||
impl McBufReadable for Method {
|
||||
fn read_from(buf: &mut Cursor<&[u8]>) -> Result<Self, azalea_buf::BufReadError> {
|
||||
let kind = MethodKind::read_from(buf)?;
|
||||
match kind {
|
||||
MethodKind::Add => Ok(Method::Add {
|
||||
display_name: FormattedText::read_from(buf)?,
|
||||
render_type: ObjectiveCriteria::read_from(buf)?,
|
||||
number_format: NumberFormat::read_from(buf)?,
|
||||
}),
|
||||
MethodKind::Remove => Ok(Method::Remove),
|
||||
MethodKind::Change => Ok(Method::Change {
|
||||
display_name: FormattedText::read_from(buf)?,
|
||||
render_type: ObjectiveCriteria::read_from(buf)?,
|
||||
number_format: NumberFormat::read_from(buf)?,
|
||||
}),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl McBufWritable for Method {
|
||||
fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
|
||||
match self {
|
||||
Method::Add {
|
||||
display_name,
|
||||
render_type,
|
||||
number_format,
|
||||
} => {
|
||||
MethodKind::Add.write_into(buf)?;
|
||||
display_name.write_into(buf)?;
|
||||
render_type.write_into(buf)?;
|
||||
number_format.write_into(buf)?;
|
||||
}
|
||||
Method::Remove => MethodKind::Remove.write_into(buf)?,
|
||||
Method::Change {
|
||||
display_name,
|
||||
render_type,
|
||||
number_format,
|
||||
} => {
|
||||
MethodKind::Change.write_into(buf)?;
|
||||
display_name.write_into(buf)?;
|
||||
render_type.write_into(buf)?;
|
||||
number_format.write_into(buf)?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_chat::FormattedText;
|
||||
use azalea_chat::{numbers::NumberFormat, FormattedText};
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
|
@ -9,4 +9,5 @@ pub struct ClientboundSetScorePacket {
|
|||
#[var]
|
||||
pub score: u32,
|
||||
pub display: Option<FormattedText>,
|
||||
pub number_format: Option<NumberFormat>,
|
||||
}
|
||||
|
|
|
@ -1,18 +1,16 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
use azalea_registry::SoundEvent;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundSoundPacket {
|
||||
pub sound: SoundEvent,
|
||||
pub source: SoundSource,
|
||||
#[var]
|
||||
pub x: i32,
|
||||
#[var]
|
||||
pub y: i32,
|
||||
#[var]
|
||||
pub z: i32,
|
||||
pub volume: f32,
|
||||
pub pitch: f32,
|
||||
#[var]
|
||||
pub seed: u64,
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,5 @@ use azalea_protocol_macros::ClientboundGamePacket;
|
|||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundStoreCookiePacket {
|
||||
pub key: ResourceLocation,
|
||||
// TODO: {'field': 'd.length', 'operation': 'write', 'type': 'varint'}
|
||||
pub payload: Vec<u8>,
|
||||
}
|
||||
|
|
|
@ -1,5 +1,18 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_entity::attributes::AttributeModifier;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
use azalea_registry::Attribute;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundUpdateAttributesPacket {}
|
||||
pub struct ClientboundUpdateAttributesPacket {
|
||||
#[var]
|
||||
pub entity_id: u32,
|
||||
pub values: Vec<AttributeSnapshot>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, McBuf)]
|
||||
pub struct AttributeSnapshot {
|
||||
pub attribute: Attribute,
|
||||
pub base: f64,
|
||||
pub modifiers: Vec<AttributeModifier>,
|
||||
}
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
use azalea_registry::MobEffect;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundUpdateMobEffectPacket {
|
||||
#[var]
|
||||
pub entity_id: u32,
|
||||
pub mob_effect: MobEffect,
|
||||
#[var]
|
||||
pub effect_amplifier: u32,
|
||||
#[var]
|
||||
pub effect_duration_ticks: u32,
|
||||
#[var]
|
||||
pub flags: u32,
|
||||
pub flags: u8,
|
||||
}
|
||||
|
|
|
@ -214,9 +214,7 @@ impl McBufWritable for RecipeHolder {
|
|||
impl McBufReadable for RecipeHolder {
|
||||
fn read_from(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> {
|
||||
let identifier = ResourceLocation::read_from(buf)?;
|
||||
println!("identifier: {identifier:?}");
|
||||
let recipe_serializer = RecipeSerializer::read_from(buf)?;
|
||||
println!("recipe_serializer: {recipe_serializer:?}");
|
||||
|
||||
// rust doesn't let us match ResourceLocation so we have to do a big
|
||||
// if-else chain :(
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_core::position::BlockPos;
|
||||
use azalea_protocol_macros::ServerboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ServerboundGamePacket)]
|
||||
pub struct ServerboundBlockEntityTagQueryPacket {
|
||||
#[var]
|
||||
pub transaction_id: u32,
|
||||
pub pos: u64, // TODO: Does BlockPos::asLong, may not be implemented
|
||||
pub pos: BlockPos,
|
||||
}
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_buf::UnsizedByteArray;
|
||||
use azalea_core::resource_location::ResourceLocation;
|
||||
use azalea_protocol_macros::ServerboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ServerboundGamePacket)]
|
||||
pub struct ServerboundCustomPayloadPacket {}
|
||||
pub struct ServerboundCustomPayloadPacket {
|
||||
pub identifier: ResourceLocation,
|
||||
pub data: UnsizedByteArray,
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_core::position::BlockPos;
|
||||
use azalea_protocol_macros::ServerboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ServerboundGamePacket)]
|
||||
pub struct ServerboundJigsawGeneratePacket {
|
||||
pub pos: u64, // TODO: Does BlockPos::asLong, may not be implemented
|
||||
pub pos: BlockPos,
|
||||
#[var]
|
||||
pub levels: u32,
|
||||
pub keep_jigsaws: bool,
|
||||
|
|
|
@ -2,4 +2,9 @@ use azalea_buf::McBuf;
|
|||
use azalea_protocol_macros::ServerboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ServerboundGamePacket)]
|
||||
pub struct ServerboundSetBeaconPacket {}
|
||||
pub struct ServerboundSetBeaconPacket {
|
||||
#[var]
|
||||
pub primary: Option<u32>,
|
||||
#[var]
|
||||
pub secondary: Option<u32>,
|
||||
}
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
use azalea_buf::McBuf;
|
||||
use crate::packets::McBufWritable;
|
||||
use azalea_buf::{BufReadError, McBuf, McBufReadable};
|
||||
use azalea_core::{bitset::FixedBitSet, position::BlockPos};
|
||||
use azalea_protocol_macros::ServerboundGamePacket;
|
||||
use std::io::Cursor;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ServerboundGamePacket)]
|
||||
#[derive(Clone, Debug, ServerboundGamePacket)]
|
||||
pub struct ServerboundSetCommandBlockPacket {
|
||||
pub pos: u64, // TODO: Does BlockPos::asLong, may not be implemented
|
||||
pub pos: BlockPos,
|
||||
pub command: String,
|
||||
pub mode: Mode,
|
||||
// TODO: {'operation': 'store', 'type': 'int', 'value': '0', 'var': 'var2'}
|
||||
// TODO: {'condition': 'g', 'instructions': [{'operation': 'store', 'type': 'int', 'value':
|
||||
// '(var2 | 1)', 'var': 'var2'}], 'operation': 'if'} TODO: {'condition': 'h',
|
||||
// 'instructions': [{'operation': 'store', 'type': 'int', 'value': '(var2 | 2)', 'var':
|
||||
// 'var2'}], 'operation': 'if'} TODO: {'condition': 'i', 'instructions': [{'operation':
|
||||
// 'store', 'type': 'int', 'value': '(var2 | 4)', 'var': 'var2'}], 'operation': 'if'} TODO:
|
||||
// unknown field {'field': 'var2', 'operation': 'write', 'type': 'byte'}
|
||||
|
||||
pub track_output: bool,
|
||||
pub conditional: bool,
|
||||
pub automatic: bool,
|
||||
}
|
||||
|
||||
#[derive(McBuf, Clone, Copy, Debug)]
|
||||
|
@ -21,3 +21,41 @@ pub enum Mode {
|
|||
Auto = 1,
|
||||
Redstone = 2,
|
||||
}
|
||||
|
||||
impl McBufReadable for ServerboundSetCommandBlockPacket {
|
||||
fn read_from(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> {
|
||||
let pos = BlockPos::read_from(buf)?;
|
||||
let command = String::read_from(buf)?;
|
||||
let mode = Mode::read_from(buf)?;
|
||||
|
||||
let set = FixedBitSet::<3>::read_from(buf)?;
|
||||
Ok(Self {
|
||||
pos,
|
||||
command,
|
||||
mode,
|
||||
track_output: set.index(0),
|
||||
conditional: set.index(1),
|
||||
automatic: set.index(2),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl McBufWritable for ServerboundSetCommandBlockPacket {
|
||||
fn write_into(&self, buf: &mut impl std::io::Write) -> Result<(), std::io::Error> {
|
||||
self.pos.write_into(buf)?;
|
||||
self.command.write_into(buf)?;
|
||||
self.mode.write_into(buf)?;
|
||||
|
||||
let mut set = FixedBitSet::<3>::new();
|
||||
if self.track_output {
|
||||
set.set(0);
|
||||
}
|
||||
if self.conditional {
|
||||
set.set(1);
|
||||
}
|
||||
if self.automatic {
|
||||
set.set(2);
|
||||
}
|
||||
set.write_into(buf)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_inventory::ItemSlot;
|
||||
use azalea_protocol_macros::ServerboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ServerboundGamePacket)]
|
||||
pub struct ServerboundSetCreativeModeSlotPacket {
|
||||
#[var]
|
||||
pub slot_num: u32,
|
||||
pub slot_num: u16,
|
||||
pub item_stack: ItemSlot,
|
||||
}
|
||||
|
|
|
@ -1,18 +1,49 @@
|
|||
use crate::packets::BufReadError;
|
||||
use crate::packets::McBufWritable;
|
||||
use azalea_buf::McBuf;
|
||||
use azalea_buf::McBufReadable;
|
||||
use azalea_core::position::BlockPos;
|
||||
use azalea_core::resource_location::ResourceLocation;
|
||||
use azalea_protocol_macros::ServerboundGamePacket;
|
||||
use std::io::Cursor;
|
||||
use std::io::Write;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ServerboundGamePacket)]
|
||||
pub struct ServerboundSetJigsawBlockPacket {
|
||||
pub pos: u64, // TODO: Does BlockPos::asLong, may not be implemented
|
||||
pub pos: BlockPos,
|
||||
pub name: ResourceLocation,
|
||||
pub target: ResourceLocation,
|
||||
pub pool: ResourceLocation,
|
||||
pub final_state: String,
|
||||
pub joint: String, /* TODO: Does JigsawBlockEntity$JointType::getSerializedName, may not be
|
||||
* implemented */
|
||||
pub joint: String,
|
||||
#[var]
|
||||
pub selection_priority: u32,
|
||||
pub selection_priority: i32,
|
||||
#[var]
|
||||
pub placement_priority: u32,
|
||||
pub placement_priority: i32,
|
||||
}
|
||||
|
||||
pub enum JointType {
|
||||
Rollable,
|
||||
Aligned,
|
||||
}
|
||||
|
||||
impl McBufReadable for JointType {
|
||||
fn read_from(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> {
|
||||
let name = String::read_from(buf)?;
|
||||
match name.as_str() {
|
||||
"rollable" => Ok(JointType::Rollable),
|
||||
"aligned" => Ok(JointType::Aligned),
|
||||
_ => Err(BufReadError::UnexpectedStringEnumVariant { id: name }),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl McBufWritable for JointType {
|
||||
fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
|
||||
match self {
|
||||
JointType::Rollable => "rollable".to_string().write_into(buf)?,
|
||||
JointType::Aligned => "aligned".to_string().write_into(buf)?,
|
||||
};
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_core::position::BlockPos;
|
||||
use azalea_protocol_macros::ServerboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ServerboundGamePacket)]
|
||||
pub struct ServerboundSignUpdatePacket {
|
||||
pub pos: u64, // TODO: Does BlockPos::asLong, may not be implemented
|
||||
pub pos: BlockPos,
|
||||
pub is_front_text: bool,
|
||||
// TODO: {'operation': 'store', 'type': 'int', 'value': '0', 'var': 'var2'}
|
||||
// TODO: {'condition': 'var2 < 4', 'instructions': [{'field': 'd[var2]', 'operation': 'write',
|
||||
// 'type': 'string'}, {'amount': '1', 'field': 'var2', 'operation': 'increment'}], 'operation':
|
||||
// 'loop'}
|
||||
pub lines: [String; 4],
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ use std::io::{Cursor, Write};
|
|||
// TODO: rename the packet files to just like clientbound_add_entity instead of
|
||||
// clientbound_add_entity_packet
|
||||
|
||||
pub const PROTOCOL_VERSION: i32 = 1073742006;
|
||||
pub const PROTOCOL_VERSION: i32 = 1073742011;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub enum ConnectionProtocol {
|
||||
|
|
|
@ -19,6 +19,7 @@ enum WolfVariant {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::derivable_impls)]
|
||||
impl Default for WolfVariant {
|
||||
fn default() -> Self {
|
||||
WolfVariant::Pale
|
||||
|
|
|
@ -1,20 +1,10 @@
|
|||
use std::{hint::black_box, sync::Arc, time::Duration};
|
||||
|
||||
use azalea::{
|
||||
pathfinder::{
|
||||
astar::{self, a_star},
|
||||
goals::{BlockPosGoal, Goal},
|
||||
mining::MiningCache,
|
||||
simulation::{SimulatedPlayerBundle, Simulation, SimulationSet},
|
||||
world::CachedWorld,
|
||||
},
|
||||
BlockPos, Vec3,
|
||||
pathfinder::simulation::{SimulatedPlayerBundle, SimulationSet},
|
||||
Vec3,
|
||||
};
|
||||
use azalea_core::position::{ChunkBlockPos, ChunkPos};
|
||||
use azalea_inventory::Menu;
|
||||
use azalea_world::{Chunk, ChunkStorage, PartialChunkStorage};
|
||||
use criterion::{criterion_group, criterion_main, Bencher, Criterion};
|
||||
use parking_lot::RwLock;
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn generate_world(partial_chunks: &mut PartialChunkStorage, size: u32) -> ChunkStorage {
|
||||
|
|
|
@ -105,8 +105,8 @@ print()
|
|||
# lib.code.packet.generate_packet(
|
||||
# new_burger_data[0]['packets']['packet'], new_mappings, packet.packet_id, packet.direction, packet.state)
|
||||
|
||||
# lib.code.version.set_protocol_version(
|
||||
# new_burger_data[0]['version']['protocol'])
|
||||
lib.code.version.set_protocol_version(
|
||||
new_burger_data[0]['version']['protocol'])
|
||||
|
||||
# print('Updated protocol!')
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue