diff --git a/leaf-server/minecraft-patches/features/0171-send-and-flush-position-while-knockback-player.patch b/leaf-server/minecraft-patches/features/0171-send-and-flush-position-while-knockback-player.patch index 02596fc5..37bd6186 100644 --- a/leaf-server/minecraft-patches/features/0171-send-and-flush-position-while-knockback-player.patch +++ b/leaf-server/minecraft-patches/features/0171-send-and-flush-position-while-knockback-player.patch @@ -4,41 +4,33 @@ Date: Thu, 8 May 2025 04:56:30 +0900 Subject: [PATCH] send and flush position while knockback player -diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 405b8da8b886b5caac7ed774472e106374c42185..0e57a1799731e933f155fd694b224144da66977c 100644 ---- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java -+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -1674,6 +1674,12 @@ public class ServerGamePacketListenerImpl - this.lastGoodX = this.player.getX(); - this.lastGoodY = this.player.getY(); - this.lastGoodZ = this.player.getZ(); -+ // Leaf start -+ if (org.dreeam.leaf.config.modules.gameplay.Knockback.flushKnockback && this.player.lastHurtByPlayer instanceof ServerPlayer hurtBy && hurtBy.distanceToSqr(this.player) <= 1024D) { -+ hurtBy.connection.send(net.minecraft.network.protocol.game.ClientboundEntityPositionSyncPacket.of(this.player)); -+ hurtBy.connection.connection.flushChannel(); -+ } -+ // Leaf end - } else { - this.internalTeleport(x, y, z, f, f1); // CraftBukkit - SPIGOT-1807: Don't call teleport event, when the client thinks the player is falling, because the chunks are not loaded on the client yet. - this.player.doCheckFallDamage(this.player.getX() - x, this.player.getY() - y, this.player.getZ() - z, packet.isOnGround()); diff --git a/net/minecraft/world/entity/player/Player.java b/net/minecraft/world/entity/player/Player.java -index 477455fdfcc591a89823e88983eb12dabb078d9b..4996f5c073443d5f93a8f05bc7a0adfe0c3713b5 100644 +index 477455fdfcc591a89823e88983eb12dabb078d9b..789eed2336c31c486ea09eff7744d2e2146506cc 100644 --- a/net/minecraft/world/entity/player/Player.java +++ b/net/minecraft/world/entity/player/Player.java -@@ -1480,6 +1480,16 @@ public abstract class Player extends LivingEntity { - } +@@ -1411,6 +1411,25 @@ public abstract class Player extends LivingEntity { + player.setVelocity(event.getVelocity()); + } - this.causeFoodExhaustion(this.level().spigotConfig.combatExhaustion, org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.ATTACK); // CraftBukkit - EntityExhaustionEvent // Spigot - Change to use configurable value -+ // Leaf start -+ if (org.dreeam.leaf.config.modules.gameplay.Knockback.flushKnockback && this instanceof ServerPlayer player1 && target instanceof ServerPlayer target1) { -+ player1.connection.send(net.minecraft.network.protocol.game.ClientboundEntityPositionSyncPacket.of(target1)); -+ target1.connection.send(net.minecraft.network.protocol.game.ClientboundEntityPositionSyncPacket.of(this)); -+ player1.hasImpulse = true; -+ target1.hasImpulse = true; -+ player1.connection.connection.flushChannel(); -+ target1.connection.connection.flushChannel(); -+ } -+ // Leaf end - } else { - this.sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_NODAMAGE, this.getSoundSource(), 1.0F, 1.0F); // Paper - send while respecting visibility - // CraftBukkit start - resync on cancelled event ++ ++ // Leaf start ++ if (org.dreeam.leaf.config.modules.gameplay.Knockback.flushKnockback) { ++ ServerPlayer target1 = (ServerPlayer) target; ++ Vec3 before = target1.getDeltaMovement(); ++ target1.aiStep(); ++ target1.setDeltaMovement(before); ++ target1.connection.send(new net.minecraft.network.protocol.game.ClientboundSetEntityMotionPacket(this)); ++ target1.connection.send(net.minecraft.network.protocol.game.ClientboundEntityPositionSyncPacket.of(this)); ++ target1.connection.resumeFlushing(); ++ target1.hasImpulse = true; ++ if (this instanceof ServerPlayer player1) { ++ player1.connection.send(new net.minecraft.network.protocol.game.ClientboundSetEntityMotionPacket(target1)); ++ player1.connection.send(net.minecraft.network.protocol.game.ClientboundEntityPositionSyncPacket.of(target1)); ++ player1.connection.resumeFlushing(); ++ player1.hasImpulse = true; ++ } ++ } ++ // Leaf end + if (!cancelled) { + ((ServerPlayer)target).connection.send(new ClientboundSetEntityMotionPacket(target)); + target.hurtMarked = false;