Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skill Icon/Description + onSkillMastered #20

Merged
merged 3 commits into from
Dec 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ forgeVersion=43.2.6
# Parchment Version
parchmentVersion=2022.11.27
# Mod Information see https://mcforge.readthedocs.io/en/1.18.x/gettingstarted/versioning/#examples
modVersion=2.1.0.5
modVersion=2.1.0.6
modId=manascore
# Mixin Extras
mixinExtrasVersion=0.2.0-beta.10
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,25 @@ public MutableComponent getName() {
return Component.translatable(String.format("%s.skill.%s", id.getNamespace(), id.getPath().replace('/', '.')));
}

/**
* Used to get the {@link ResourceLocation} of this skill's icon texture.
*/
@Nullable
public ResourceLocation getSkillIcon() {
ResourceLocation id = this.getRegistryName();
if (id == null) return null;
return new ResourceLocation(id.getNamespace(), "icons/skills/" + id.getPath());
}

/**
* Used to get the {@link MutableComponent} description of this skill for translation.
*/
public Component getSkillDescription() {
ResourceLocation id = this.getRegistryName();
if (id == null) return Component.empty();
return Component.translatable(String.format("%s.skill.%s.description", id.getNamespace(), id.getPath().replace('/', '.')));
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand Down Expand Up @@ -135,6 +154,7 @@ public boolean isMastered(ManasSkillInstance instance, LivingEntity entity) {
public void addMasteryPoint(ManasSkillInstance instance, LivingEntity entity) {
if (isMastered(instance, entity)) return;
instance.setMastery(instance.getMastery() + 1);
if (isMastered(instance, entity)) onSkillMastered(instance, entity);
}

/**
Expand Down Expand Up @@ -213,6 +233,15 @@ public void onScroll(ManasSkillInstance instance, LivingEntity living, double de
public void onLearnSkill(ManasSkillInstance instance, LivingEntity living, UnlockSkillEvent event) {
}

/**
* Called when the {@link LivingEntity} masters this skill.
*
* @param instance Affected {@link ManasSkillInstance}
* @param living Affected {@link LivingEntity} owning this Skill.
*/
public void onSkillMastered(ManasSkillInstance instance, LivingEntity living) {
}

/**
* Called when the {@link LivingEntity} owning this Skill right-clicks a block.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,15 @@ public void onLearnSkill(LivingEntity living, UnlockSkillEvent event) {
this.getSkill().onLearnSkill(this, living, event);
}

/**
* Called when the {@link LivingEntity} masters this instance.
*
* @param living Affected {@link LivingEntity} owning this Skill.
*/
public void onSkillMastered(LivingEntity living) {
this.getSkill().onSkillMastered(this, living);
}

/**
* Called when the {@link LivingEntity} owning this Skill right-clicks a block.
*
Expand Down