mirror of
https://github.com/tanyaofei/minecraft-fakeplayer.git
synced 2025-07-13 04:42:24 +08:00
Fix fake players do not knockback when kiting
This commit is contained in:
parent
f08b80148b
commit
cabf813198
@ -6,6 +6,7 @@ import io.github.hello09x.fakeplayer.core.manager.FakeplayerManager;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.game.ClientboundCustomPayloadPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundSetEntityMotionPacket;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||
@ -34,9 +35,21 @@ public class FakeServerGamePacketListenerImpl extends ServerGamePacketListenerIm
|
||||
@Override
|
||||
public void send(Packet<?> packet) {
|
||||
if (packet instanceof ClientboundCustomPayloadPacket p) {
|
||||
// 接收到自定义的数据包,由于假人没有连接导致 BungeeCord 的插件消息无法正确通过 Proxy 发送
|
||||
// 因此将该数据包通过真实的玩家重新发送一份
|
||||
this.handleCustomPayloadPacket(p);
|
||||
} else if (packet instanceof ClientboundSetEntityMotionPacket p) {
|
||||
this.handleClientboundSetEntityMotionPacket(p);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 玩家被击退的动作由客户端完成, 假人没有客户端因此手动完成这个动作
|
||||
*/
|
||||
public void handleClientboundSetEntityMotionPacket(@NotNull ClientboundSetEntityMotionPacket packet) {
|
||||
if (packet.getId() == this.player.getId() && this.player.hurtMarked) {
|
||||
Bukkit.getScheduler().runTask(Main.getInstance(), () -> {
|
||||
this.player.hurtMarked = true;
|
||||
this.player.lerpMotion(packet.getXa(), packet.getYa(), packet.getZa());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.minecraft.network.protocol.game.ClientboundSetEntityMotionPacket;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.network.CommonListenerCookie;
|
||||
@ -39,6 +40,20 @@ public class FakeServerGamePacketListenerImpl extends ServerGamePacketListenerIm
|
||||
public void send(Packet<?> packet) {
|
||||
if (packet instanceof ClientboundCustomPayloadPacket p) {
|
||||
this.handleCustomPayloadPacket(p.payload());
|
||||
} else if (packet instanceof ClientboundSetEntityMotionPacket p) {
|
||||
this.handleClientboundSetEntityMotionPacket(p);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 玩家被击退的动作由客户端完成, 假人没有客户端因此手动完成这个动作
|
||||
*/
|
||||
public void handleClientboundSetEntityMotionPacket(@NotNull ClientboundSetEntityMotionPacket packet) {
|
||||
if (packet.getId() == this.player.getId() && this.player.hurtMarked) {
|
||||
Bukkit.getScheduler().runTask(Main.getInstance(), () -> {
|
||||
this.player.hurtMarked = true;
|
||||
this.player.lerpMotion(packet.getXa(), packet.getYa(), packet.getZa());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.minecraft.network.protocol.game.ClientboundSetEntityMotionPacket;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.network.CommonListenerCookie;
|
||||
@ -35,10 +36,24 @@ public class FakeServerGamePacketListenerImpl extends ServerGamePacketListenerIm
|
||||
.ifPresent(p -> p.addChannel(BUNGEE_CORD_CORRECTED_CHANNEL));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void send(Packet<?> packet) {
|
||||
if (packet instanceof ClientboundCustomPayloadPacket p) {
|
||||
this.handleCustomPayloadPacket(p.payload());
|
||||
} else if (packet instanceof ClientboundSetEntityMotionPacket p) {
|
||||
this.handleClientboundSetEntityMotionPacket(p);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 玩家被击退的动作由客户端完成, 假人没有客户端因此手动完成这个动作
|
||||
*/
|
||||
public void handleClientboundSetEntityMotionPacket(@NotNull ClientboundSetEntityMotionPacket packet) {
|
||||
if (packet.getId() == this.player.getId() && this.player.hurtMarked) {
|
||||
Bukkit.getScheduler().runTask(Main.getInstance(), () -> {
|
||||
this.player.hurtMarked = true;
|
||||
this.player.lerpMotion(packet.getXa(), packet.getYa(), packet.getZa());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket;
|
||||
import net.minecraft.network.protocol.common.custom.DiscardedPayload;
|
||||
import net.minecraft.network.protocol.game.ClientboundSetEntityMotionPacket;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.network.CommonListenerCookie;
|
||||
@ -35,10 +36,24 @@ public class FakeServerGamePacketListenerImpl extends ServerGamePacketListenerIm
|
||||
.ifPresent(p -> p.addChannel(BUNGEE_CORD_CORRECTED_CHANNEL));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void send(Packet<?> packet) {
|
||||
if (packet instanceof ClientboundCustomPayloadPacket p) {
|
||||
this.handleCustomPayloadPacket(p);
|
||||
} else if (packet instanceof ClientboundSetEntityMotionPacket p) {
|
||||
this.handleClientboundSetEntityMotionPacket(p);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 玩家被击退的动作由客户端完成, 假人没有客户端因此手动完成这个动作
|
||||
*/
|
||||
public void handleClientboundSetEntityMotionPacket(@NotNull ClientboundSetEntityMotionPacket packet) {
|
||||
if (packet.getId() == this.player.getId() && this.player.hurtMarked) {
|
||||
Bukkit.getScheduler().runTask(Main.getInstance(), () -> {
|
||||
this.player.hurtMarked = true;
|
||||
this.player.lerpMotion(packet.getXa(), packet.getYa(), packet.getZa());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket;
|
||||
import net.minecraft.network.protocol.common.custom.DiscardedPayload;
|
||||
import net.minecraft.network.protocol.game.ClientboundSetEntityMotionPacket;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.network.CommonListenerCookie;
|
||||
@ -39,6 +40,20 @@ public class FakeServerGamePacketListenerImpl extends ServerGamePacketListenerIm
|
||||
public void send(Packet<?> packet) {
|
||||
if (packet instanceof ClientboundCustomPayloadPacket p) {
|
||||
this.handleCustomPayloadPacket(p);
|
||||
} else if (packet instanceof ClientboundSetEntityMotionPacket p) {
|
||||
this.handleClientboundSetEntityMotionPacket(p);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 玩家被击退的动作由客户端完成, 假人没有客户端因此手动完成这个动作
|
||||
*/
|
||||
public void handleClientboundSetEntityMotionPacket(@NotNull ClientboundSetEntityMotionPacket packet) {
|
||||
if (packet.getId() == this.player.getId() && this.player.hurtMarked) {
|
||||
Bukkit.getScheduler().runTask(Main.getInstance(), () -> {
|
||||
this.player.hurtMarked = true;
|
||||
this.player.lerpMotion(packet.getXa(), packet.getYa(), packet.getZa());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user