From 130b55d7d4c34b4245c10c4b38974da7ccd5a67e Mon Sep 17 00:00:00 2001 From: Taiyou06 Date: Sun, 11 May 2025 21:25:14 +0200 Subject: [PATCH] if it aint broken, dont fix it --- ...tch => 0171-Only-tick-items-at-hand.patch} | 2 +- ...lush-position-while-knockback-player.patch | 44 ------------------- ...art-sort-items-in-NearestItemSensor.patch} | 0 ...173-Optimise-player-movement-checks.patch} | 0 ...e-and-flush-location-while-knockback.patch | 36 +++++++++++++++ .../config/modules/gameplay/Knockback.java | 1 + 6 files changed, 38 insertions(+), 45 deletions(-) rename leaf-server/minecraft-patches/features/{0172-Only-tick-items-at-hand.patch => 0171-Only-tick-items-at-hand.patch} (95%) delete mode 100644 leaf-server/minecraft-patches/features/0171-send-and-flush-position-while-knockback-player.patch rename leaf-server/minecraft-patches/features/{0173-Smart-sort-items-in-NearestItemSensor.patch => 0172-Smart-sort-items-in-NearestItemSensor.patch} (100%) rename leaf-server/minecraft-patches/features/{0174-Optimise-player-movement-checks.patch => 0173-Optimise-player-movement-checks.patch} (100%) create mode 100644 leaf-server/minecraft-patches/features/0174-move-and-flush-location-while-knockback.patch diff --git a/leaf-server/minecraft-patches/features/0172-Only-tick-items-at-hand.patch b/leaf-server/minecraft-patches/features/0171-Only-tick-items-at-hand.patch similarity index 95% rename from leaf-server/minecraft-patches/features/0172-Only-tick-items-at-hand.patch rename to leaf-server/minecraft-patches/features/0171-Only-tick-items-at-hand.patch index 3ced9a74..431f852c 100644 --- a/leaf-server/minecraft-patches/features/0172-Only-tick-items-at-hand.patch +++ b/leaf-server/minecraft-patches/features/0171-Only-tick-items-at-hand.patch @@ -26,7 +26,7 @@ index 95e03045bcbee74ddac36ae36ce8c8c2f5769fa4..6eee16dccef1d0f04ba3532f5ee06447 } } diff --git a/net/minecraft/world/entity/player/Player.java b/net/minecraft/world/entity/player/Player.java -index ffff3c710f6a96de9372fe07ffa69e65d392273f..fb61bf4b69033d856e2ed424a0557d1f6a27e4e7 100644 +index 477455fdfcc591a89823e88983eb12dabb078d9b..9e62fe46eb9883ade81c1c9ff0f8220ed34b5d85 100644 --- a/net/minecraft/world/entity/player/Player.java +++ b/net/minecraft/world/entity/player/Player.java @@ -631,7 +631,12 @@ public abstract class Player extends LivingEntity { 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 deleted file mode 100644 index dee46232..00000000 --- a/leaf-server/minecraft-patches/features/0171-send-and-flush-position-while-knockback-player.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: hayanesuru -Date: Thu, 8 May 2025 04:56:30 +0900 -Subject: [PATCH] send and flush position while knockback player - - -diff --git a/net/minecraft/world/entity/player/Player.java b/net/minecraft/world/entity/player/Player.java -index 477455fdfcc591a89823e88983eb12dabb078d9b..fdc9c68a0ed30b8b342ceaca5d988e82524d6bf9 100644 ---- a/net/minecraft/world/entity/player/Player.java -+++ b/net/minecraft/world/entity/player/Player.java -@@ -1411,6 +1411,20 @@ public abstract class Player extends LivingEntity { - player.setVelocity(event.getVelocity()); - } - -+ -+ // Leaf start -+ if (org.dreeam.leaf.config.modules.gameplay.Knockback.flushKnockback && !cancelled && this instanceof ServerPlayer player1) { -+ ServerPlayer target1 = (ServerPlayer) target; -+ var targetV = target1.getDeltaMovement(); -+ target1.aiStep(); -+ target1.setDeltaMovement(targetV); -+ target1.connection.send(net.minecraft.network.protocol.game.ClientboundEntityPositionSyncPacket.of(this)); -+ player1.connection.send(net.minecraft.network.protocol.game.ClientboundEntityPositionSyncPacket.of(target1)); -+ player1.connection.send(new ClientboundSetEntityMotionPacket(target1)); -+ player1.hasImpulse = true; -+ target1.hasImpulse = true; -+ } -+ // Leaf end - if (!cancelled) { - ((ServerPlayer)target).connection.send(new ClientboundSetEntityMotionPacket(target)); - target.hurtMarked = false; -@@ -1480,6 +1494,12 @@ 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 && target instanceof ServerPlayer target1 && this instanceof ServerPlayer player1) { -+ target1.connection.connection.flushChannel(); -+ player1.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 diff --git a/leaf-server/minecraft-patches/features/0173-Smart-sort-items-in-NearestItemSensor.patch b/leaf-server/minecraft-patches/features/0172-Smart-sort-items-in-NearestItemSensor.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0173-Smart-sort-items-in-NearestItemSensor.patch rename to leaf-server/minecraft-patches/features/0172-Smart-sort-items-in-NearestItemSensor.patch diff --git a/leaf-server/minecraft-patches/features/0174-Optimise-player-movement-checks.patch b/leaf-server/minecraft-patches/features/0173-Optimise-player-movement-checks.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0174-Optimise-player-movement-checks.patch rename to leaf-server/minecraft-patches/features/0173-Optimise-player-movement-checks.patch diff --git a/leaf-server/minecraft-patches/features/0174-move-and-flush-location-while-knockback.patch b/leaf-server/minecraft-patches/features/0174-move-and-flush-location-while-knockback.patch new file mode 100644 index 00000000..00f995a1 --- /dev/null +++ b/leaf-server/minecraft-patches/features/0174-move-and-flush-location-while-knockback.patch @@ -0,0 +1,36 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Taiyou06 +Date: Sun, 11 May 2025 19:45:58 +0200 +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 9e62fe46eb9883ade81c1c9ff0f8220ed34b5d85..fb61bf4b69033d856e2ed424a0557d1f6a27e4e7 100644 +--- a/net/minecraft/world/entity/player/Player.java ++++ b/net/minecraft/world/entity/player/Player.java +@@ -1420,6 +1420,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 + } diff --git a/leaf-server/src/main/java/org/dreeam/leaf/config/modules/gameplay/Knockback.java b/leaf-server/src/main/java/org/dreeam/leaf/config/modules/gameplay/Knockback.java index 1ffed0e9..b0610c61 100644 --- a/leaf-server/src/main/java/org/dreeam/leaf/config/modules/gameplay/Knockback.java +++ b/leaf-server/src/main/java/org/dreeam/leaf/config/modules/gameplay/Knockback.java @@ -13,6 +13,7 @@ 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