修复协议版本758后TeleportationPacket数据包回应

This commit is contained in:
SerendipityR 2022-08-21 00:30:36 +08:00 committed by GitHub
parent 904fc93515
commit cc24f85abe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,7 @@
package cn.serendipityr.EndMinecraftPlusV2.VersionControl; package cn.serendipityr.EndMinecraftPlusV2.VersionControl;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundChatPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundChatPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerPositionPacket;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundChatPacket; import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundChatPacket;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundClientInformationPacket; import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundClientInformationPacket;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundCommandSuggestionPacket; import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundCommandSuggestionPacket;
@ -98,14 +99,21 @@ public class VersionSupport758 {
} catch (Exception ignored) {} } catch (Exception ignored) {}
} }
public static void sendClientTeleportConfirmPacket(Session session, Packet packet) { public static void sendClientTeleportConfirmPacket(Session session, int id) {
try { try {
Class<?> cls = Class.forName("com.github.steveice10.mc.protocol.packet.ingame.serverbound.level.ServerboundAcceptTeleportationPacket"); Class<?> cls = Class.forName("com.github.steveice10.mc.protocol.packet.ingame.serverbound.level.ServerboundAcceptTeleportationPacket");
Constructor<?> constructor = cls.getConstructor(int.class); Constructor<?> constructor = cls.getConstructor(int.class);
Packet packet = (Packet) constructor.newInstance(id);
session.send(packet); session.send(packet);
} catch (Exception ignored) {} } catch (Exception ignored) {}
} }
public static void sendClientTeleportConfirmPacket(Session session, ClientboundPlayerPositionPacket packet) {
try {
sendClientTeleportConfirmPacket(session, (int) ClientboundPlayerPositionPacket.class.getMethod("getTeleportId").invoke(packet));
} catch (Exception ignored) {}
}
public static void sendPosPacket(Session session, double x, double y, double z, float yaw, float pitch) { public static void sendPosPacket(Session session, double x, double y, double z, float yaw, float pitch) {
try { try {
Class<?> cls = ServerboundMovePlayerPosRotPacket.class; Class<?> cls = ServerboundMovePlayerPosRotPacket.class;