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

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>
This commit is contained in:
hayanesuru
2025-05-09 11:57:49 +09:00
committed by GitHub
parent 08287d95db
commit b63f850b91
2 changed files with 40 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
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
}

View File

@@ -2,6 +2,7 @@ package org.dreeam.leaf.config.modules.gameplay;
import org.dreeam.leaf.config.ConfigModules; import org.dreeam.leaf.config.ConfigModules;
import org.dreeam.leaf.config.EnumConfigCategory; import org.dreeam.leaf.config.EnumConfigCategory;
import org.dreeam.leaf.config.annotations.Experimental;
public class Knockback extends ConfigModules { public class Knockback extends ConfigModules {
@@ -12,6 +13,8 @@ public class Knockback extends ConfigModules {
public static boolean snowballCanKnockback = false; public static boolean snowballCanKnockback = false;
public static boolean eggCanKnockback = false; public static boolean eggCanKnockback = false;
public static boolean canPlayerKnockbackZombie = true; public static boolean canPlayerKnockbackZombie = true;
@Experimental
public static boolean flushKnockback = false;
@Override @Override
public void onLoaded() { public void onLoaded() {
@@ -30,5 +33,6 @@ public class Knockback extends ConfigModules {
"Make players can knockback zombie.", "Make players can knockback zombie.",
"使玩家可以击退僵尸." "使玩家可以击退僵尸."
)); ));
flushKnockback = config.getBoolean(getBasePath() + ".flush-location-while-knockback-player", flushKnockback);
} }
} }