mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 06:16:04 +00:00
Merge branch 'main' into pathfinding
This commit is contained in:
commit
18e45c8e95
22 changed files with 15175 additions and 34040 deletions
|
@ -15,5 +15,5 @@ async fn main() {
|
|||
)
|
||||
.await
|
||||
.unwrap();
|
||||
println!("{:?}", auth_result);
|
||||
println!("{auth_result:?}");
|
||||
}
|
||||
|
|
|
@ -336,7 +336,7 @@ async fn auth_with_xbox_live(
|
|||
"SiteName": "user.auth.xboxlive.com",
|
||||
// i thought this was supposed to be d={} but it doesn't work for
|
||||
// me when i add it ??????
|
||||
"RpsTicket": format!("{}", access_token)
|
||||
"RpsTicket": format!("{access_token}")
|
||||
},
|
||||
"RelyingParty": "http://auth.xboxlive.com",
|
||||
"TokenType": "JWT"
|
||||
|
@ -359,7 +359,7 @@ async fn auth_with_xbox_live(
|
|||
|
||||
// not_after looks like 2020-12-21T19:52:08.4463796Z
|
||||
let expires_at = DateTime::parse_from_rfc3339(&res.not_after)
|
||||
.map_err(|e| XboxLiveAuthError::InvalidExpiryDate(format!("{}: {}", res.not_after, e)))?
|
||||
.map_err(|e| XboxLiveAuthError::InvalidExpiryDate(format!("{}: {e}", res.not_after)))?
|
||||
.with_timezone(&Utc)
|
||||
.timestamp() as u64;
|
||||
Ok(ExpiringValue {
|
||||
|
@ -416,7 +416,7 @@ async fn auth_with_minecraft(
|
|||
.post("https://api.minecraftservices.com/authentication/login_with_xbox")
|
||||
.header("Accept", "application/json")
|
||||
.json(&json!({
|
||||
"identityToken": format!("XBL3.0 x={};{}", user_hash, xsts_token)
|
||||
"identityToken": format!("XBL3.0 x={user_hash};{xsts_token}")
|
||||
}))
|
||||
.send()
|
||||
.await?
|
||||
|
@ -446,7 +446,7 @@ async fn check_ownership(
|
|||
.get("https://api.minecraftservices.com/entitlements/mcstore")
|
||||
.header(
|
||||
"Authorization",
|
||||
format!("Bearer {}", minecraft_access_token),
|
||||
format!("Bearer {minecraft_access_token}"),
|
||||
)
|
||||
.send()
|
||||
.await?
|
||||
|
@ -474,7 +474,7 @@ async fn get_profile(
|
|||
.get("https://api.minecraftservices.com/minecraft/profile")
|
||||
.header(
|
||||
"Authorization",
|
||||
format!("Bearer {}", minecraft_access_token),
|
||||
format!("Bearer {minecraft_access_token}"),
|
||||
)
|
||||
.send()
|
||||
.await?
|
||||
|
|
|
@ -317,7 +317,7 @@ pub fn make_block_states(input: TokenStream) -> TokenStream {
|
|||
// }
|
||||
let property_variants = properties_map
|
||||
.get(property_name)
|
||||
.unwrap_or_else(|| panic!("Property '{}' not found", property_name))
|
||||
.unwrap_or_else(|| panic!("Property '{property_name}' not found"))
|
||||
.clone();
|
||||
block_properties_vec.push(property_variants);
|
||||
}
|
||||
|
@ -354,7 +354,7 @@ pub fn make_block_states(input: TokenStream) -> TokenStream {
|
|||
previous_names.push(property_name.clone());
|
||||
if let Some(index) = index {
|
||||
// property_name.push_str(&format!("_{}", &index.to_string()));
|
||||
write!(property_name, "_{}", index).unwrap();
|
||||
write!(property_name, "_{index}").unwrap();
|
||||
}
|
||||
properties_with_name.push(PropertyWithNameAndDefault {
|
||||
name: Ident::new(&property_name, proc_macro2::Span::call_site()),
|
||||
|
@ -391,7 +391,7 @@ pub fn make_block_states(input: TokenStream) -> TokenStream {
|
|||
proc_macro2::Span::call_site(),
|
||||
);
|
||||
let block_struct_name = Ident::new(
|
||||
&format!("{}Block", block_name_pascal_case),
|
||||
&format!("{block_name_pascal_case}Block"),
|
||||
proc_macro2::Span::call_site(),
|
||||
);
|
||||
|
||||
|
|
|
@ -45,35 +45,35 @@ impl fmt::Debug for BuiltInExceptions {
|
|||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
BuiltInExceptions::DoubleTooSmall { found, min } => {
|
||||
write!(f, "Double must not be less than {}, found {}", min, found)
|
||||
write!(f, "Double must not be less than {min}, found {found}")
|
||||
}
|
||||
BuiltInExceptions::DoubleTooBig { found, max } => {
|
||||
write!(f, "Double must not be more than {}, found {}", max, found)
|
||||
write!(f, "Double must not be more than {max}, found {found}")
|
||||
}
|
||||
|
||||
BuiltInExceptions::FloatTooSmall { found, min } => {
|
||||
write!(f, "Float must not be less than {}, found {}", min, found)
|
||||
write!(f, "Float must not be less than {min}, found {found}")
|
||||
}
|
||||
BuiltInExceptions::FloatTooBig { found, max } => {
|
||||
write!(f, "Float must not be more than {}, found {}", max, found)
|
||||
write!(f, "Float must not be more than {max}, found {found}")
|
||||
}
|
||||
|
||||
BuiltInExceptions::IntegerTooSmall { found, min } => {
|
||||
write!(f, "Integer must not be less than {}, found {}", min, found)
|
||||
write!(f, "Integer must not be less than {min}, found {found}")
|
||||
}
|
||||
BuiltInExceptions::IntegerTooBig { found, max } => {
|
||||
write!(f, "Integer must not be more than {}, found {}", max, found)
|
||||
write!(f, "Integer must not be more than {max}, found {found}")
|
||||
}
|
||||
|
||||
BuiltInExceptions::LongTooSmall { found, min } => {
|
||||
write!(f, "Long must not be less than {}, found {}", min, found)
|
||||
write!(f, "Long must not be less than {min}, found {found}")
|
||||
}
|
||||
BuiltInExceptions::LongTooBig { found, max } => {
|
||||
write!(f, "Long must not be more than {}, found {}", max, found)
|
||||
write!(f, "Long must not be more than {max}, found {found}")
|
||||
}
|
||||
|
||||
BuiltInExceptions::LiteralIncorrect { expected } => {
|
||||
write!(f, "Expected literal {}", expected)
|
||||
write!(f, "Expected literal {expected}")
|
||||
}
|
||||
|
||||
BuiltInExceptions::ReaderExpectedStartOfQuote => {
|
||||
|
@ -97,25 +97,25 @@ impl fmt::Debug for BuiltInExceptions {
|
|||
)
|
||||
}
|
||||
BuiltInExceptions::ReaderInvalidInt { value } => {
|
||||
write!(f, "Invalid Integer '{}'", value)
|
||||
write!(f, "Invalid Integer '{value}'")
|
||||
}
|
||||
BuiltInExceptions::ReaderExpectedInt => {
|
||||
write!(f, "Expected Integer")
|
||||
}
|
||||
BuiltInExceptions::ReaderInvalidLong { value } => {
|
||||
write!(f, "Invalid long '{}'", value)
|
||||
write!(f, "Invalid long '{value}'")
|
||||
}
|
||||
BuiltInExceptions::ReaderExpectedLong => {
|
||||
write!(f, "Expected long")
|
||||
}
|
||||
BuiltInExceptions::ReaderInvalidDouble { value } => {
|
||||
write!(f, "Invalid double '{}'", value)
|
||||
write!(f, "Invalid double '{value}'")
|
||||
}
|
||||
BuiltInExceptions::ReaderExpectedDouble => {
|
||||
write!(f, "Expected double")
|
||||
}
|
||||
BuiltInExceptions::ReaderInvalidFloat { value } => {
|
||||
write!(f, "Invalid Float '{}'", value)
|
||||
write!(f, "Invalid Float '{value}'")
|
||||
}
|
||||
BuiltInExceptions::ReaderExpectedFloat => {
|
||||
write!(f, "Expected Float")
|
||||
|
@ -124,7 +124,7 @@ impl fmt::Debug for BuiltInExceptions {
|
|||
write!(f, "Expected bool")
|
||||
}
|
||||
BuiltInExceptions::ReaderExpectedSymbol { symbol } => {
|
||||
write!(f, "Expected '{}'", symbol)
|
||||
write!(f, "Expected '{symbol}'")
|
||||
}
|
||||
|
||||
BuiltInExceptions::DispatcherUnknownCommand => {
|
||||
|
@ -140,7 +140,7 @@ impl fmt::Debug for BuiltInExceptions {
|
|||
)
|
||||
}
|
||||
BuiltInExceptions::DispatcherParseException { message } => {
|
||||
write!(f, "Could not parse command: {}", message)
|
||||
write!(f, "Could not parse command: {message}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -148,12 +148,12 @@ impl fmt::Debug for BuiltInExceptions {
|
|||
|
||||
impl BuiltInExceptions {
|
||||
pub fn create(self) -> CommandSyntaxException {
|
||||
let message = Message::from(format!("{:?}", self));
|
||||
let message = Message::from(format!("{self:?}"));
|
||||
CommandSyntaxException::create(self, message)
|
||||
}
|
||||
|
||||
pub fn create_with_context(self, reader: &StringReader) -> CommandSyntaxException {
|
||||
let message = Message::from(format!("{:?}", self));
|
||||
let message = Message::from(format!("{self:?}"));
|
||||
CommandSyntaxException::new(self, message, reader.string(), reader.cursor())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -275,7 +275,7 @@ fn execute_redirected_multiple_times() {
|
|||
child2.clone().unwrap().nodes[0].range,
|
||||
child2.clone().unwrap().range
|
||||
);
|
||||
assert_eq!(child2.clone().unwrap().nodes[0].node, concrete_node);
|
||||
assert_eq!(child2.unwrap().nodes[0].node, concrete_node);
|
||||
|
||||
assert_eq!(CommandDispatcher::execute_parsed(parse).unwrap(), 42);
|
||||
}
|
||||
|
@ -406,5 +406,5 @@ fn get_path() {
|
|||
fn find_node_doesnt_exist() {
|
||||
let subject = CommandDispatcher::<()>::new();
|
||||
|
||||
assert_eq!(subject.find_node(&vec!["foo", "bar"]), None)
|
||||
assert_eq!(subject.find_node(&["foo", "bar"]), None)
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ mod tests {
|
|||
let u = Uuid::parse_str("6536bfed-8695-48fd-83a1-ecd24cf2a0fd").unwrap();
|
||||
let mut buf = Vec::new();
|
||||
u.write_into(&mut buf).unwrap();
|
||||
println!("{:?}", buf);
|
||||
println!("{buf:?}");
|
||||
assert_eq!(buf.len(), 16);
|
||||
let u2 = Uuid::read_from(&mut Cursor::new(&buf)).unwrap();
|
||||
assert_eq!(u, u2);
|
||||
|
|
|
@ -186,7 +186,7 @@ impl<'de> Deserialize<'de> for Component {
|
|||
nbt
|
||||
} else {
|
||||
return Err(de::Error::custom(
|
||||
format!("Don't know how to turn {} into a Component", json).as_str(),
|
||||
format!("Don't know how to turn {json} into a Component").as_str(),
|
||||
));
|
||||
};
|
||||
let _separator = Component::parse_separator(&json).map_err(de::Error::custom)?;
|
||||
|
@ -223,7 +223,7 @@ impl<'de> Deserialize<'de> for Component {
|
|||
// ok so it's not an object, if it's an array deserialize every item
|
||||
else if !json.is_array() {
|
||||
return Err(de::Error::custom(
|
||||
format!("Don't know how to turn {} into a Component", json).as_str(),
|
||||
format!("Don't know how to turn {json} into a Component").as_str(),
|
||||
));
|
||||
}
|
||||
let json_array = json.as_array().unwrap();
|
||||
|
|
|
@ -134,8 +134,8 @@ impl Display for TranslatableComponent {
|
|||
impl Display for StringOrComponent {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), fmt::Error> {
|
||||
match self {
|
||||
StringOrComponent::String(s) => write!(f, "{}", s),
|
||||
StringOrComponent::Component(c) => write!(f, "{}", c),
|
||||
StringOrComponent::String(s) => write!(f, "{s}"),
|
||||
StringOrComponent::Component(c) => write!(f, "{c}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -230,7 +230,7 @@ impl Client {
|
|||
}
|
||||
},
|
||||
Err(e) => {
|
||||
panic!("Error: {:?}", e);
|
||||
panic!("Error: {e:?}");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -300,7 +300,7 @@ impl Client {
|
|||
if IGNORE_ERRORS {
|
||||
continue;
|
||||
} else {
|
||||
panic!("Error handling packet: {}", e);
|
||||
panic!("Error handling packet: {e}");
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -308,7 +308,7 @@ impl Client {
|
|||
if IGNORE_ERRORS {
|
||||
warn!("{}", e);
|
||||
match e {
|
||||
ReadPacketError::FrameSplitter { .. } => panic!("Error: {:?}", e),
|
||||
ReadPacketError::FrameSplitter { .. } => panic!("Error: {e:?}"),
|
||||
_ => continue,
|
||||
}
|
||||
} else {
|
||||
|
@ -422,8 +422,8 @@ impl Client {
|
|||
|
||||
tx.send(Event::Login).unwrap();
|
||||
}
|
||||
ClientboundGamePacket::UpdateViewDistance(p) => {
|
||||
debug!("Got view distance packet {:?}", p);
|
||||
ClientboundGamePacket::SetChunkCacheRadius(p) => {
|
||||
debug!("Got set chunk cache radius packet {:?}", p);
|
||||
}
|
||||
ClientboundGamePacket::CustomPayload(p) => {
|
||||
debug!("Got custom payload packet {:?}", p);
|
||||
|
@ -581,7 +581,7 @@ impl Client {
|
|||
ClientboundGamePacket::UpdateAttributes(_p) => {
|
||||
// debug!("Got update attributes packet {:?}", p);
|
||||
}
|
||||
ClientboundGamePacket::EntityVelocity(_p) => {
|
||||
ClientboundGamePacket::SetEntityMotion(_p) => {
|
||||
// debug!("Got entity velocity packet {:?}", p);
|
||||
}
|
||||
ClientboundGamePacket::SetEntityLink(p) => {
|
||||
|
@ -743,10 +743,8 @@ impl Client {
|
|||
ClientboundGamePacket::SetBorderWarningDelay(_) => {}
|
||||
ClientboundGamePacket::SetBorderWarningDistance(_) => {}
|
||||
ClientboundGamePacket::SetCamera(_) => {}
|
||||
ClientboundGamePacket::SetChunkCacheRadius(_) => {}
|
||||
ClientboundGamePacket::SetDisplayChatPreview(_) => {}
|
||||
ClientboundGamePacket::SetDisplayObjective(_) => {}
|
||||
ClientboundGamePacket::SetEntityMotion(_) => {}
|
||||
ClientboundGamePacket::SetObjective(_) => {}
|
||||
ClientboundGamePacket::SetPassengers(_) => {}
|
||||
ClientboundGamePacket::SetPlayerTeam(_) => {}
|
||||
|
|
|
@ -20,7 +20,7 @@ pub enum Err {
|
|||
impl Debug for Err {
|
||||
fn fmt(&self, f: &mut Formatter) -> Result<(), Error> {
|
||||
match self {
|
||||
Err::InvalidDifficulty(s) => write!(f, "Invalid difficulty: {}", s),
|
||||
Err::InvalidDifficulty(s) => write!(f, "Invalid difficulty: {s}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ impl Difficulty {
|
|||
2 => Difficulty::NORMAL,
|
||||
3 => Difficulty::HARD,
|
||||
// this shouldn't be possible because of the modulo, so panicking is fine
|
||||
_ => panic!("Unknown difficulty id: {}", id),
|
||||
_ => panic!("Unknown difficulty id: {id}"),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ impl Axis {
|
|||
0 => Axis::X,
|
||||
1 => Axis::Y,
|
||||
2 => Axis::Z,
|
||||
_ => panic!("Invalid ordinal {}", ordinal),
|
||||
_ => panic!("Invalid ordinal {ordinal}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ impl GameType {
|
|||
"creative" => GameType::CREATIVE,
|
||||
"adventure" => GameType::ADVENTURE,
|
||||
"spectator" => GameType::SPECTATOR,
|
||||
_ => panic!("Unknown game type name: {}", name),
|
||||
_ => panic!("Unknown game type name: {name}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,10 +10,10 @@ pub enum Error {
|
|||
impl std::fmt::Display for Error {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
match self {
|
||||
Error::InvalidTagType(id) => write!(f, "Invalid tag type: {}", id),
|
||||
Error::InvalidTagType(id) => write!(f, "Invalid tag type: {id}"),
|
||||
Error::InvalidTag => write!(f, "Invalid tag"),
|
||||
Error::WriteError(e) => write!(f, "Write error: {}", e),
|
||||
Error::Utf8Error(e) => write!(f, "Utf8 error: {}", e),
|
||||
Error::WriteError(e) => write!(f, "Write error: {e}"),
|
||||
Error::Utf8Error(e) => write!(f, "Utf8 error: {e}"),
|
||||
Error::UnexpectedEof => write!(f, "Unexpected EOF"),
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -19,7 +19,7 @@ pub fn box_shape(
|
|||
max_y: f64,
|
||||
max_z: f64,
|
||||
) -> VoxelShape {
|
||||
assert!(min_x >= 0., "min_x must be >= 0 but was {}", min_x);
|
||||
assert!(min_x >= 0., "min_x must be >= 0 but was {min_x}");
|
||||
assert!(min_y >= 0.);
|
||||
assert!(min_z >= 0.);
|
||||
assert!(max_x >= 0.);
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundEntityVelocityPacket {
|
||||
#[var]
|
||||
pub entity_id: u32,
|
||||
pub x_vel: i16,
|
||||
pub y_vel: i16,
|
||||
pub z_vel: i16,
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundUpdateViewDistancePacket {
|
||||
#[var]
|
||||
pub view_distance: i32,
|
||||
}
|
|
@ -23,7 +23,6 @@ pub mod clientbound_custom_sound_packet;
|
|||
pub mod clientbound_delete_chat_packet;
|
||||
pub mod clientbound_disconnect_packet;
|
||||
pub mod clientbound_entity_event_packet;
|
||||
pub mod clientbound_entity_velocity_packet;
|
||||
pub mod clientbound_explode_packet;
|
||||
pub mod clientbound_forget_level_chunk_packet;
|
||||
pub mod clientbound_game_event_packet;
|
||||
|
@ -105,7 +104,6 @@ pub mod clientbound_update_attributes_packet;
|
|||
pub mod clientbound_update_mob_effect_packet;
|
||||
pub mod clientbound_update_recipes_packet;
|
||||
pub mod clientbound_update_tags_packet;
|
||||
pub mod clientbound_update_view_distance_packet;
|
||||
pub mod serverbound_accept_teleportation_packet;
|
||||
pub mod serverbound_block_entity_tag_query;
|
||||
pub mod serverbound_change_difficulty_packet;
|
||||
|
|
|
@ -35,7 +35,7 @@ fn packet_encoder<P: ProtocolPacket + std::fmt::Debug>(
|
|||
return Err(PacketEncodeError::TooBig {
|
||||
actual: buf.len(),
|
||||
maximum: MAXIMUM_UNCOMPRESSED_LENGTH as usize,
|
||||
packet_string: format!("{:?}", packet),
|
||||
packet_string: format!("{packet:?}"),
|
||||
});
|
||||
}
|
||||
Ok(buf)
|
||||
|
|
|
@ -76,8 +76,8 @@ pub fn registry(input: TokenStream) -> TokenStream {
|
|||
|
||||
let max_id = input.items.len() as u32;
|
||||
|
||||
let doc_0 = format!("Transmutes a u32 to a {}.", name);
|
||||
let doc_1 = format!("The `id` should be at most {}.", max_id);
|
||||
let doc_0 = format!("Transmutes a u32 to a {name}.");
|
||||
let doc_1 = format!("The `id` should be at most {max_id}.");
|
||||
|
||||
generated.extend(quote! {
|
||||
impl #name {
|
||||
|
@ -97,7 +97,7 @@ pub fn registry(input: TokenStream) -> TokenStream {
|
|||
}
|
||||
});
|
||||
|
||||
let doc_0 = format!("Safely transmutes a u32 to a {}.", name);
|
||||
let doc_0 = format!("Safely transmutes a u32 to a {name}.");
|
||||
|
||||
generated.extend(quote! {
|
||||
impl TryFrom<u32> for #name {
|
||||
|
|
|
@ -158,7 +158,7 @@ impl Chunk {
|
|||
}
|
||||
|
||||
pub fn section_index(&self, y: i32, min_y: i32) -> u32 {
|
||||
assert!(y >= min_y, "y ({}) must be at least {}", y, min_y);
|
||||
assert!(y >= min_y, "y ({y}) must be at least {min_y}");
|
||||
let min_section_index = min_y.div_floor(16);
|
||||
(y.div_floor(16) - min_section_index) as u32
|
||||
}
|
||||
|
|
|
@ -8,11 +8,43 @@ COLLISION_BLOCKS_RS_DIR = get_dir_location(
|
|||
|
||||
|
||||
def generate_block_shapes(blocks: dict, shapes: dict, block_states_report, block_datas_burger, mappings: Mappings):
|
||||
code = generate_block_shapes_code(blocks, shapes, block_states_report, block_datas_burger, mappings)
|
||||
blocks, shapes = simplify_shapes(blocks, shapes)
|
||||
|
||||
code = generate_block_shapes_code(
|
||||
blocks, shapes, block_states_report, block_datas_burger, mappings)
|
||||
with open(COLLISION_BLOCKS_RS_DIR, 'w') as f:
|
||||
f.write(code)
|
||||
|
||||
|
||||
def simplify_shapes(blocks: dict, shapes: dict):
|
||||
shape_to_new_id = {}
|
||||
new_id_increment = 0
|
||||
|
||||
new_shapes = {}
|
||||
old_id_to_new_id = {}
|
||||
|
||||
for shape_id, shape in sorted(shapes.items(), key=lambda shape: int(shape[0])):
|
||||
# tuples are hashable
|
||||
shape_as_tuple = tuple(map(tuple, shape))
|
||||
if shape_as_tuple not in shape_to_new_id:
|
||||
shape_to_new_id[shape_as_tuple] = new_id_increment
|
||||
old_id_to_new_id[shape_id] = new_id_increment
|
||||
new_shapes[new_id_increment] = shape
|
||||
new_id_increment += 1
|
||||
else:
|
||||
old_id_to_new_id[shape_id] = shape_to_new_id[shape_as_tuple]
|
||||
|
||||
# now map the blocks to the new shape ids
|
||||
for block_id, shape_ids in blocks.items():
|
||||
if isinstance(shape_ids, int):
|
||||
blocks[block_id] = old_id_to_new_id[str(shape_ids)]
|
||||
else:
|
||||
blocks[block_id] = [old_id_to_new_id[str(shape_id)]
|
||||
for shape_id in shape_ids]
|
||||
|
||||
return blocks, new_shapes
|
||||
|
||||
|
||||
def generate_block_shapes_code(blocks: dict, shapes: dict, block_states_report, block_datas_burger, mappings: Mappings):
|
||||
# look at downloads/generator-mod-*/blockCollisionShapes.json for format of blocks and shapes
|
||||
|
||||
|
@ -39,7 +71,7 @@ def generate_block_shapes_code(blocks: dict, shapes: dict, block_states_report,
|
|||
variant_values = []
|
||||
for value in tuple(possible_state.get('properties', {}).values()):
|
||||
variant_values.append(to_camel_case(value))
|
||||
|
||||
|
||||
if variant_values == []:
|
||||
variant_name = to_camel_case(block_id)
|
||||
else:
|
||||
|
@ -47,13 +79,13 @@ def generate_block_shapes_code(blocks: dict, shapes: dict, block_states_report,
|
|||
|
||||
if shape_id not in shape_ids_to_variants:
|
||||
shape_ids_to_variants[shape_id] = []
|
||||
shape_ids_to_variants[shape_id].append(f'BlockState::{variant_name}')
|
||||
shape_ids_to_variants[shape_id].append(
|
||||
f'BlockState::{variant_name}')
|
||||
# shape 1 is the most common so we have a _ => &SHAPE1 at the end
|
||||
del shape_ids_to_variants[1]
|
||||
for shape_id, variants in shape_ids_to_variants.items():
|
||||
generated_match_inner_code += f'{"|".join(variants)} => &SHAPE{shape_id},\n'
|
||||
|
||||
|
||||
return f'''
|
||||
//! Autogenerated block collisions for every block
|
||||
|
||||
|
@ -67,7 +99,7 @@ use crate::collision::{{self, Shapes}};
|
|||
use azalea_block::*;
|
||||
use lazy_static::lazy_static;
|
||||
|
||||
trait BlockWithShape {{
|
||||
pub trait BlockWithShape {{
|
||||
fn shape(&self) -> &'static VoxelShape;
|
||||
}}
|
||||
|
||||
|
@ -106,5 +138,3 @@ def generate_code_for_shape(shape_id: str, parts: list[list[float]]):
|
|||
code += f' {steps[-1]}\n'
|
||||
code += '};\n'
|
||||
return code
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue