Skip to content

Commit f116926

Browse files
WakelessSloth56lainio24
andcommittedFeb 8, 2025··
feat: impl proficiency
Co-authored-by: lainio24 <[email protected]>
1 parent bcfbd2a commit f116926

File tree

4 files changed

+41
-6
lines changed

4 files changed

+41
-6
lines changed
 

‎src/main/java/org/auioc/mcmod/harmonicench/enchantment/HEEnchantments.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public class HEEnchantments {
6969

7070
public static final ResourceKey<Enchantment> AIM = register("aim", AimEnchantment::bootstrap); // TODO
7171
public static final ResourceKey<Enchantment> BANE_OF_CHAMPIONS = register("bane_of_champions", BaneOfChampionsEnchantment::bootstrap);
72-
public static final ResourceKey<Enchantment> BLESSING = register("blessing", BlessingEnchantment::bootstrap); // TODO
72+
public static final ResourceKey<Enchantment> BLESSING = register("blessing", BlessingEnchantment::bootstrap);
7373
public static final ResourceKey<Enchantment> BLUNT = register("blunt", BluntEnchantment::bootstrap); // TODO WIP
7474
public static final ResourceKey<Enchantment> DEEP_STUDY = register("deep_study", DeepStudyEnchantment::bootstrap);
7575
public static final ResourceKey<Enchantment> DINING = register("dining", DiningEnchantment::bootstrap);
@@ -84,7 +84,7 @@ public class HEEnchantments {
8484
public static final ResourceKey<Enchantment> LUCK_OF_THE_SNOW = register("luck_of_the_snow", LuckOfTheSnowEnchantment::bootstrap);
8585
public static final ResourceKey<Enchantment> MOB_AFFINITY = register("mob_affinity", MobAffinityEnchantment::bootstrap); // TODO
8686
public static final ResourceKey<Enchantment> OBSERVER = register("observer", ObserverEnchantment::bootstrap); // TODO
87-
public static final ResourceKey<Enchantment> PROFICIENCY = register("proficiency", ProficiencyEnchantment::bootstrap); // TODO
87+
public static final ResourceKey<Enchantment> PROFICIENCY = register("proficiency", ProficiencyEnchantment::bootstrap);
8888
public static final ResourceKey<Enchantment> RAPIER = register("rapier", RapierEnchantment::bootstrap);
8989
public static final ResourceKey<Enchantment> REBELLING_CURSE = register("rebelling_curse", RebellingCurseEnchantment::bootstrap);
9090
public static final ResourceKey<Enchantment> SACRIFICING_CURSE = register("sacrificing_curse", SacrificingCurseEnchantment::bootstrap); // TODO

‎src/main/java/org/auioc/mcmod/harmonicench/enchantment/impl/ProficiencyEnchantment.java

+37-2
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,19 @@
2121

2222
import net.minecraft.tags.ItemTags;
2323
import net.minecraft.world.entity.EquipmentSlotGroup;
24+
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
25+
import net.minecraft.world.entity.ai.attributes.Attributes;
2426
import net.minecraft.world.item.enchantment.Enchantments;
2527
import net.neoforged.neoforge.common.Tags;
28+
import org.auioc.mcmod.harmonicench.api.HEEnchantedValue;
2629
import org.auioc.mcmod.harmonicench.api.HEEnchantment;
30+
import org.auioc.mcmod.harmonicench.component.HEEDataComponents;
31+
import org.auioc.mcmod.harmonicench.enchantment.HEEnchantmentEffectComponents;
2732
import org.auioc.mcmod.harmonicench.enchantment.HEEnchantments;
33+
import org.auioc.mcmod.harmonicench.enchantment.effect.HEAttributeEffect;
34+
import org.auioc.mcmod.harmonicench.enchantment.effect.SetItemProficiency;
35+
36+
import java.util.List;
2837

2938
/**
3039
* <b>TODO 熟练 Proficiency</b>
@@ -61,6 +70,17 @@ public class ProficiencyEnchantment extends HEEnchantment {
6170
*/
6271
private static final Cost COST = dynamicCost(1, 10, 61, 10);
6372

73+
74+
/**
75+
* <code>[∑(lvl,k=1)(1/k)]/200</code>
76+
*/
77+
private static final HEEnchantedValue PROBABILITY = HEEnchantedValue.fraction(
78+
HEEnchantedValue.harmonic(HEEnchantedValue.level(), 1.0F, HEEnchantedValue.identity()),
79+
HEEnchantedValue.constant(200)
80+
);
81+
82+
private static final HEEnchantedValue BONUS = HEEnchantedValue.fromDataComponent(HEEDataComponents.PROFICIENCY.get());
83+
6484
private static final BuilderFunction BUILDER = define(
6585
SUPPORTED_ITEMS,
6686
PRIMARY_ITEMS,
@@ -69,9 +89,24 @@ public class ProficiencyEnchantment extends HEEnchantment {
6989
5,
7090
COST,
7191
1,
72-
EquipmentSlotGroup.HAND
92+
EquipmentSlotGroup.MAINHAND
7393
).andThen((key, ctx, builder) -> builder
74-
94+
.withEffect(
95+
HEEnchantmentEffectComponents.BLOCK_DESTROYED.get(),
96+
new SetItemProficiency(HEEnchantedValue.chance(
97+
PROBABILITY,
98+
HEEnchantedValue.sum(HEEnchantedValue.identity(), HEEnchantedValue.constant(1)),
99+
HEEnchantedValue.identity()
100+
))
101+
).withSpecialEffect(
102+
HEEnchantmentEffectComponents.ATTRIBUTES.get(),
103+
List.of(new HEAttributeEffect(
104+
HEEnchantments.PROFICIENCY,
105+
Attributes.MINING_EFFICIENCY,
106+
BONUS,
107+
AttributeModifier.Operation.ADD_MULTIPLIED_BASE
108+
))
109+
)
75110
);
76111

77112
public static Bootstrap.Builder bootstrap() {

‎src/main/resources/assets/harmonicench/lang/en_us.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"enchantment.harmonicench.luck_of_the_snow": "Luck of the Snow",
2121
"enchantment.harmonicench.mob_affinity": "Mob Affinity (WIP)",
2222
"enchantment.harmonicench.observer": "Observer (WIP)",
23-
"enchantment.harmonicench.proficiency": "Proficiency (WIP)",
23+
"enchantment.harmonicench.proficiency": "Proficiency",
2424
"enchantment.harmonicench.rapier": "Rapier",
2525
"enchantment.harmonicench.rebelling_curse": "Curse of Rebelling",
2626
"enchantment.harmonicench.sacrificing_curse": "Curse of Sacrificing (WIP)",

‎src/main/resources/assets/harmonicench/lang/zh_cn.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"enchantment.harmonicench.luck_of_the_snow": "冰雪眷顾",
2121
"enchantment.harmonicench.mob_affinity": "亲善(未实现)",
2222
"enchantment.harmonicench.observer": "观测(未实现)",
23-
"enchantment.harmonicench.proficiency": "熟练(未实现)",
23+
"enchantment.harmonicench.proficiency": "熟练",
2424
"enchantment.harmonicench.rapier": "迅捷之刃",
2525
"enchantment.harmonicench.rebelling_curse": "叛逆诅咒",
2626
"enchantment.harmonicench.sacrificing_curse": "献祭诅咒(未实现)",

0 commit comments

Comments
 (0)
Please sign in to comment.