Get rid of annotation workaround (by not referencing affected classes)

This commit is contained in:
Jonas Herzig
2019-05-06 19:54:08 +02:00
parent bd91d0d3bd
commit 6b9b9c2131
2 changed files with 27 additions and 61 deletions

View File

@@ -12,10 +12,16 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
//#if MC>=10800
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerPlayerListEntryPacket;
import com.github.steveice10.packetlib.io.buffer.ByteBufferNetInput;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.minecraft.network.PacketBuffer;
import net.minecraft.network.play.server.SPacketPlayerListItem;
import net.minecraft.client.network.NetworkPlayerInfo;
import java.util.List;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.Map;
import java.util.UUID;
//#endif
@@ -48,13 +54,26 @@ public abstract class MixinNetHandlerPlayClient {
RecordingEventHandler handler = getRecordingEventHandler();
if (handler != null && packet.getAction() == SPacketPlayerListItem.Action.ADD_PLAYER) {
//#if MC>=10809
List<SPacketPlayerListItem.AddPlayerData> entries = packet.getEntries();
//#else
//$$ @SuppressWarnings("unchecked")
//$$ List<S38PacketPlayerListItem.AddPlayerData> entries = packet.func_179767_a();
//#endif
for (SPacketPlayerListItem.AddPlayerData data : entries) {
// We cannot reference SPacketPlayerListItem.AddPlayerData directly for complicated (and yet to be
// resolved) reasons (see https://github.com/MinecraftForge/ForgeGradle/issues/472), so we "simply" convert
// the back to the MCProtocolLib equivalent and deal with that one.
ByteBuf byteBuf = Unpooled.buffer();
ServerPlayerListEntryPacket mcpl = new ServerPlayerListEntryPacket(null, null);
try {
packet.writePacketData(new PacketBuffer(byteBuf));
byteBuf.readerIndex(0);
byte[] array = new byte[byteBuf.readableBytes()];
byteBuf.readBytes(array);
mcpl.read(new ByteBufferNetInput(ByteBuffer.wrap(array)));
} catch (IOException e) {
throw new RuntimeException(e); // we just parsed this?
} finally {
byteBuf.release();
}
for (com.github.steveice10.mc.protocol.data.game.PlayerListEntry data : mcpl.getEntries()) {
if (data.getProfile() == null || data.getProfile().getId() == null) continue;
// Only add spawn packet for our own player and only if he isn't known yet
if (data.getProfile().getId().equals(gameController.player.getGameProfile().getId())