Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

Commit

Permalink
remove players when they disconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
dskprt committed Apr 1, 2021
1 parent f46bf57 commit 2ee42f6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
7 changes: 6 additions & 1 deletion nylium.Core/Networking/MinecraftClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,12 @@ protected override void OnDisconnected() {
World.Format.Save(Player);
World.PlayerEntities.Remove(Player);

// TODO remove player from player list and world client-side here
SP32PlayerInfo playerInfo = new(Player.Uuid);
Server.MulticastAsync(playerInfo, this);

// TODO is there a packet to destroy only one entity?
SP36DestroyEntities destroyEntities = new(new int[] { Player.EntityId });
Server.MulticastAsync(destroyEntities, this);
}

ProtocolState = ProtocolState.Unknown;
Expand Down
18 changes: 18 additions & 0 deletions nylium.Core/Networking/Packet/Server/Play/SP36DestroyEntities.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using nylium.Core.Networking.DataTypes;

namespace nylium.Core.Networking.Packet.Server.Play {

[Packet(0x36, ProtocolState.Play, PacketSide.Server)]
public class SP36DestroyEntities : MinecraftPacket {

public int[] EntityIds { get; }

public SP36DestroyEntities(int[] entityIds) {
EntityIds = entityIds;

WriteVarInt(entityIds.Length);
WriteArray<int, VarInt>(entityIds);
}
}
}

0 comments on commit 2ee42f6

Please sign in to comment.