Skip to content

Commit d431b74

Browse files
committed
Merge branch '1.19.3' into 1.19.2
2 parents f94b0aa + 029257c commit d431b74

File tree

83 files changed

+362
-1037
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+362
-1037
lines changed

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# 1.5.5
2+
- Add attack speed cap
3+
- Add knockback reduction for fast attacks (configurable)
4+
- Improve back to back animation overlapping
5+
- Fix offhand arm invisible while 2H animations
6+
- Rework feinting
7+
- Update `staff` and `battlestaff` presets
8+
19
# 1.5.4
210
- Fix attacking hostile mounts/vehicles (Thanks to Emily Darrow)
311
- Fix cleaving for decoration items (such as Item Frames)

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -165,19 +165,19 @@ A fitting preset for a big two handed sword is the `claymore` from Better Combat
165165
}
166166
```
167167

168-
You can check out all available presets [here](/common/src/main/resources/data/bettercombat/weapon_attributes).
168+
You can check out all available presets [here](common/src/main/resources/data/bettercombat/weapon_attributes).
169169

170-
You can check out how presets are used to add compatibility for Vanilla weapons [here](/common/src/main/resources/data/minecraft/weapon_attributes).
170+
You can check out how presets are used to add compatibility for Vanilla weapons [here](common/src/main/resources/data/minecraft/weapon_attributes).
171171

172172
You can make and reference your own presets the same way.
173173

174174
## Custom attributes
175175

176176
If you want unique behaviour for your weapon, you can create attributes from scratch.
177177

178-
The content of your weapon attributes JSON file is parsed into an [AttributesContainer](https://github.com/ZsoltMolnarrr/BetterCombat/blob/main/src/main/java/net/bettercombat/api/AttributesContainer.java) object. (Check out the inline java documentation of [AttributesContainer](https://github.com/ZsoltMolnarrr/BetterCombat/blob/main/src/main/java/net/bettercombat/api/AttributesContainer.java) for details.)
178+
The content of your weapon attributes JSON file is parsed into an [AttributesContainer](common/src/main/java/net/bettercombat/api/AttributesContainer.java) object. (Check out the inline java documentation of [AttributesContainer](common/src/main/java/net/bettercombat/api/AttributesContainer.java) for details.)
179179

180-
When no parent is specified, the value for `"attributes"` key must be a full json object that can be parsed into [WeaponAttributes](https://github.com/ZsoltMolnarrr/BetterCombat/blob/main/src/main/java/net/bettercombat/api/WeaponAttributes.java) object.
180+
When no parent is specified, the value for `"attributes"` key must be a full json object that can be parsed into [WeaponAttributes](common/src/main/java/net/bettercombat/api/WeaponAttributes.java) object.
181181

182182
```
183183
{
@@ -193,7 +193,7 @@ If you need more details, the java documentation of [WeaponAttributes](common/sr
193193

194194
---
195195

196-
When `"parent"` and `"attributes"` are both specified, you can customize attributes by partially (or fully) overriding the properties. Make sure the inheritance results in fully parsable [WeaponAttributes](https://github.com/ZsoltMolnarrr/BetterCombat/blob/main/src/main/java/net/bettercombat/api/WeaponAttributes.java) object.
196+
When `"parent"` and `"attributes"` are both specified, you can customize attributes by partially (or fully) overriding the properties. Make sure the inheritance results in fully parsable [WeaponAttributes](common/src/main/java/net/bettercombat/api/WeaponAttributes.java) object.
197197

198198
(Attributes are merged in parent -> child order. So parent properties are copied and overridden with child. The chain of inheritance can be any length.)
199199
```

common/src/main/java/net/bettercombat/api/animation/FirstPersonAnimation.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package net.bettercombat.api.animation;
22

33
import dev.kosmx.playerAnim.api.layered.ModifierLayer;
4-
import net.bettercombat.client.animation.FirstPersonAnimator;
5-
import net.bettercombat.client.animation.FirstPersonRenderHelper;
4+
import net.bettercombat.client.animation.first_person.FirstPersonAnimator;
5+
import net.bettercombat.client.animation.first_person.FirstPersonRenderHelper;
66
import net.minecraft.client.network.AbstractClientPlayerEntity;
77

88
public class FirstPersonAnimation {
99
// Adding the given layer will make it visible in first person while it is actively playing
1010
public static void addLayer(AbstractClientPlayerEntity player, ModifierLayer layer) {
11-
((FirstPersonAnimator)player).addLayer(layer);
11+
((FirstPersonAnimator)player).addFirstPersonAnimationLayer(layer);
1212
}
1313

1414
public static boolean isRenderingAttackAnimationInFirstPerson() {

common/src/main/java/net/bettercombat/client/BetterCombatClient.java

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import net.bettercombat.BetterCombat;
77
import net.bettercombat.Platform;
88
import net.bettercombat.PlatformClient;
9+
import net.bettercombat.client.animation.AnimationRegistry;
910
import net.bettercombat.config.ClientConfig;
1011
import net.bettercombat.config.ClientConfigWrapper;
1112
import net.fabricmc.api.ClientModInitializer;

common/src/main/java/net/bettercombat/client/ClientNetwork.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package net.bettercombat.client;
22

33
import net.bettercombat.BetterCombat;
4+
import net.bettercombat.client.animation.PlayerAttackAnimatable;
45
import net.bettercombat.logic.WeaponRegistry;
56
import net.bettercombat.network.Packets;
67
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
@@ -17,9 +18,9 @@ public static void initializeHandlers() {
1718
var entity = client.world.getEntityById(packet.playerId());
1819
if (entity instanceof PlayerEntity) {
1920
if (packet.animationName().equals(Packets.AttackAnimation.StopSymbol)) {
20-
((PlayerAttackAnimatable)entity).stopAttackAnimation();
21+
((PlayerAttackAnimatable)entity).stopAttackAnimation(packet.length());
2122
} else {
22-
((PlayerAttackAnimatable)entity).playAttackAnimation(packet.animationName(), packet.isOffHand(), packet.length(), packet.upswing());
23+
((PlayerAttackAnimatable)entity).playAttackAnimation(packet.animationName(), packet.animatedHand(), packet.length(), packet.upswing());
2324
}
2425
}
2526
});

common/src/main/java/net/bettercombat/client/PlayerAttackAnimatable.java

-12
This file was deleted.

common/src/main/java/net/bettercombat/client/AnimationRegistry.java common/src/main/java/net/bettercombat/client/animation/AnimationRegistry.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package net.bettercombat.client;
1+
package net.bettercombat.client.animation;
22

33
import com.mojang.logging.LogUtils;
44
import dev.kosmx.playerAnim.core.data.KeyframeAnimation;

common/src/main/java/net/bettercombat/client/animation/AttackAnimationSubStack.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@
33
import dev.kosmx.playerAnim.api.layered.ModifierLayer;
44
import dev.kosmx.playerAnim.api.layered.modifier.AbstractModifier;
55
import dev.kosmx.playerAnim.api.layered.modifier.MirrorModifier;
6+
import net.bettercombat.client.animation.modifier.AdjustmentModifier;
7+
import net.bettercombat.client.animation.modifier.TransmissionSpeedModifier;
68

79
public class AttackAnimationSubStack {
810
public final TransmissionSpeedModifier speed = new TransmissionSpeedModifier();
911
public final MirrorModifier mirror = new MirrorModifier();
1012
public final ModifierLayer base = new ModifierLayer(null);
13+
public final AdjustmentModifier adjustmentModifier;
1114

12-
public AttackAnimationSubStack(AbstractModifier adjustmentModifier) {
15+
public AttackAnimationSubStack(AdjustmentModifier adjustmentModifier) {
16+
this.adjustmentModifier = adjustmentModifier;
1317
mirror.setEnabled(false);
1418
base.addModifier(adjustmentModifier, 0);
1519
base.addModifier(speed, 0);

common/src/main/java/net/bettercombat/client/animation/FirstPersonAnimator.java

-7
This file was deleted.

common/src/main/java/net/bettercombat/client/animation/FirstPersonRenderHelper.java

-6
This file was deleted.

common/src/main/java/net/bettercombat/client/animation/IExtendedAnimation.java

-5
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package net.bettercombat.client.animation;
2+
3+
import dev.kosmx.playerAnim.api.layered.IAnimation;
4+
import net.bettercombat.logic.AnimatedHand;
5+
6+
import java.util.Optional;
7+
8+
public interface PlayerAttackAnimatable {
9+
void updateAnimationsOnTick();
10+
void playAttackAnimation(String name, AnimatedHand hand, float length, float upswing);
11+
void stopAttackAnimation(float length);
12+
}

common/src/main/java/net/bettercombat/client/animation/PoseSubStack.java

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import dev.kosmx.playerAnim.api.layered.modifier.MirrorModifier;
77
import dev.kosmx.playerAnim.core.data.KeyframeAnimation;
88
import dev.kosmx.playerAnim.core.util.Ease;
9+
import net.bettercombat.client.animation.first_person.CustomAnimationPlayer;
910

1011
import javax.annotation.Nullable;
1112
import java.util.function.Consumer;

common/src/main/java/net/bettercombat/client/animation/CustomAnimationPlayer.java common/src/main/java/net/bettercombat/client/animation/first_person/CustomAnimationPlayer.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package net.bettercombat.client.animation;
1+
package net.bettercombat.client.animation.first_person;
22

33
import dev.kosmx.playerAnim.api.layered.KeyframeAnimationPlayer;
44
import dev.kosmx.playerAnim.core.data.KeyframeAnimation;
@@ -13,13 +13,13 @@ public CustomAnimationPlayer(KeyframeAnimation emote, int t) {
1313
super(emote, t);
1414
}
1515

16-
public boolean isWindingDown() {
16+
public boolean isWindingDown(float tickDelta) {
1717
var windDownStart = getData().endTick + ((getData().stopTick - getData().endTick) / 4);
18-
return (getTick() > windDownStart);
18+
return ((getTick() + tickDelta) > (windDownStart + 0.5F)); // + 0.5 for smoother transition
1919
}
2020

2121
@Override
22-
public boolean isActiveInFirstPerson() {
23-
return isActive() && !isWindingDown();
22+
public boolean isActiveInFirstPerson(float tickDelta) {
23+
return isActive() && !isWindingDown(tickDelta);
2424
}
2525
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package net.bettercombat.client.animation.first_person;
2+
3+
import dev.kosmx.playerAnim.api.layered.IAnimation;
4+
import dev.kosmx.playerAnim.api.layered.ModifierLayer;
5+
6+
import java.util.Optional;
7+
8+
public interface FirstPersonAnimator {
9+
void addFirstPersonAnimationLayer(ModifierLayer layer);
10+
Optional<IAnimation> getActiveFirstPersonAnimation(float tickDelta);
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package net.bettercombat.client.animation.first_person;
2+
3+
import net.bettercombat.logic.AnimatedHand;
4+
5+
public class FirstPersonRenderHelper {
6+
public static boolean isRenderingFirstPersonPlayerModel = false;
7+
// public static boolean isAttackingWithOffHand = false;
8+
9+
10+
public static AnimationProperties current = AnimationProperties.defaults;
11+
public static void resetProperties() {
12+
current = AnimationProperties.defaults;
13+
}
14+
15+
public record AnimationProperties(AnimatedHand hand) {
16+
public static AnimationProperties defaults = new AnimationProperties(AnimatedHand.MAIN_HAND);
17+
}
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package net.bettercombat.client.animation.first_person;
2+
3+
public interface IExtendedAnimation {
4+
boolean isActiveInFirstPerson(float tickDelta);
5+
}

common/src/main/java/net/bettercombat/client/animation/AdjustmentModifier.java common/src/main/java/net/bettercombat/client/animation/modifier/AdjustmentModifier.java

+28-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package net.bettercombat.client.animation;
1+
package net.bettercombat.client.animation.modifier;
22

33
import dev.kosmx.playerAnim.api.TransformType;
44
import dev.kosmx.playerAnim.api.layered.KeyframeAnimationPlayer;
@@ -32,8 +32,34 @@ private float getFadeIn(float delta) {
3232
return fadeIn;
3333
}
3434

35+
@Override
36+
public void tick() {
37+
super.tick();
38+
39+
if (remainingFadeout > 0) {
40+
remainingFadeout -= 1;
41+
if(remainingFadeout <= 0) {
42+
instructedFadeout = 0;
43+
}
44+
}
45+
}
46+
47+
private int instructedFadeout = 0;
48+
private int remainingFadeout = 0;
49+
50+
public void fadeOut(int fadeOut) {
51+
instructedFadeout = fadeOut;
52+
remainingFadeout = fadeOut + 1;
53+
}
54+
3555
private float getFadeOut(float delta) {
3656
float fadeOut = 1;
57+
if(remainingFadeout > 0 && instructedFadeout > 0) {
58+
float current = Math.max(remainingFadeout - delta , 0);
59+
fadeOut = current / ((float)instructedFadeout);
60+
Math.min(fadeOut, 1F);
61+
return fadeOut;
62+
}
3763
if(this.getAnim() instanceof KeyframeAnimationPlayer player) {
3864
float currentTick = player.getTick() + delta;
3965

@@ -71,7 +97,7 @@ private Vec3f transformVector(Vec3f vector, TransformType type, PartModifier par
7197
return vector.add(partModifier.offset);
7298
}
7399
case ROTATION -> {
74-
return vector.add(partModifier.rotation.scale(fade));
100+
return vector.add(partModifier.rotation.scale(fade));
75101
}
76102
case BEND -> {
77103
// Nothing to do here...

common/src/main/java/net/bettercombat/client/animation/TransmissionSpeedModifier.java common/src/main/java/net/bettercombat/client/animation/modifier/TransmissionSpeedModifier.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package net.bettercombat.client.animation;
1+
package net.bettercombat.client.animation.modifier;
22

33
import dev.kosmx.playerAnim.api.layered.modifier.SpeedModifier;
44

common/src/main/java/net/bettercombat/config/ServerConfig.java

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ public class ServerConfig implements ConfigData {
1919
public boolean allow_fast_attacks = true;
2020
@Comment("Allows client-side target search and server-side attack request execution against currently mounted entity of the player")
2121
public boolean allow_attacking_mount = false;
22+
@Comment("The minimum number of ticks between two attacks")
23+
public int attack_interval_cap = 2;
2224
@Comment("""
2325
Blacklist for entities that are acting as vehicle but should not be treated as protected mounts.
2426
Classical example is an alexsmobs:crocodile attempting a death spin.
@@ -34,6 +36,8 @@ public class ServerConfig implements ConfigData {
3436
public boolean movement_speed_applied_smoothly = true;
3537
@Comment("Determines whether or not to apply movement speed reduction while attacking mounted")
3638
public boolean movement_speed_effected_while_mounting = false;
39+
@Comment("Attacks faster than a vanilla sword will do smaller knockback, proportionally.")
40+
public boolean knockback_reduced_for_fast_attacks = true;
3741
@Comment("Multiplier for `attack_range`, during target lookup on both sides. " +
3842
"Large sized entities may be colliding with weapon hitbox, but center of entities can have bigger distance than `attack_range`")
3943
public float target_search_range_multiplier = 2F;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package net.bettercombat.logic;
2+
3+
public enum AnimatedHand {
4+
MAIN_HAND, OFF_HAND, TWO_HANDED;
5+
6+
public static AnimatedHand from(boolean isOffHand, boolean isTwoHanded) {
7+
if (isTwoHanded) {
8+
return TWO_HANDED;
9+
}
10+
if (isOffHand) {
11+
return OFF_HAND;
12+
}
13+
return MAIN_HAND;
14+
}
15+
16+
public boolean isOffHand() {
17+
return this == OFF_HAND;
18+
}
19+
}

common/src/main/java/net/bettercombat/logic/PlayerAttackHelper.java

+5
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ public static boolean isTwoHandedWielding(PlayerEntity player) {
4040
return false;
4141
}
4242

43+
public static float getAttackCooldownTicksCapped(PlayerEntity player) {
44+
// `getAttackCooldownProgressPerTick` should be called `getAttackCooldownLengthTicks`
45+
return Math.max(player.getAttackCooldownProgressPerTick(), BetterCombat.config.attack_interval_cap);
46+
}
47+
4348
public static AttackHand getCurrentAttack(PlayerEntity player, int comboCount) {
4449
if (isDualWielding(player)) {
4550
boolean isOffHand = shouldAttackWithOffHand(player,comboCount);

common/src/main/java/net/bettercombat/logic/TargetHelper.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ public static Relation getRelation(PlayerEntity attacker, Entity target) {
3333
return getRelation(attacker, owner);
3434
}
3535
}
36-
36+
if (target instanceof AbstractDecorationEntity) {
37+
return Relation.NEUTRAL;
38+
}
3739
var config = BetterCombat.config;
3840
var casterTeam = attacker.getScoreboardTeam();
3941
var targetTeam = target.getScoreboardTeam();
@@ -50,9 +52,6 @@ public static Relation getRelation(PlayerEntity attacker, Entity target) {
5052
if (target instanceof HostileEntity) {
5153
return Relation.coalesce(config.player_relation_to_hostiles, Relation.HOSTILE);
5254
}
53-
if (target instanceof AbstractDecorationEntity) {
54-
return Relation.NEUTRAL;
55-
}
5655
return Relation.coalesce(config.player_relation_to_other, Relation.HOSTILE);
5756
} else {
5857
return attacker.isTeammate(target) ? Relation.FRIENDLY : Relation.HOSTILE;

common/src/main/java/net/bettercombat/logic/WeaponAttributesFallback.java

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package net.bettercombat.logic;
22

33
import net.bettercombat.BetterCombat;
4+
import net.bettercombat.utils.PatternMatching;
45
import net.minecraft.entity.EquipmentSlot;
56
import net.minecraft.entity.attribute.EntityAttribute;
67
import net.minecraft.entity.attribute.EntityAttributes;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package net.bettercombat.logic.knockback;
2+
3+
public interface ConfigurableKnockback {
4+
void setKnockbackMultiplier_BetterCombat(float strength);
5+
}

0 commit comments

Comments
 (0)