9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-19 15:09:25 +00:00

rollback flush knockback to prev version

This commit is contained in:
hayanesuru
2025-05-11 01:34:16 +09:00
parent 184c2221b2
commit 6a59f9e832

View File

@@ -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;