Skip to content

Commit bad06c8

Browse files
committed
Merge branch '1.19.3' into 1.19.2
2 parents e2cded6 + b8c89c2 commit bad06c8

File tree

11 files changed

+101
-26
lines changed

11 files changed

+101
-26
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# 1.7.0
2+
3+
- Reworked support for Sweeping Edge
4+
- Reduce multipliers spread for maces
5+
16
# 1.6.2
27

38
- Update claymore pose

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

-7
This file was deleted.

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

+23-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,29 @@ public class ServerConfig implements ConfigData {
2727
(Note all hostile mobs hittable by default, this config is to fix faulty mobs)""")
2828
public String[] hostile_player_vehicles = {"alexsmobs:crocodile"};
2929
@Comment("Allows vanilla sweeping mechanic to work and Sweeping Edge enchantment")
30-
public boolean allow_sweeping = true;
30+
public boolean allow_vanilla_sweeping = false;
31+
@Comment("Allows new sweeping mechanic (by Better Combat) to work, including Sweeping Edge enchantment")
32+
public boolean allow_reworked_sweeping = true;
33+
@Comment("""
34+
The more additional targets a weapon swing hits, the weaker it will get.
35+
Entities struck (+1) in a swing more than this, won't get weakened any further.
36+
""")
37+
public int reworked_sweeping_extra_target_count = 4;
38+
@Comment("""
39+
Determines how weak the attack becomes when striking `reworked_sweeping_extra_target_count + 1` targets.
40+
Example values:
41+
- `0.5` -50% damage
42+
""")
43+
public float reworked_sweeping_maximum_damage_penalty = 0.5F;
44+
@Comment("""
45+
The maximum level Sweeping Edge enchantment applied to the attackers weapon will restore this amount of penalty.
46+
Example values:
47+
- `0.5` restores 50% damage penalty when 3 levels are applied, so 16.66% when 1 level is applied
48+
""")
49+
public float reworked_sweeping_enchant_restores = 0.5F;
50+
public boolean reworked_sweeping_plays_sound = true;
51+
public boolean reworked_sweeping_emits_particles = true;
52+
public boolean reworked_sweeping_sound_and_particles_only_for_swords = true;
3153
@Comment("Allows client-side target search to ignore obstacles. WARNING! Setting this to `false` significantly increases the load on clients.")
3254
public boolean allow_attacking_thru_walls = false;
3355
@Comment("Applies movement speed multiplier while attacking. (Min: 0, Max: 1). Use `0` for a full stop while attacking. Use `1` for no movement speed penalty")

common/src/main/java/net/bettercombat/mixin/PlayerEntityMixin.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public void post_Tick(CallbackInfo ci) {
4949

5050
@ModifyVariable(method = "attack", at = @At("STORE"), ordinal = 3)
5151
private boolean disableSweeping(boolean value) {
52-
if (BetterCombat.config.allow_sweeping) {
52+
if (BetterCombat.config.allow_vanilla_sweeping) {
5353
return value;
5454
}
5555

common/src/main/java/net/bettercombat/mixin/SweepingEnchantmentMixin.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ public class SweepingEnchantmentMixin {
1212

1313
@Inject(method = "getMaxLevel", at = @At("HEAD"), cancellable = true)
1414
public void getMaxLevel_DisableSweeping(CallbackInfoReturnable<Integer> cir) {
15-
if (BetterCombat.config == null || BetterCombat.config.allow_sweeping) {
15+
if (BetterCombat.config == null
16+
|| BetterCombat.config.allow_vanilla_sweeping
17+
|| BetterCombat.config.allow_reworked_sweeping) {
1618
return;
1719
}
1820
cir.setReturnValue(0);

common/src/main/java/net/bettercombat/mixin/client/ClientPlayerEntityMixin.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import net.bettercombat.BetterCombat;
44
import net.bettercombat.api.MinecraftClient_BetterCombat;
5-
import net.bettercombat.client.MathHelper;
5+
import net.bettercombat.utils.MathHelper;
66
import net.minecraft.client.MinecraftClient;
77
import net.minecraft.client.network.ClientPlayerEntity;
88
import org.spongepowered.asm.mixin.Mixin;

common/src/main/java/net/bettercombat/network/ServerNetwork.java

+42-4
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111
import net.bettercombat.logic.WeaponRegistry;
1212
import net.bettercombat.logic.knockback.ConfigurableKnockback;
1313
import net.bettercombat.mixin.LivingEntityAccessor;
14-
import net.bettercombat.utils.MathHelp;
14+
import net.bettercombat.utils.MathHelper;
1515
import net.bettercombat.utils.SoundHelper;
1616
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
1717
import net.fabricmc.fabric.api.networking.v1.PlayerLookup;
1818
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
1919
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
20+
import net.minecraft.enchantment.EnchantmentHelper;
21+
import net.minecraft.enchantment.Enchantments;
2022
import net.minecraft.entity.Entity;
2123
import net.minecraft.entity.ExperienceOrbEntity;
2224
import net.minecraft.entity.ItemEntity;
@@ -26,9 +28,12 @@
2628
import net.minecraft.entity.attribute.EntityAttributes;
2729
import net.minecraft.entity.decoration.ArmorStandEntity;
2830
import net.minecraft.entity.projectile.PersistentProjectileEntity;
31+
import net.minecraft.item.SwordItem;
2932
import net.minecraft.network.PacketByteBuf;
3033
import net.minecraft.network.packet.c2s.play.PlayerInteractEntityC2SPacket;
34+
import net.minecraft.particle.ParticleTypes;
3135
import net.minecraft.server.world.ServerWorld;
36+
import net.minecraft.sound.SoundEvents;
3237
import net.minecraft.text.Text;
3338
import org.slf4j.Logger;
3439

@@ -39,6 +44,10 @@ public class ServerNetwork {
3944

4045
private static PacketByteBuf configSerialized = PacketByteBufs.create();
4146

47+
private static final UUID COMBO_DAMAGE_MODIFIER_ID = UUID.randomUUID();
48+
private static final UUID DUAL_WIELDING_MODIFIER_ID = UUID.randomUUID();
49+
private static final UUID SWEEPING_MODIFIER_ID = UUID.randomUUID();
50+
4251
public static void initializeHandlers() {
4352
configSerialized = Packets.ConfigSync.write(BetterCombat.config);
4453
ServerPlayConnectionEvents.JOIN.register( (handler, sender, server) -> {
@@ -88,6 +97,7 @@ public static void initializeHandlers() {
8897
((PlayerAttackProperties)player).setComboCount(request.comboCount());
8998
Multimap<EntityAttribute, EntityAttributeModifier> comboAttributes = null;
9099
Multimap<EntityAttribute, EntityAttributeModifier> dualWieldingAttributes = null;
100+
Multimap<EntityAttribute, EntityAttributeModifier> sweepingModifiers = HashMultimap.create();
91101
double range = 18.0;
92102
if (attributes != null && attack != null) {
93103
range = attributes.attackRange();
@@ -96,15 +106,15 @@ public static void initializeHandlers() {
96106
double comboMultiplier = attack.damageMultiplier() - 1;
97107
comboAttributes.put(
98108
EntityAttributes.GENERIC_ATTACK_DAMAGE,
99-
new EntityAttributeModifier(UUID.randomUUID(), "COMBO_DAMAGE_MULTIPLIER", comboMultiplier, EntityAttributeModifier.Operation.MULTIPLY_BASE));
109+
new EntityAttributeModifier(COMBO_DAMAGE_MODIFIER_ID, "COMBO_DAMAGE_MULTIPLIER", comboMultiplier, EntityAttributeModifier.Operation.MULTIPLY_BASE));
100110
player.getAttributes().addTemporaryModifiers(comboAttributes);
101111

102112
var dualWieldingMultiplier = PlayerAttackHelper.getDualWieldingAttackDamageMultiplier(player, hand) - 1;
103113
if (dualWieldingMultiplier != 0) {
104114
dualWieldingAttributes = HashMultimap.create();
105115
dualWieldingAttributes.put(
106116
EntityAttributes.GENERIC_ATTACK_DAMAGE,
107-
new EntityAttributeModifier(UUID.randomUUID(), "DUAL_WIELDING_DAMAGE_MULTIPLIER", dualWieldingMultiplier, EntityAttributeModifier.Operation.MULTIPLY_TOTAL));
117+
new EntityAttributeModifier(DUAL_WIELDING_MODIFIER_ID, "DUAL_WIELDING_DAMAGE_MULTIPLIER", dualWieldingMultiplier, EntityAttributeModifier.Operation.MULTIPLY_TOTAL));
108118
player.getAttributes().addTemporaryModifiers(dualWieldingAttributes);
109119
}
110120

@@ -113,17 +123,42 @@ public static void initializeHandlers() {
113123
}
114124

115125
SoundHelper.playSound(world, player, attack.swingSound());
126+
127+
if (BetterCombat.config.allow_reworked_sweeping && request.entityIds().length > 1) {
128+
double multiplier = 1.0
129+
- (BetterCombat.config.reworked_sweeping_maximum_damage_penalty / BetterCombat.config.reworked_sweeping_extra_target_count)
130+
* Math.min(BetterCombat.config.reworked_sweeping_extra_target_count, request.entityIds().length - 1);
131+
int sweepingLevel = EnchantmentHelper.getLevel(Enchantments.SWEEPING, hand.itemStack());
132+
double sweepingSteps = BetterCombat.config.reworked_sweeping_enchant_restores / ((double)Enchantments.SWEEPING.getMaxLevel());
133+
multiplier += sweepingLevel * sweepingSteps;
134+
multiplier = Math.min(multiplier, 1);
135+
sweepingModifiers.put(
136+
EntityAttributes.GENERIC_ATTACK_DAMAGE,
137+
new EntityAttributeModifier(SWEEPING_MODIFIER_ID, "SWEEPING_DAMAGE_MODIFIER", multiplier - 1, EntityAttributeModifier.Operation.MULTIPLY_TOTAL));
138+
// System.out.println("Applied sweeping multiplier " + multiplier + " , sweepingSteps " + sweepingSteps + " , enchant bonus: " + (sweepingLevel * sweepingSteps));
139+
player.getAttributes().addTemporaryModifiers(sweepingModifiers);
140+
141+
boolean playEffects = !BetterCombat.config.reworked_sweeping_sound_and_particles_only_for_swords
142+
|| (hand.itemStack().getItem() instanceof SwordItem);
143+
if (BetterCombat.config.reworked_sweeping_plays_sound && playEffects) {
144+
world.playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.ENTITY_PLAYER_ATTACK_SWEEP, player.getSoundCategory(), 1.0f, 1.0f);
145+
}
146+
if (BetterCombat.config.reworked_sweeping_emits_particles && playEffects) {
147+
player.spawnSweepAttackParticles();
148+
}
149+
}
116150
}
117151

118152
var attackCooldown = PlayerAttackHelper.getAttackCooldownTicksCapped(player);
119153
var knockbackMultiplier = BetterCombat.config.knockback_reduced_for_fast_attacks
120-
? MathHelp.clamp(attackCooldown / 12.5F, 0.1F, 1F)
154+
? MathHelper.clamp(attackCooldown / 12.5F, 0.1F, 1F)
121155
: 1F;
122156
var lastAttackedTicks = ((LivingEntityAccessor)player).getLastAttackedTicks();
123157
if (!useVanillaPacket) {
124158
player.setSneaking(request.isSneaking());
125159
}
126160

161+
127162
for (int entityId: request.entityIds()) {
128163
// getEntityById(entityId);
129164
boolean isBossPart = false;
@@ -183,6 +218,9 @@ public static void initializeHandlers() {
183218
if (dualWieldingAttributes != null) {
184219
player.getAttributes().removeModifiers(dualWieldingAttributes);
185220
}
221+
if (!sweepingModifiers.isEmpty()) {
222+
player.getAttributes().removeModifiers(sweepingModifiers);
223+
}
186224
((PlayerAttackProperties)player).setComboCount(-1);
187225
});
188226
});

common/src/main/java/net/bettercombat/utils/MathHelp.java

-7
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package net.bettercombat.utils;
2+
3+
public class MathHelper {
4+
// Generic
5+
public static float clamp(float value, float min, float max) {
6+
return Math.max(Math.min(value, max), min);
7+
}
8+
9+
// Easing
10+
11+
public static double easeOutCubic(double number) {
12+
return 1.0 - Math.pow(1.0 - number, 3);
13+
}
14+
15+
public double easeInExpo(double x) {
16+
return x == 0 ? 0 : Math.pow(2, 10 * x - 10);
17+
}
18+
19+
public double easeOutExpo(double x) {
20+
return x == 1 ? 1 : 1 - Math.pow(2, -10 * x);
21+
}
22+
}

common/src/main/resources/data/bettercombat/weapon_attributes/mace.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"attacks": [
66
{
77
"hitbox": "HORIZONTAL_PLANE",
8-
"damage_multiplier": 0.7,
8+
"damage_multiplier": 0.8,
99
"angle": 150,
1010
"upswing": 0.5,
1111
"animation": "bettercombat:one_handed_slash_horizontal_right",
@@ -15,7 +15,7 @@
1515
},
1616
{
1717
"hitbox": "HORIZONTAL_PLANE",
18-
"damage_multiplier": 0.7,
18+
"damage_multiplier": 0.8,
1919
"angle": 150,
2020
"upswing": 0.5,
2121
"animation": "bettercombat:one_handed_slash_horizontal_left",
@@ -25,7 +25,7 @@
2525
},
2626
{
2727
"hitbox": "VERTICAL_PLANE",
28-
"damage_multiplier": 1.6,
28+
"damage_multiplier": 1.4,
2929
"angle": 90,
3030
"upswing": 0.5,
3131
"animation": "bettercombat:one_handed_slam",

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ loader_version=0.14.9
1515
forge_version=43.1.25
1616

1717
# Mod Properties
18-
mod_version=1.6.2
18+
mod_version=1.7.0
1919
maven_group=net
2020
archives_base_name=bettercombat
2121

0 commit comments

Comments
 (0)