diff --git a/src/main/java/com/replaymod/recording/mixin/MixinNetHandlerPlayClient.java b/src/main/java/com/replaymod/recording/mixin/MixinNetHandlerPlayClient.java index dc453f0c..586385a7 100644 --- a/src/main/java/com/replaymod/recording/mixin/MixinNetHandlerPlayClient.java +++ b/src/main/java/com/replaymod/recording/mixin/MixinNetHandlerPlayClient.java @@ -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 entries = packet.getEntries(); - //#else - //$$ @SuppressWarnings("unchecked") - //$$ List 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()) diff --git a/versions/common.gradle b/versions/common.gradle index 90a3787d..835ade63 100644 --- a/versions/common.gradle +++ b/versions/common.gradle @@ -561,59 +561,6 @@ compileJava.doLast { } */ -import java.util.zip.ZipEntry -import java.util.zip.ZipFile -import java.util.zip.ZipOutputStream - -import org.objectweb.asm.* - -import static org.objectweb.asm.Opcodes.ASM5 - -// MC binaries were complied with a java version that produces invalid class files under certain circumstances -// This causes setupCIWorkspace to be insufficient for compiling. -// Related JDK bug: https://bugs.openjdk.java.net/browse/JDK-8066725 -// As a workaround, to use setupCIWorkspace on Drone, we modify the bin jar in-place and remove all parameter annotations. -// WARNING: This piece of code ignores any and all gradle conventions and will probably fail horribly when run outside -// of a single-use environment (e.g. Drone). Use setupDecompWorkspace for normal use. -def annotationWorkaround = { - println "Applying RuntimeInvisibleParameterAnnotations workaround..." - File jar = getOutJar() - File tmp = new File((File) getTemporaryDir(), "workaround.jar") - tmp.withOutputStream { - new ZipOutputStream(it).withStream { dst -> - new ZipFile(jar).withCloseable { src -> - src.entries().each { - if (it.name.startsWith("net/minecraft/") && it.name.endsWith(".class")) { - def cw = new ClassWriter(0) - def cv = new ClassVisitor(ASM5, cw) { - @Override - MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { - return new MethodVisitor(ASM5, cv.visitMethod(access, name, desc, signature, exceptions)) { - @Override - AnnotationVisitor visitParameterAnnotation(int parameter, String pdesc, boolean visible) { - return null // Strip all parameter annotations - } - } - } - } - new ClassReader(src.getInputStream(it)).accept(cv, 0) - dst.putNextEntry(new ZipEntry(it.name)) - dst.write(cw.toByteArray()) - } else { - dst.putNextEntry(it) - dst.write(src.getInputStream(it).bytes) - } - } - } - } - } - jar.delete() - tmp.renameTo(jar) -} -if (mcVersion >= 10809 && !FG3 && !FABRIC) { - tasks.deobfMcMCP.doLast annotationWorkaround -} - if (!FG3 && !FABRIC) { // FIXME task runIntegrationTest(type: JavaExec, dependsOn: ["makeStart", "jar"]) { main = 'GradleStart'