Remove player list packet entry workaround
No longer using ForgeGradle \o/
This commit is contained in:
@@ -21,6 +21,7 @@ import net.minecraft.network.NetworkSide;
|
|||||||
import net.minecraft.network.NetworkState;
|
import net.minecraft.network.NetworkState;
|
||||||
import net.minecraft.network.Packet;
|
import net.minecraft.network.Packet;
|
||||||
import net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket;
|
import net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket;
|
||||||
|
import net.minecraft.network.packet.s2c.play.PlayerListS2CPacket;
|
||||||
import net.minecraft.resource.Resource;
|
import net.minecraft.resource.Resource;
|
||||||
import net.minecraft.resource.ResourceManager;
|
import net.minecraft.resource.ResourceManager;
|
||||||
import net.minecraft.sound.SoundCategory;
|
import net.minecraft.sound.SoundCategory;
|
||||||
@@ -85,6 +86,7 @@ import net.minecraft.client.render.BufferBuilder;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
class Patterns {
|
class Patterns {
|
||||||
//#if MC>=10904
|
//#if MC>=10904
|
||||||
@@ -955,6 +957,15 @@ class Patterns {
|
|||||||
//$$ @Pattern public void UnloadChunkPacket_getX() {}
|
//$$ @Pattern public void UnloadChunkPacket_getX() {}
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
|
@Pattern
|
||||||
|
public UUID getId(PlayerListS2CPacket.Entry entry) {
|
||||||
|
//#if MC>=11903
|
||||||
|
//$$ return entry.profileId();
|
||||||
|
//#else
|
||||||
|
return entry.getProfile().getId();
|
||||||
|
//#endif
|
||||||
|
}
|
||||||
|
|
||||||
@Pattern
|
@Pattern
|
||||||
public Identifier getSkinTexture(AbstractClientPlayerEntity player) {
|
public Identifier getSkinTexture(AbstractClientPlayerEntity player) {
|
||||||
//#if MC>=12002
|
//#if MC>=12002
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package com.replaymod.recording.mixin;
|
|||||||
|
|
||||||
import com.replaymod.core.versions.MCVer;
|
import com.replaymod.core.versions.MCVer;
|
||||||
import com.replaymod.recording.handler.RecordingEventHandler;
|
import com.replaymod.recording.handler.RecordingEventHandler;
|
||||||
import com.replaymod.replaystudio.lib.viaversion.api.protocol.packet.State;
|
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||||
import net.minecraft.network.packet.s2c.play.PlayerRespawnS2CPacket;
|
import net.minecraft.network.packet.s2c.play.PlayerRespawnS2CPacket;
|
||||||
@@ -13,16 +12,9 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
|||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
//#if MC>=10800
|
//#if MC>=10800
|
||||||
import com.replaymod.replaystudio.protocol.Packet;
|
|
||||||
import com.replaymod.replaystudio.protocol.PacketType;
|
|
||||||
import com.replaymod.replaystudio.protocol.packets.PacketPlayerListEntry;
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import io.netty.buffer.Unpooled;
|
|
||||||
import net.minecraft.network.PacketByteBuf;
|
|
||||||
import net.minecraft.network.packet.s2c.play.PlayerListS2CPacket;
|
import net.minecraft.network.packet.s2c.play.PlayerListS2CPacket;
|
||||||
import net.minecraft.client.network.PlayerListEntry;
|
import net.minecraft.client.network.PlayerListEntry;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
//#else
|
//#else
|
||||||
@@ -67,32 +59,12 @@ public abstract class MixinNetHandlerPlayClient {
|
|||||||
//#else
|
//#else
|
||||||
if (handler != null && packet.getAction() == PlayerListS2CPacket.Action.ADD_PLAYER) {
|
if (handler != null && packet.getAction() == PlayerListS2CPacket.Action.ADD_PLAYER) {
|
||||||
//#endif
|
//#endif
|
||||||
// We cannot reference SPacketPlayerListItem.AddPlayerData directly for complicated (and yet to be
|
for (PlayerListS2CPacket.Entry entry : packet.getEntries()) {
|
||||||
// resolved) reasons (see https://github.com/MinecraftForge/ForgeGradle/issues/472), so we use ReplayStudio
|
UUID uuid = entry.getProfile().getId();
|
||||||
// to parse it instead.
|
// Only add spawn packet for our own player and only if he isn't known yet
|
||||||
ByteBuf byteBuf = Unpooled.buffer();
|
if (uuid.equals(mcStatic.player.getGameProfile().getId()) && !this.playerListEntries.containsKey(uuid)) {
|
||||||
try {
|
handler.spawnRecordingPlayer();
|
||||||
packet.write(new PacketByteBuf(byteBuf));
|
|
||||||
|
|
||||||
byteBuf.readerIndex(0);
|
|
||||||
byte[] array = new byte[byteBuf.readableBytes()];
|
|
||||||
byteBuf.readBytes(array);
|
|
||||||
|
|
||||||
for (PacketPlayerListEntry data : PacketPlayerListEntry.read(new Packet(
|
|
||||||
MCVer.getPacketTypeRegistry(State.PLAY), 0, PacketType.PlayerListEntry,
|
|
||||||
com.github.steveice10.netty.buffer.Unpooled.wrappedBuffer(array)
|
|
||||||
))) {
|
|
||||||
if (data.getUuid() == null) continue;
|
|
||||||
// Only add spawn packet for our own player and only if he isn't known yet
|
|
||||||
if (data.getUuid().equals(mcStatic.player.getGameProfile().getId())
|
|
||||||
&& !this.playerListEntries.containsKey(data.getUuid())) {
|
|
||||||
handler.spawnRecordingPlayer();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e); // we just parsed this?
|
|
||||||
} finally {
|
|
||||||
byteBuf.release();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user