Box block update sign text to reduce enum size from 268 bytes (large_enum_variant)
warning: large size difference between variants --> src/world/mod.rs:54:5 | 54 | / UpdateSignText( 55 | | Position, 56 | | format::Component, 57 | | format::Component, 58 | | format::Component, 59 | | format::Component, 60 | | ), | |_____^ this variant is 268 bytes | = note: `#[warn(clippy::large_enum_variant)]` on by default note: and the second-largest variant is 12 bytes: --> src/world/mod.rs:53:5 | 53 | Remove(Position), | ^^^^^^^^^^^^^^^^ help: consider boxing the large fields to reduce the total size of the enum --> src/world/mod.rs:54:5 | 54 | / UpdateSignText( 55 | | Position, 56 | | format::Component, 57 | | format::Component, 58 | | format::Component, 59 | | format::Component, 60 | | ), | |_____^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#large_enum_variant
This commit is contained in:
parent
f88036ea4e
commit
0d1e86a233
|
@ -1576,13 +1576,13 @@ impl Server {
|
|||
nbt.1.get("Text4").unwrap().as_str().unwrap(),
|
||||
);
|
||||
self.world.add_block_entity_action(
|
||||
world::BlockEntityAction::UpdateSignText(
|
||||
world::BlockEntityAction::UpdateSignText(Box::new((
|
||||
block_update.location,
|
||||
line1,
|
||||
line2,
|
||||
line3,
|
||||
line4,
|
||||
),
|
||||
))),
|
||||
);
|
||||
}
|
||||
//10 => // Unused
|
||||
|
@ -1610,13 +1610,13 @@ impl Server {
|
|||
format::convert_legacy(&mut update_sign.line3);
|
||||
format::convert_legacy(&mut update_sign.line4);
|
||||
self.world
|
||||
.add_block_entity_action(world::BlockEntityAction::UpdateSignText(
|
||||
.add_block_entity_action(world::BlockEntityAction::UpdateSignText(Box::new((
|
||||
update_sign.location,
|
||||
update_sign.line1,
|
||||
update_sign.line2,
|
||||
update_sign.line3,
|
||||
update_sign.line4,
|
||||
));
|
||||
))));
|
||||
}
|
||||
|
||||
fn on_sign_update_u16(&mut self, mut update_sign: packet::play::clientbound::UpdateSign_u16) {
|
||||
|
@ -1625,13 +1625,13 @@ impl Server {
|
|||
format::convert_legacy(&mut update_sign.line3);
|
||||
format::convert_legacy(&mut update_sign.line4);
|
||||
self.world
|
||||
.add_block_entity_action(world::BlockEntityAction::UpdateSignText(
|
||||
.add_block_entity_action(world::BlockEntityAction::UpdateSignText(Box::new((
|
||||
Position::new(update_sign.x, update_sign.y as i32, update_sign.z),
|
||||
update_sign.line1,
|
||||
update_sign.line2,
|
||||
update_sign.line3,
|
||||
update_sign.line4,
|
||||
));
|
||||
))));
|
||||
}
|
||||
|
||||
fn on_player_info_string(
|
||||
|
|
|
@ -52,11 +52,13 @@ pub enum BlockEntityAction {
|
|||
Create(Position),
|
||||
Remove(Position),
|
||||
UpdateSignText(
|
||||
Position,
|
||||
format::Component,
|
||||
format::Component,
|
||||
format::Component,
|
||||
format::Component,
|
||||
Box<(
|
||||
Position,
|
||||
format::Component,
|
||||
format::Component,
|
||||
format::Component,
|
||||
format::Component,
|
||||
)>,
|
||||
),
|
||||
}
|
||||
|
||||
|
@ -240,7 +242,8 @@ impl World {
|
|||
}
|
||||
}
|
||||
}
|
||||
BlockEntityAction::UpdateSignText(pos, line1, line2, line3, line4) => {
|
||||
BlockEntityAction::UpdateSignText(bx) => {
|
||||
let (pos, line1, line2, line3, line4) = *bx;
|
||||
if let Some(chunk) = self.chunks.get(&CPos(pos.x >> 4, pos.z >> 4)) {
|
||||
if let Some(entity) = chunk.block_entities.get(&pos) {
|
||||
if let Some(sign) = m.get_component_mut(*entity, sign_info) {
|
||||
|
|
Loading…
Reference in New Issue