3232import net .minecraft .server .world .ServerChunkManager ;
3333import net .minecraft .server .world .ServerWorld ;
3434import net .minecraft .server .world .ThreadedAnvilChunkStorage ;
35- import net .minecraft .text .LiteralText ;
3635import net .minecraft .text .MutableText ;
3736import net .minecraft .text .Text ;
38- import net .minecraft .text .TranslatableText ;
3937import net .minecraft .util .Formatting ;
4038import net .minecraft .util .Identifier ;
4139import net .minecraft .util .registry .Registry ;
5856import xyz .nucleoid .disguiselib .impl .mixin .accessor .PlayerListS2CPacketAccessor ;
5957import xyz .nucleoid .disguiselib .impl .mixin .accessor .ThreadedAnvilChunkStorageAccessor ;
6058
61- import java .util .Arrays ;
62- import java .util .Collection ;
63- import java .util .Collections ;
64- import java .util .List ;
65- import java .util .UUID ;
59+ import java .util .*;
6660import java .util .stream .Collectors ;
6761
6862import static net .minecraft .entity .EntityType .PLAYER ;
@@ -168,7 +162,7 @@ public void disguiseAs(EntityType<?> entityType) {
168162 // Previous type was player, we have to send a player remove packet
169163 PlayerListS2CPacket listPacket = new PlayerListS2CPacket (REMOVE_PLAYER );
170164 PlayerListS2CPacketAccessor listPacketAccessor = (PlayerListS2CPacketAccessor ) listPacket ;
171- listPacketAccessor .setEntries (Arrays .asList (new PlayerListS2CPacket .Entry (this .disguiselib$profile , 0 , GameMode .SURVIVAL , new LiteralText (this .disguiselib$profile .getName ()))));
165+ listPacketAccessor .setEntries (Arrays .asList (new PlayerListS2CPacket .Entry (this .disguiselib$profile , 0 , GameMode .SURVIVAL , Text . literal (this .disguiselib$profile .getName ()), null )));
172166 manager .sendToAll (listPacket );
173167 }
174168
@@ -347,7 +341,7 @@ public void setGameProfile(@Nullable GameProfile gameProfile) {
347341 */
348342 @ Unique
349343 private void disguiselib$constructFakePlayer (@ NotNull GameProfile profile ) {
350- this .disguiselib$disguiseEntity = new ServerPlayerEntity (world .getServer (), (ServerWorld ) world , profile );
344+ this .disguiselib$disguiseEntity = new ServerPlayerEntity (world .getServer (), (ServerWorld ) world , profile , null );
351345 this .disguiselib$disguiseEntity .getDataTracker ().set (getPLAYER_MODEL_PARTS (), (byte ) 0x7f );
352346 }
353347
@@ -372,7 +366,7 @@ public void setGameProfile(@Nullable GameProfile gameProfile) {
372366 PlayerListS2CPacket packet = new PlayerListS2CPacket (REMOVE_PLAYER );
373367 //noinspection ConstantConditions
374368 PlayerListS2CPacketAccessor accessor = (PlayerListS2CPacketAccessor ) packet ;
375- accessor .setEntries (Arrays .asList (new PlayerListS2CPacket .Entry (this .disguiselib$profile , 0 , GameMode .SURVIVAL , new LiteralText (this .disguiselib$profile .getName ()))));
369+ accessor .setEntries (Arrays .asList (new PlayerListS2CPacket .Entry (this .disguiselib$profile , 0 , GameMode .SURVIVAL , Text . literal (this .disguiselib$profile .getName ()), null )));
376370
377371 PlayerManager playerManager = this .world .getServer ().getPlayerManager ();
378372 playerManager .sendToAll (packet );
@@ -390,14 +384,15 @@ public void setGameProfile(@Nullable GameProfile gameProfile) {
390384 ServerWorld targetWorld = player .getWorld ();
391385
392386 player .networkHandler .sendPacket (new PlayerRespawnS2CPacket (
393- targetWorld .method_40134 (), // getDimension()
387+ targetWorld .getDimensionKey (), // getDimension()
394388 targetWorld .getRegistryKey (),
395389 BiomeAccess .hashSeed (targetWorld .getSeed ()),
396390 player .interactionManager .getGameMode (),
397391 player .interactionManager .getPreviousGameMode (),
398392 targetWorld .isDebugWorld (),
399393 targetWorld .isFlat (),
400- true
394+ true ,
395+ Optional .empty ()
401396 ));
402397 player .networkHandler .requestTeleport (player .getX (), player .getY (), player .getZ (), player .getYaw (), player .getPitch ());
403398
@@ -451,8 +446,8 @@ private void postTick(CallbackInfo ci) {
451446 this .world .getServer ().getPlayerManager ().sendToDimension (new EntityPositionS2CPacket (this .disguiselib$entity ), this .world .getRegistryKey ());
452447 else if (this .disguiselib$entity instanceof ServerPlayerEntity && ++this .disguiselib$ticks % 40 == 0 && this .disguiselib$disguiseEntity != null ) {
453448 // "Disguised as" message
454- MutableText msg = new LiteralText ("You are disguised as " )
455- .append (new TranslatableText (this .disguiselib$disguiseEntity .getType ().getTranslationKey ()))
449+ MutableText msg = Text . literal ("You are disguised as " )
450+ .append (Text . translatable (this .disguiselib$disguiseEntity .getType ().getTranslationKey ()))
456451 .formatted (Formatting .GREEN );
457452
458453 ((ServerPlayerEntity ) this .disguiselib$entity ).sendMessage (msg , true );
@@ -479,7 +474,7 @@ private void onRemove(CallbackInfo ci) {
479474
480475 GameProfile profile = new GameProfile (this .disguiselib$entity .getUuid (), this .getName ().getString ());
481476 // Arrays.asList is needed as we PlayerList needs mutable list
482- listS2CPacketAccessor .setEntries (Arrays .asList (new PlayerListS2CPacket .Entry (profile , 0 , GameMode .SURVIVAL , this .getName ())));
477+ listS2CPacketAccessor .setEntries (Arrays .asList (new PlayerListS2CPacket .Entry (profile , 0 , GameMode .SURVIVAL , this .getName (), null )));
483478
484479 PlayerManager manager = this .world .getServer ().getPlayerManager ();
485480 manager .sendToAll (packet );
0 commit comments