feat: show credits on exiting end

This commit is contained in:
Alexander Medvedev 2026-07-15 20:50:13 +02:00
parent c7be511fbc
commit 21e7f1418a
3 changed files with 51 additions and 0 deletions

View File

@ -39,6 +39,7 @@ pub mod set_health;
pub mod set_player_gamemode;
pub mod set_time;
pub mod set_title;
pub mod show_credits;
pub mod start_game;
pub mod take_item_actor;
pub mod transfer;
@ -87,6 +88,7 @@ pub use set_health::*;
pub use set_player_gamemode::*;
pub use set_time::*;
pub use set_title::*;
pub use show_credits::*;
pub use start_game::*;
pub use take_item_actor::*;
pub use transfer::*;

View File

@ -0,0 +1,22 @@
use crate::{
codec::{var_int::VarInt, var_ulong::VarULong},
serial::PacketWrite,
};
use pumpkin_macros::packet;
#[derive(PacketWrite)]
#[packet(75)]
pub struct CShowCredits {
pub player_runtime_id: VarULong,
pub status: VarInt,
}
impl CShowCredits {
#[must_use]
pub const fn new(player_runtime_id: VarULong, status: VarInt) -> Self {
Self {
player_runtime_id,
status,
}
}
}

View File

@ -131,6 +131,33 @@ impl PortalType {
})
} else {
// Leaving the End through the exit portal: return to overworld spawn
if let Some(player) =
current_level.get_player_by_id(caller.get_entity().entity_id)
{
match player.client.as_ref() {
crate::net::ClientPlatform::Java(client) => {
client
.enqueue_packet(&pumpkin_protocol::java::client::play::CGameEvent::new(
pumpkin_protocol::java::client::play::GameEvent::WinGame,
1.0,
))
.await;
}
crate::net::ClientPlatform::Bedrock(client) => {
client
.send_game_packet(
&pumpkin_protocol::bedrock::client::CShowCredits::new(
pumpkin_protocol::codec::var_ulong::VarULong(
caller.get_entity().entity_id as u64,
),
pumpkin_protocol::codec::var_int::VarInt(0),
),
)
.await;
}
}
}
let info = dest_world.level_info.load();
Some(TeleportTransition {
new_world: dest_world,