Skip to content

Commit 59639d7

Browse files
Add missing copper variant for eartharmor and change gracefuldescent to be affected by heavy armor
1 parent 4b71f1b commit 59639d7

File tree

7 files changed

+97
-18
lines changed

7 files changed

+97
-18
lines changed

api/src/main/java/me/moros/bending/api/platform/entity/AttributeProperties.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,7 @@ public interface AttributeProperties {
3131

3232
boolean baseValue(AttributeType type, double baseValue);
3333

34-
boolean modify(AttributeType type, Key key, ModifierOperation operation, double value);
34+
boolean addModifier(AttributeType type, Key key, ModifierOperation operation, double value);
35+
36+
boolean removeModifier(AttributeType type, Key key);
3537
}

api/src/main/java/me/moros/bending/api/temporal/TempArmor.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,26 +70,26 @@ public static Builder builder() {
7070

7171
public static Builder leather() {
7272
return builder()
73-
.head(Item.LEATHER_HELMET)
74-
.chest(Item.LEATHER_CHESTPLATE)
75-
.legs(Item.LEATHER_LEGGINGS)
76-
.feet(Item.LEATHER_BOOTS);
73+
.head(Item.LEATHER_HELMET).chest(Item.LEATHER_CHESTPLATE)
74+
.legs(Item.LEATHER_LEGGINGS).feet(Item.LEATHER_BOOTS);
7775
}
7876

7977
public static Builder iron() {
8078
return builder()
81-
.head(Item.IRON_HELMET)
82-
.chest(Item.IRON_CHESTPLATE)
83-
.legs(Item.IRON_LEGGINGS)
84-
.feet(Item.IRON_BOOTS);
79+
.head(Item.IRON_HELMET).chest(Item.IRON_CHESTPLATE)
80+
.legs(Item.IRON_LEGGINGS).feet(Item.IRON_BOOTS);
8581
}
8682

8783
public static Builder gold() {
8884
return builder()
89-
.head(Item.GOLDEN_HELMET)
90-
.chest(Item.GOLDEN_CHESTPLATE)
91-
.legs(Item.GOLDEN_LEGGINGS)
92-
.feet(Item.GOLDEN_BOOTS);
85+
.head(Item.GOLDEN_HELMET).chest(Item.GOLDEN_CHESTPLATE)
86+
.legs(Item.GOLDEN_LEGGINGS).feet(Item.GOLDEN_BOOTS);
87+
}
88+
89+
public static Builder copper() {
90+
return builder()
91+
.head(Item.COPPER_HELMET).chest(Item.COPPER_CHESTPLATE)
92+
.legs(Item.COPPER_LEGGINGS).feet(Item.COPPER_BOOTS);
9393
}
9494

9595
public static final class Builder {

api/src/main/java/me/moros/bending/api/util/material/MaterialUtil.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ public static void init() {
9797
.buildAndRegister();
9898
BlockTag.builder(LOCKABLE_CONTAINERS.key())
9999
.add(BlockTag.reference(KeyUtil.simple("extra_lockable_containers")))
100+
.add(BlockTag.COPPER_CHESTS)
100101
.add(BlockType.CHEST, BlockType.TRAPPED_CHEST, BlockType.BARREL, BlockType.SHULKER_BOX,
101102
BlockType.FURNACE, BlockType.BLAST_FURNACE, BlockType.SMOKER, BlockType.BEACON,
102103
BlockType.DISPENSER, BlockType.DROPPER, BlockType.HOPPER, BlockType.BREWING_STAND)
@@ -117,6 +118,7 @@ public static void init() {
117118
.add(ItemTag.reference(KeyUtil.simple("extra_metal_armor")))
118119
.add(Item.IRON_HELMET, Item.IRON_CHESTPLATE, Item.IRON_LEGGINGS, Item.IRON_BOOTS,
119120
Item.GOLDEN_HELMET, Item.GOLDEN_CHESTPLATE, Item.GOLDEN_LEGGINGS, Item.GOLDEN_BOOTS,
121+
Item.COPPER_HELMET, Item.COPPER_CHESTPLATE, Item.COPPER_LEGGINGS, Item.COPPER_BOOTS,
120122
Item.CHAINMAIL_HELMET, Item.CHAINMAIL_CHESTPLATE, Item.CHAINMAIL_LEGGINGS, Item.CHAINMAIL_BOOTS,
121123
Item.NETHERITE_HELMET, Item.NETHERITE_CHESTPLATE, Item.NETHERITE_LEGGINGS, Item.NETHERITE_BOOTS)
122124
.buildAndRegister();

common/src/main/java/me/moros/bending/common/ability/air/passive/GracefulDescent.java

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,25 @@
1919

2020
package me.moros.bending.common.ability.air.passive;
2121

22+
import java.util.List;
23+
2224
import me.moros.bending.api.ability.AbilityDescription;
2325
import me.moros.bending.api.ability.AbilityInstance;
2426
import me.moros.bending.api.ability.Activation;
27+
import me.moros.bending.api.config.Configurable;
28+
import me.moros.bending.api.config.attribute.Attribute;
29+
import me.moros.bending.api.config.attribute.Modifiable;
30+
import me.moros.bending.api.config.attribute.ModifierOperation;
31+
import me.moros.bending.api.platform.entity.AttributeType;
32+
import me.moros.bending.api.platform.entity.EntityProperties;
2533
import me.moros.bending.api.user.User;
34+
import org.spongepowered.configurate.objectmapping.meta.Comment;
2635

2736
public class GracefulDescent extends AbilityInstance {
37+
private Config userConfig;
38+
39+
private boolean modifiedFall = false;
40+
2841
public GracefulDescent(AbilityDescription desc) {
2942
super(desc);
3043
}
@@ -38,15 +51,53 @@ public boolean activate(User user, Activation method) {
3851

3952
@Override
4053
public void loadConfig() {
54+
userConfig = user.game().configProcessor().calculate(this, Config.class);
4155
}
4256

4357
@Override
4458
public UpdateResult update() {
59+
if (!modifiedFall) {
60+
user.propertyValue(EntityProperties.ATTRIBUTES)
61+
.addModifier(
62+
AttributeType.SAFE_FALL_DISTANCE, description().key(),
63+
ModifierOperation.ADDITIVE, userConfig.safeFallDistanceBonus
64+
);
65+
modifiedFall = true;
66+
}
4567
return UpdateResult.CONTINUE;
4668
}
4769

70+
@Override
71+
public void onDestroy() {
72+
user.propertyValue(EntityProperties.ATTRIBUTES)
73+
.removeModifier(AttributeType.SAFE_FALL_DISTANCE, description().key());
74+
modifiedFall = false;
75+
}
76+
77+
private boolean isGraceful() {
78+
if (!user.canBend(description())) {
79+
return false;
80+
}
81+
return user.propertyValue(EntityProperties.ATTRIBUTES)
82+
.value(AttributeType.ARMOR).orElse(0) < userConfig.heavyArmorThreshold;
83+
}
84+
4885
public static boolean isGraceful(User user) {
4986
return user.game().abilityManager(user.worldKey()).firstInstance(user, GracefulDescent.class)
50-
.map(a -> user.canBend(a.description())).orElse(false);
87+
.map(GracefulDescent::isGraceful).orElse(false);
88+
}
89+
90+
private static final class Config implements Configurable {
91+
@Modifiable(Attribute.HEIGHT)
92+
private double safeFallDistanceBonus = 8;
93+
94+
@Comment("Armor points greater than or equal to this value are considered heavy and the passive will no longer function.")
95+
@Modifiable(Attribute.STRENGTH)
96+
private int heavyArmorThreshold = 8; // full leather armor provides 7 armor
97+
98+
@Override
99+
public List<String> path() {
100+
return List.of("abilities", "air", "passives", "gracefuldescent");
101+
}
51102
}
52103
}

common/src/main/java/me/moros/bending/common/ability/earth/EarthArmor.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import me.moros.bending.api.config.attribute.Modifiable;
3131
import me.moros.bending.api.platform.block.Block;
3232
import me.moros.bending.api.platform.block.BlockState;
33+
import me.moros.bending.api.platform.block.BlockTag;
3334
import me.moros.bending.api.platform.block.BlockType;
3435
import me.moros.bending.api.platform.entity.EntityUtil;
3536
import me.moros.bending.api.platform.potion.PotionEffect;
@@ -49,7 +50,7 @@
4950
import me.moros.math.Vector3d;
5051

5152
public class EarthArmor extends AbilityInstance {
52-
private enum Mode {ROCK, IRON, GOLD}
53+
private enum Mode {ROCK, IRON, GOLD, COPPER}
5354

5455
private Config userConfig;
5556
private RemovalPolicy removalPolicy;
@@ -80,7 +81,13 @@ public boolean activate(User user, Activation method) {
8081
}
8182

8283
if (EarthMaterials.isMetalBendable(source)) {
83-
mode = source.type() == BlockType.GOLD_BLOCK ? Mode.GOLD : Mode.IRON;
84+
if (BlockTag.COPPER.isTagged(source) || source.type() == BlockType.RAW_COPPER_BLOCK) {
85+
mode = Mode.COPPER;
86+
} else if (source.type() == BlockType.GOLD_BLOCK || source.type() == BlockType.RAW_GOLD_BLOCK) {
87+
mode = Mode.GOLD;
88+
} else {
89+
mode = Mode.IRON;
90+
}
8491
resistance = userConfig.metalPower;
8592
SoundEffect.METAL.play(source);
8693
} else {
@@ -120,6 +127,7 @@ private void formArmor() {
120127
case ROCK -> TempArmor.leather();
121128
case IRON -> TempArmor.iron();
122129
case GOLD -> TempArmor.gold();
130+
case COPPER -> TempArmor.copper();
123131
};
124132
if (armorBuilder.duration(userConfig.duration).build(user).isEmpty()) {
125133
removalPolicy = (u, d) -> true;

fabric/src/main/java/me/moros/bending/fabric/platform/entity/FabricAttributes.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public boolean baseValue(AttributeType type, double baseValue) {
5353
}
5454

5555
@Override
56-
public boolean modify(AttributeType type, Key key, ModifierOperation operation, double value) {
56+
public boolean addModifier(AttributeType type, Key key, ModifierOperation operation, double value) {
5757
var instance = handle().getInstance(PlatformAdapter.toFabricAttribute(type));
5858
if (instance == null) {
5959
return false;
@@ -63,4 +63,10 @@ public boolean modify(AttributeType type, Key key, ModifierOperation operation,
6363
instance.addTransientModifier(new AttributeModifier(id, value, op));
6464
return true;
6565
}
66+
67+
@Override
68+
public boolean removeModifier(AttributeType type, Key key) {
69+
var instance = handle().getInstance(PlatformAdapter.toFabricAttribute(type));
70+
return instance != null && instance.removeModifier(PlatformAdapter.identifier(key));
71+
}
6672
}

paper/src/main/java/me/moros/bending/paper/platform/entity/BukkitAttributes.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public boolean baseValue(AttributeType type, double baseValue) {
5454
}
5555

5656
@Override
57-
public boolean modify(AttributeType type, Key key, ModifierOperation operation, double value) {
57+
public boolean addModifier(AttributeType type, Key key, ModifierOperation operation, double value) {
5858
var instance = attributeInstance(type);
5959
if (instance == null) {
6060
return false;
@@ -65,6 +65,16 @@ public boolean modify(AttributeType type, Key key, ModifierOperation operation,
6565
return true;
6666
}
6767

68+
@Override
69+
public boolean removeModifier(AttributeType type, Key key) {
70+
var instance = attributeInstance(type);
71+
if (instance == null) {
72+
return false;
73+
}
74+
instance.removeModifier(key);
75+
return instance.getModifier(key) == null;
76+
}
77+
6878
private AttributeInstance attributeInstance(AttributeType type) {
6979
return handle().getAttribute(PlatformAdapter.toBukkitAttribute(type));
7080
}

0 commit comments

Comments
 (0)