Closed ghost closed 4 years ago
I already solve the problem, but It's just that I haven't solved the TP problem for the time being, and I can't accurately determine whether a movement is caused by TP
@jiangdashao
when server tells player to move:
public void onPacketSending(PacketEvent e) {
if (!e.isPlayerTemporary()) {
if (e.getPacketType() == PacketType.Play.Server.POSITION) {
data.lastServerdictatedMove = System.currentTimeMillis();
data.dictatedmoveids.add(e.getPacket().getIntegers().read(0));
}
}
}
when client says "yes i have been move": public void onPacketReceiving(PacketEvent e) { if (!e.isPlayerTemporary()) { if (type == TELEPORT_ACCEPT) { Integer id = e.getPacket().getIntegers().readSafely(0); if (data.dictatedmoveids.contains(id)) { data.dictatedmoveids.remove(id); data.lastClientMoveResponse = System.currentTimeMillis(); }
I will implement my own PlayerConnection wrapper according to the writing of NMS
@jiangdashao I don't think you must get rid protocol lib, but if you planning to don't use your own wrapper, it hard maintain maybe. use https://github.com/retrooper/packetevents or https://www.spigotmc.org/resources/2ls-hamsterapi.78831/
No, I mean, use ProtocolLib to fake a PlayerConnection to imitate NMS's processing of packet
@jiangdashao why would you want to do this?
Process Teleport packets like NMS
when server wants player to move it sends PacketType.Play.Server.POSITION with a transaction ID when client responds to this packet they send PacketType.Play.Client.TELEPORT_ACCEPT with the same ID this is same for 1.8-1.16 im pretty sure, no need for NMS hackery https://wiki.vg/Protocol#Teleport_Confirm https://wiki.vg/Protocol#Player_Position_And_Look_.28clientbound.29
I know teleport confirm packet was added in 1.12
@jiangdashao ah okay. I dont know what happens in 1.8 then
https://wiki.vg/index.php?title=Protocol&oldid=7368#Player_Position_And_Look yeah its same as 1.16 except client sends nothing back.
What features/checks do you need?: if spigot stop getnearbyentity off main thread why not do this: for (Zombie mob : player.getWorld().getEntitiesByClass(Zombie.class)) { if (mob.getLocation().distance(player.getLocation()) <= DISTANCE) { player.sendMessage("You are near zombie"); } } and to get block async you can do this: (many plugin use this and its reliable) public static Block getBlockAsync(Location location) { if (location.getWorld().isChunkLoaded(location.getBlockX() >> 4, location.getBlockZ() >> 4)) return location.getBlock(); return null; }