9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2026-01-06 15:51:31 +00:00

update flush knockback

This commit is contained in:
hayanesuru
2025-05-10 23:29:35 +09:00
parent edab752b3a
commit 184c2221b2
3 changed files with 44 additions and 34 deletions

View File

@@ -0,0 +1,44 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: hayanesuru <hayanesuru@outlook.jp>
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
--- 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 {
}
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

View File

@@ -1,33 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: hayanesuru <hayanesuru@outlook.jp>
Date: Thu, 8 May 2025 04:56:30 +0900
Subject: [PATCH] serverside move and flush while knockback player
diff --git a/net/minecraft/world/entity/player/Player.java b/net/minecraft/world/entity/player/Player.java
index 477455fdfcc591a89823e88983eb12dabb078d9b..41fbd978632572636ca25a279fd15f818fa4eb22 100644
--- a/net/minecraft/world/entity/player/Player.java
+++ b/net/minecraft/world/entity/player/Player.java
@@ -1414,6 +1414,22 @@ public abstract class Player extends LivingEntity {
if (!cancelled) {
((ServerPlayer)target).connection.send(new ClientboundSetEntityMotionPacket(target));
target.hurtMarked = false;
+ // Leaf start
+ if (org.dreeam.leaf.config.modules.gameplay.Knockback.flushKnockback) {
+ ServerPlayer targetPlayer = (ServerPlayer) target;
+ targetPlayer.travel(targetPlayer.getDeltaMovement());
+ targetPlayer.connection.send(new net.minecraft.network.protocol.game.ClientboundSetEntityMotionPacket(this));
+ targetPlayer.connection.send(net.minecraft.network.protocol.game.ClientboundEntityPositionSyncPacket.of(this));
+ targetPlayer.connection.connection.flushChannel();
+ targetPlayer.hasImpulse = true;
+ if (this instanceof ServerPlayer player1) {
+ player1.connection.send(new net.minecraft.network.protocol.game.ClientboundSetEntityMotionPacket(targetPlayer));
+ player1.connection.send(net.minecraft.network.protocol.game.ClientboundEntityPositionSyncPacket.of(targetPlayer));
+ player1.connection.connection.flushChannel();
+ player1.hasImpulse = true;
+ }
+ }
+ // Leaf end
target.setDeltaMovement(deltaMovement);
}
// CraftBukkit end

View File

@@ -13,7 +13,6 @@ public class Knockback extends ConfigModules {
public static boolean snowballCanKnockback = false;
public static boolean eggCanKnockback = false;
public static boolean canPlayerKnockbackZombie = true;
@Experimental
public static boolean flushKnockback = false;
@Override