Skip to content

Commit

Permalink
feat: Add knockout stat (#127)
Browse files Browse the repository at this point in the history
* Add knockout stat

* fix lang key

* Fix language key

---------

Co-authored-by: BlayTheNinth <[email protected]>
  • Loading branch information
MelanX and BlayTheNinth authored May 24, 2024
1 parent a15775f commit 716351b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.blay09.mods.hardcorerevival.config.HardcoreRevivalConfig;
import net.blay09.mods.hardcorerevival.handler.*;
import net.blay09.mods.hardcorerevival.network.ModNetworking;
import net.blay09.mods.hardcorerevival.stats.ModStats;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import org.apache.logging.log4j.LogManager;
Expand All @@ -27,6 +28,7 @@ public static void initialize() {
HardcoreRevivalConfig.initialize();

ModNetworking.initialize(Balm.getNetworking());
ModStats.initialize(Balm.getStats());

Balm.getCommands().register(ReviveCommand::register);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.blay09.mods.hardcorerevival.mixin.ServerPlayerAccessor;
import net.blay09.mods.hardcorerevival.network.RevivalProgressMessage;
import net.blay09.mods.hardcorerevival.network.RevivalSuccessMessage;
import net.blay09.mods.hardcorerevival.stats.ModStats;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceKey;
Expand Down Expand Up @@ -49,6 +50,7 @@ public void knockout(Player player, DamageSource source) {
revivalData.setKnockedOut(true);
revivalData.setKnockoutTicksPassed(0);
revivalData.setLastKnockoutAt(System.currentTimeMillis());
player.awardStat(ModStats.knockouts);

// Punish consecutive knockouts
final var lastRescuedAt = revivalData.getLastRescuedAt();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package net.blay09.mods.hardcorerevival.stats;

import net.blay09.mods.balm.api.stats.BalmStats;
import net.blay09.mods.hardcorerevival.HardcoreRevival;
import net.minecraft.resources.ResourceLocation;

public class ModStats {

public static final ResourceLocation knockouts = new ResourceLocation(HardcoreRevival.MOD_ID, "knockouts");

public static void initialize(BalmStats stats) {
stats.registerCustomStat(knockouts);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"gui.hardcorerevival.rescuing": "Rescuing %s",
"death.attack.not_rescued_in_time": "%1$s was not rescued in time",
"death.attack.not_rescued_in_time.player": "%1$s was not rescued in time",
"stat.hardcorerevival.knockouts": "Knockouts",
"config.hardcorerevival.secondsUntilDeath": "Seconds until Death",
"config.hardcorerevival.secondsUntilDeath.tooltip": "The time in seconds in which a player can still be rescued from death. Set to 0 to disable the timer.",
"config.hardcorerevival.continueTimerWhileOffline": "Continue Timer while Offline",
Expand Down

0 comments on commit 716351b

Please sign in to comment.