Skip to content

Commit

Permalink
Revert fixing knockback on 1.20.x
Browse files Browse the repository at this point in the history
  • Loading branch information
tanyaofei committed Oct 22, 2024
1 parent 1e1cf79 commit 3d70e2e
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
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;
Expand Down Expand Up @@ -35,21 +34,9 @@ public FakeServerGamePacketListenerImpl(
@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());
});
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
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;
Expand Down Expand Up @@ -40,20 +39,6 @@ public FakeServerGamePacketListenerImpl(
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());
});
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
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;
Expand All @@ -36,24 +35,10 @@ public FakeServerGamePacketListenerImpl(
.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());
});
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
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;
Expand Down Expand Up @@ -36,24 +35,10 @@ public FakeServerGamePacketListenerImpl(
.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());
});
}
}

Expand Down

0 comments on commit 3d70e2e

Please sign in to comment.