Skip to content

Commit 4da2c3e

Browse files
committed
fix: Always send player info even when no skin
1 parent 7619523 commit 4da2c3e

File tree

3 files changed

+28
-25
lines changed

3 files changed

+28
-25
lines changed

crates/minecraft_packets/src/play/player_info_update_packet.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,15 @@ pub struct PlayerInfoUpdatePacket {
1414

1515
impl PlayerInfoUpdatePacket {
1616
pub fn skin(name: String, uuid: Uuid, property: Property) -> Self {
17-
let properties = LengthPaddedVec::new(vec![property]);
17+
Self::new(name, uuid, vec![property])
18+
}
19+
20+
pub fn skinless(name: String, uuid: Uuid) -> Self {
21+
Self::new(name, uuid, Vec::new())
22+
}
23+
24+
fn new(name: String, uuid: Uuid, properties: Vec<Property>) -> Self {
25+
let properties = LengthPaddedVec::new(properties);
1826
let add_player_action = AddPlayer {
1927
name,
2028
properties,

pico_limbo/src/handlers/configuration.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ use pico_structures::prelude::SchematicError;
2727
use pico_text_component::prelude::Component;
2828
use registries::{Registries, get_dimension_index, get_registries, get_void_biome_index};
2929
use std::num::TryFromIntError;
30-
use tracing::debug;
3130

3231
impl PacketHandler for AcknowledgeConfigurationPacket {
3332
fn handle(
@@ -276,13 +275,12 @@ fn send_skin_packets(
276275
None
277276
};
278277

279-
if let Some(textures) = textures {
280-
let packet = PlayerInfoUpdatePacket::skin(username, unique_id, textures);
281-
Some(PacketRegistry::PlayerInfoUpdate(packet))
278+
let packet = if let Some(textures) = textures {
279+
PlayerInfoUpdatePacket::skin(username, unique_id, textures)
282280
} else {
283-
debug!("No skin for player {username}");
284-
None
285-
}
281+
PlayerInfoUpdatePacket::skinless(username, unique_id)
282+
};
283+
PacketRegistry::PlayerInfoUpdate(packet)
286284
});
287285
}
288286

pico_limbo/src/server/batch.rs

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::pin::Pin;
55
use std::task::{Context, Poll};
66

77
type AsyncClosure<T> =
8-
Box<dyn FnOnce() -> Pin<Box<dyn Future<Output = Option<T>> + Send>> + Send + 'static>;
8+
Box<dyn FnOnce() -> Pin<Box<dyn Future<Output = T> + Send>> + Send + 'static>;
99

1010
enum Producer<T> {
1111
SyncClosure(Box<dyn FnOnce() -> T + Send + 'static>),
@@ -36,9 +36,9 @@ impl<T: Send + 'static> Batch<T> {
3636
pub fn queue_async<F, Fut>(&mut self, f: F)
3737
where
3838
F: FnOnce() -> Fut + Send + 'static,
39-
Fut: Future<Output = Option<T>> + Send + 'static,
39+
Fut: Future<Output = T> + Send + 'static,
4040
{
41-
let closure = move || -> Pin<Box<dyn Future<Output = Option<T>> + Send>> { Box::pin(f()) };
41+
let closure = move || -> Pin<Box<dyn Future<Output = T> + Send>> { Box::pin(f()) };
4242
self.producers
4343
.push_back(Producer::AsyncClosure(Box::new(closure)));
4444
}
@@ -63,7 +63,7 @@ impl<T: Send + 'static> Batch<T> {
6363

6464
enum Current<T> {
6565
Idle,
66-
Future(Pin<Box<dyn Future<Output = Option<T>> + Send>>),
66+
Future(Pin<Box<dyn Future<Output = T> + Send>>),
6767
Iterator(Box<dyn Iterator<Item = T> + Send>),
6868
}
6969

@@ -80,18 +80,15 @@ impl<T: Send + 'static> Stream for BatchStream<T> {
8080

8181
loop {
8282
match &mut this.current {
83-
Current::Future(fut) => match fut.as_mut().poll(cx) {
84-
Poll::Ready(Some(item)) => {
85-
this.current = Current::Idle;
86-
return Poll::Ready(Some(item));
87-
}
88-
Poll::Ready(None) => {
89-
this.current = Current::Idle;
90-
}
91-
Poll::Pending => {
92-
return Poll::Pending;
93-
}
94-
},
83+
Current::Future(fut) => {
84+
return match fut.as_mut().poll(cx) {
85+
Poll::Ready(item) => {
86+
this.current = Current::Idle;
87+
Poll::Ready(Some(item))
88+
}
89+
Poll::Pending => Poll::Pending,
90+
};
91+
}
9592
Current::Iterator(iter) => {
9693
if let Some(item) = iter.next() {
9794
return Poll::Ready(Some(item));
@@ -127,7 +124,7 @@ mod tests {
127124
let mut batch = Batch::new();
128125

129126
batch.queue(|| 1);
130-
batch.queue_async(|| async { Some(2) });
127+
batch.queue_async(|| async { 2 });
131128
batch.chain_iter(3..5);
132129

133130
let mut stream = batch.into_stream();

0 commit comments

Comments
 (0)