Get rid of annotation workaround (by not referencing affected classes)
This commit is contained in:
@@ -12,10 +12,16 @@ 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.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.network.play.server.SPacketPlayerListItem;
|
||||||
import net.minecraft.client.network.NetworkPlayerInfo;
|
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.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
//#endif
|
//#endif
|
||||||
@@ -48,13 +54,26 @@ public abstract class MixinNetHandlerPlayClient {
|
|||||||
|
|
||||||
RecordingEventHandler handler = getRecordingEventHandler();
|
RecordingEventHandler handler = getRecordingEventHandler();
|
||||||
if (handler != null && packet.getAction() == SPacketPlayerListItem.Action.ADD_PLAYER) {
|
if (handler != null && packet.getAction() == SPacketPlayerListItem.Action.ADD_PLAYER) {
|
||||||
//#if MC>=10809
|
// We cannot reference SPacketPlayerListItem.AddPlayerData directly for complicated (and yet to be
|
||||||
List<SPacketPlayerListItem.AddPlayerData> entries = packet.getEntries();
|
// resolved) reasons (see https://github.com/MinecraftForge/ForgeGradle/issues/472), so we "simply" convert
|
||||||
//#else
|
// the back to the MCProtocolLib equivalent and deal with that one.
|
||||||
//$$ @SuppressWarnings("unchecked")
|
ByteBuf byteBuf = Unpooled.buffer();
|
||||||
//$$ List<S38PacketPlayerListItem.AddPlayerData> entries = packet.func_179767_a();
|
ServerPlayerListEntryPacket mcpl = new ServerPlayerListEntryPacket(null, null);
|
||||||
//#endif
|
try {
|
||||||
for (SPacketPlayerListItem.AddPlayerData data : entries) {
|
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;
|
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
|
// 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())
|
if (data.getProfile().getId().equals(gameController.player.getGameProfile().getId())
|
||||||
|
|||||||
@@ -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
|
if (!FG3 && !FABRIC) { // FIXME
|
||||||
task runIntegrationTest(type: JavaExec, dependsOn: ["makeStart", "jar"]) {
|
task runIntegrationTest(type: JavaExec, dependsOn: ["makeStart", "jar"]) {
|
||||||
main = 'GradleStart'
|
main = 'GradleStart'
|
||||||
|
|||||||
Reference in New Issue
Block a user