11package me .tofaa .entitylib .wrapper ;
22
3+ import com .github .retrooper .packetevents .manager .server .ServerVersion ;
34import com .github .retrooper .packetevents .protocol .entity .type .EntityTypes ;
4- import com .github .retrooper .packetevents .protocol .player .* ;
5- import com .github .retrooper .packetevents .protocol .world . Location ;
6- import com .github .retrooper .packetevents .util . Vector3d ;
5+ import com .github .retrooper .packetevents .protocol .player .GameMode ;
6+ import com .github .retrooper .packetevents .protocol .player . TextureProperty ;
7+ import com .github .retrooper .packetevents .protocol . player . UserProfile ;
78import com .github .retrooper .packetevents .wrapper .PacketWrapper ;
8- import com .github .retrooper .packetevents .wrapper .play .server .*;
9+ import com .github .retrooper .packetevents .wrapper .play .server .WrapperPlayServerDestroyEntities ;
10+ import com .github .retrooper .packetevents .wrapper .play .server .WrapperPlayServerEntityHeadLook ;
11+ import com .github .retrooper .packetevents .wrapper .play .server .WrapperPlayServerEntityRotation ;
12+ import com .github .retrooper .packetevents .wrapper .play .server .WrapperPlayServerPlayerInfoRemove ;
13+ import com .github .retrooper .packetevents .wrapper .play .server .WrapperPlayServerPlayerInfoUpdate ;
14+ import com .github .retrooper .packetevents .wrapper .play .server .WrapperPlayServerSpawnPlayer ;
915import me .tofaa .entitylib .EntityLib ;
1016import me .tofaa .entitylib .meta .EntityMeta ;
17+ import java .util .EnumSet ;
18+ import java .util .List ;
19+ import java .util .UUID ;
1120import net .kyori .adventure .text .Component ;
12-
13- import java .util .*;
21+ import org .jetbrains .annotations .NotNull ;
1422
1523public class WrapperPlayer extends WrapperLivingEntity {
1624
@@ -25,6 +33,27 @@ public WrapperPlayer(UserProfile profile, int entityId) {
2533 this .profile = profile ;
2634 }
2735
36+ @ Override
37+ protected PacketWrapper <?> createSpawnPacket () {
38+ if (EntityLib .getApi ().getPacketEvents ().getServerManager ().getVersion ().isOlderThanOrEquals (ServerVersion .V_1_20_1 )) {
39+ return new WrapperPlayServerSpawnPlayer (
40+ getEntityId (),
41+ profile .getUUID (),
42+ getLocation (),
43+ getEntityMeta ().entityData ()
44+ );
45+ }
46+ return super .createSpawnPacket ();
47+ }
48+
49+ @ Override
50+ public @ NotNull List <PacketWrapper <?>> createSpawnPackets () {
51+ final List <PacketWrapper <?>> packets = super .createSpawnPackets ();
52+ packets .add (new WrapperPlayServerEntityRotation (getEntityId (), getYaw (), getPitch (), isOnGround ()));
53+ packets .add (new WrapperPlayServerEntityHeadLook (getEntityId (), getYaw ()));
54+ return packets ;
55+ }
56+
2857 public WrapperPlayServerPlayerInfoUpdate tabListPacket () {
2958 EnumSet <WrapperPlayServerPlayerInfoUpdate .Action > actions = EnumSet .of (
3059 WrapperPlayServerPlayerInfoUpdate .Action .ADD_PLAYER ,
0 commit comments