9
9
import net .bettercombat .logic .PlayerAttackProperties ;
10
10
import net .bettercombat .logic .TargetHelper ;
11
11
import net .bettercombat .logic .WeaponRegistry ;
12
+ import net .bettercombat .logic .knockback .ConfigurableKnockback ;
12
13
import net .bettercombat .mixin .LivingEntityAccessor ;
14
+ import net .bettercombat .utils .MathHelp ;
13
15
import net .bettercombat .utils .SoundHelper ;
14
16
import net .fabricmc .fabric .api .networking .v1 .PacketByteBufs ;
15
17
import net .fabricmc .fabric .api .networking .v1 .PlayerLookup ;
23
25
import net .minecraft .entity .attribute .EntityAttributeModifier ;
24
26
import net .minecraft .entity .attribute .EntityAttributes ;
25
27
import net .minecraft .entity .decoration .ArmorStandEntity ;
26
- import net .minecraft .entity .mob .HostileEntity ;
27
28
import net .minecraft .entity .projectile .PersistentProjectileEntity ;
28
29
import net .minecraft .network .PacketByteBuf ;
29
30
import net .minecraft .network .packet .c2s .play .PlayerInteractEntityC2SPacket ;
@@ -114,6 +115,10 @@ public static void initializeHandlers() {
114
115
SoundHelper .playSound (world , player , attack .swingSound ());
115
116
}
116
117
118
+ var attackCooldown = PlayerAttackHelper .getAttackCooldownTicksCapped (player );
119
+ var knockbackMultiplier = BetterCombat .config .knockback_reduced_for_fast_attacks
120
+ ? MathHelp .clamp (attackCooldown / 12.5F , 0.1F , 1F )
121
+ : 1F ;
117
122
var lastAttackedTicks = ((LivingEntityAccessor )player ).getLastAttackedTicks ();
118
123
if (!useVanillaPacket ) {
119
124
player .setSneaking (request .isSneaking ());
@@ -133,8 +138,13 @@ public static void initializeHandlers() {
133
138
|| (entity instanceof ArmorStandEntity && ((ArmorStandEntity )entity ).isMarker ())) {
134
139
continue ;
135
140
}
136
- if (BetterCombat .config .allow_fast_attacks && entity instanceof LivingEntity ) {
137
- ((LivingEntity )entity ).timeUntilRegen = 0 ;
141
+ if (entity instanceof LivingEntity livingEntity ) {
142
+ if (BetterCombat .config .allow_fast_attacks ) {
143
+ livingEntity .timeUntilRegen = 0 ;
144
+ }
145
+ if (knockbackMultiplier != 1F ) {
146
+ ((ConfigurableKnockback )livingEntity ).setKnockbackMultiplier_BetterCombat (knockbackMultiplier );
147
+ }
138
148
}
139
149
((LivingEntityAccessor ) player ).setLastAttackedTicks (lastAttackedTicks );
140
150
// System.out.println("Server - Attacking hand: " + (hand.isOffHand() ? "offhand" : "mainhand") + " CD: " + player.getAttackCooldownProgress(0));
@@ -153,6 +163,11 @@ public static void initializeHandlers() {
153
163
player .attack (entity );
154
164
}
155
165
}
166
+ if (entity instanceof LivingEntity livingEntity ) {
167
+ if (knockbackMultiplier != 1F ) {
168
+ ((ConfigurableKnockback )livingEntity ).setKnockbackMultiplier_BetterCombat (1F );
169
+ }
170
+ }
156
171
}
157
172
158
173
if (!useVanillaPacket ) {
0 commit comments