-
-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
126 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
use bytes::BufMut; | ||
use pumpkin_data::{ | ||
packet::clientbound::CONFIG_UPDATE_TAGS, | ||
tag::{RegistryKey, TAGS}, | ||
}; | ||
use pumpkin_macros::client_packet; | ||
use pumpkin_world::block::registry; | ||
|
||
use crate::{ | ||
bytebuf::ByteBufMut, | ||
codec::{identifier::Identifier, var_int::VarInt}, | ||
ClientPacket, | ||
}; | ||
|
||
#[client_packet(CONFIG_UPDATE_TAGS)] | ||
pub struct CUpdateTags<'a> { | ||
tags: &'a [pumpkin_data::tag::RegistryKey], | ||
} | ||
|
||
impl<'a> CUpdateTags<'a> { | ||
pub fn new(tags: &'a [pumpkin_data::tag::RegistryKey]) -> Self { | ||
Self { tags } | ||
} | ||
} | ||
|
||
impl ClientPacket for CUpdateTags<'_> { | ||
fn write(&self, bytebuf: &mut impl BufMut) { | ||
bytebuf.put_list(self.tags, |p, registry_key| { | ||
p.put_identifier(&Identifier::vanilla(registry_key.identifier_string())); | ||
|
||
let values = TAGS.get(registry_key).unwrap(); | ||
p.put_var_int(&VarInt::from(values.len() as i32)); | ||
for (key, values) in values.iter() { | ||
// This is technically a Identifier but same thing | ||
p.put_string_len(key, u16::MAX as usize); | ||
p.put_list(values, |p, v| { | ||
if let Some(string_id) = v { | ||
let id = match registry_key { | ||
RegistryKey::Block => registry::get_block(string_id).unwrap().id, | ||
_ => unimplemented!(), | ||
}; | ||
|
||
p.put_var_int(&VarInt::from(id as i32)); | ||
} | ||
}); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters