9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-19 15:09:25 +00:00
Files
Leaf/leaf-server/minecraft-patches/features/0171-move-and-flush-location-while-knockback.patch
hayanesuru b63f850b91 move and flush position while knockback player (#316)
* move and flush position while knockback

* fix compile error

* rename

---------

Co-authored-by: Taiyou06 <kaandindar21@gmail.com>
2025-05-09 11:57:49 +09:00

37 lines
2.5 KiB
Diff

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] move and flush location while knockback
diff --git a/net/minecraft/world/entity/player/Player.java b/net/minecraft/world/entity/player/Player.java
index 477455fdfcc591a89823e88983eb12dabb078d9b..ffff3c710f6a96de9372fe07ffa69e65d392273f 100644
--- a/net/minecraft/world/entity/player/Player.java
+++ b/net/minecraft/world/entity/player/Player.java
@@ -1415,6 +1415,25 @@ public abstract class Player extends LivingEntity {
((ServerPlayer)target).connection.send(new ClientboundSetEntityMotionPacket(target));
target.hurtMarked = false;
target.setDeltaMovement(deltaMovement);
+
+ // Leaf start
+ if (org.dreeam.leaf.config.modules.gameplay.Knockback.flushKnockback) {
+ ServerPlayer targetPlayer = (ServerPlayer) target;
+ Vec3 before = targetPlayer.getDeltaMovement();
+ targetPlayer.aiStep();
+ targetPlayer.setDeltaMovement(before);
+ targetPlayer.connection.send(new net.minecraft.network.protocol.game.ClientboundSetEntityMotionPacket(this));
+ targetPlayer.connection.send(net.minecraft.network.protocol.game.ClientboundEntityPositionSyncPacket.of(this));
+ targetPlayer.connection.resumeFlushing();
+ 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.resumeFlushing();
+ player1.hasImpulse = true;
+ }
+ }
+ // Leaf end
}
// CraftBukkit end
}