Fix recording of client player's metadata after respawn (fixes #212)

1.15 removed the data tracker syncing from the spawn packet, so we now need to
send that explicitly.
This commit is contained in:
Jonas Herzig
2020-06-28 16:33:57 +02:00
parent 8e1f9f5a9c
commit 0ba651d19c
2 changed files with 10 additions and 13 deletions

View File

@@ -99,17 +99,14 @@ public class RecordingEventHandler extends EventRegistrations {
} }
//#endif //#endif
public void onPlayerJoin() { public void spawnRecordingPlayer() {
try { try {
packetListener.save(new PlayerSpawnS2CPacket(mc.player)); ClientPlayerEntity player = mc.player;
} catch(Exception e1) { assert player != null;
e1.printStackTrace(); packetListener.save(new PlayerSpawnS2CPacket(player));
} //#if MC>=11500
} packetListener.save(new EntityTrackerUpdateS2CPacket(player.getEntityId(), player.getDataTracker(), true));
//#endif
public void onPlayerRespawn() {
try {
packetListener.save(new PlayerSpawnS2CPacket(mc.player));
lastX = lastY = lastZ = null; lastX = lastY = lastZ = null;
} catch(Exception e) { } catch(Exception e) {
e.printStackTrace(); e.printStackTrace();

View File

@@ -81,7 +81,7 @@ public abstract class MixinNetHandlerPlayClient {
// Only add spawn packet for our own player and only if he isn't known yet // Only add spawn packet for our own player and only if he isn't known yet
if (data.getUuid().equals(mcStatic.player.getGameProfile().getId()) if (data.getUuid().equals(mcStatic.player.getGameProfile().getId())
&& !this.playerListEntries.containsKey(data.getUuid())) { && !this.playerListEntries.containsKey(data.getUuid())) {
handler.onPlayerJoin(); handler.spawnRecordingPlayer();
} }
} }
} catch (IOException e) { } catch (IOException e) {
@@ -96,7 +96,7 @@ public abstract class MixinNetHandlerPlayClient {
//$$ public void recordOwnJoin(S01PacketJoinGame packet, CallbackInfo ci) { //$$ public void recordOwnJoin(S01PacketJoinGame packet, CallbackInfo ci) {
//$$ RecordingEventHandler handler = getRecordingEventHandler(); //$$ RecordingEventHandler handler = getRecordingEventHandler();
//$$ if (handler != null) { //$$ if (handler != null) {
//$$ handler.onPlayerJoin(); //$$ handler.spawnRecordingPlayer();
//$$ } //$$ }
//$$ } //$$ }
//#endif //#endif
@@ -116,7 +116,7 @@ public abstract class MixinNetHandlerPlayClient {
public void recordOwnRespawn(PlayerRespawnS2CPacket packet, CallbackInfo ci) { public void recordOwnRespawn(PlayerRespawnS2CPacket packet, CallbackInfo ci) {
RecordingEventHandler handler = getRecordingEventHandler(); RecordingEventHandler handler = getRecordingEventHandler();
if (handler != null) { if (handler != null) {
handler.onPlayerRespawn(); handler.spawnRecordingPlayer();
} }
} }
} }