This commit is contained in:
+1
-1
@@ -10,7 +10,7 @@ loom_version=1.16.1
|
|||||||
fabric_api_version=0.141.3+1.21.11
|
fabric_api_version=0.141.3+1.21.11
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version=0.4.1
|
mod_version=0.5.0
|
||||||
maven_group=com.g2806.soulsteal
|
maven_group=com.g2806.soulsteal
|
||||||
archives_base_name=soul-steal
|
archives_base_name=soul-steal
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.g2806.soulsteal.data.SoulStealDataStore;
|
|||||||
import com.g2806.soulsteal.data.StoredBounty;
|
import com.g2806.soulsteal.data.StoredBounty;
|
||||||
import com.g2806.soulsteal.service.ContractService;
|
import com.g2806.soulsteal.service.ContractService;
|
||||||
import com.g2806.soulsteal.util.DurationFormatter;
|
import com.g2806.soulsteal.util.DurationFormatter;
|
||||||
|
import com.g2806.soulsteal.util.HudTexts;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.UncheckedIOException;
|
import java.io.UncheckedIOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -16,10 +17,10 @@ import java.util.Map;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import net.minecraft.entity.boss.BossBar;
|
import net.minecraft.entity.boss.BossBar;
|
||||||
import net.minecraft.entity.boss.ServerBossBar;
|
import net.minecraft.entity.boss.ServerBossBar;
|
||||||
import net.minecraft.network.packet.s2c.play.ScoreboardDisplayS2CPacket;
|
import net.minecraft.network.packet.s2c.play.ScoreboardDisplayS2CPacket;
|
||||||
import net.minecraft.network.packet.s2c.play.ScoreboardObjectiveUpdateS2CPacket;
|
import net.minecraft.network.packet.s2c.play.ScoreboardObjectiveUpdateS2CPacket;
|
||||||
import net.minecraft.network.packet.s2c.play.ScoreboardScoreResetS2CPacket;
|
import net.minecraft.network.packet.s2c.play.ScoreboardScoreResetS2CPacket;
|
||||||
@@ -31,6 +32,7 @@ import net.minecraft.scoreboard.ScoreboardObjective;
|
|||||||
import net.minecraft.scoreboard.number.BlankNumberFormat;
|
import net.minecraft.scoreboard.number.BlankNumberFormat;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
|
import net.minecraft.text.MutableText;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.Formatting;
|
import net.minecraft.util.Formatting;
|
||||||
|
|
||||||
@@ -232,8 +234,17 @@ public final class HudService {
|
|||||||
BossBar.Color.RED,
|
BossBar.Color.RED,
|
||||||
BossBar.Style.PROGRESS
|
BossBar.Style.PROGRESS
|
||||||
));
|
));
|
||||||
bossBar.setName(Text.literal(configSupplier.get().hud().bountyBossbar().title() + ": " + totalValue + " souls | " + DurationFormatter.formatSeconds(remainingSeconds)));
|
MutableText bossbarText = HudTexts.title(configSupplier.get().hud().bountyBossbar().title())
|
||||||
bossBar.setPercent(percent);
|
.append(Text.literal(" "))
|
||||||
|
.append(HudTexts.value(String.valueOf(totalValue), Formatting.GOLD))
|
||||||
|
.append(Text.literal(" "))
|
||||||
|
.append(HudTexts.value("souls", Formatting.GRAY))
|
||||||
|
.append(Text.literal(" "))
|
||||||
|
.append(HudTexts.value("•", Formatting.DARK_GRAY))
|
||||||
|
.append(Text.literal(" "))
|
||||||
|
.append(HudTexts.value(DurationFormatter.formatSeconds(remainingSeconds), Formatting.RED));
|
||||||
|
bossBar.setName(bossbarText);
|
||||||
|
bossBar.setPercent(percent);
|
||||||
bossBar.setVisible(true);
|
bossBar.setVisible(true);
|
||||||
if (!bossBar.getPlayers().contains(player)) {
|
if (!bossBar.getPlayers().contains(player)) {
|
||||||
bossBar.addPlayer(player);
|
bossBar.addPlayer(player);
|
||||||
@@ -243,12 +254,12 @@ public final class HudService {
|
|||||||
private List<Text> buildSidebarLines(ServerPlayerEntity player, long nowEpochMillis) {
|
private List<Text> buildSidebarLines(ServerPlayerEntity player, long nowEpochMillis) {
|
||||||
List<StoredBounty> activeBounties = bountyService.activeBountiesForTarget(player.getUuid());
|
List<StoredBounty> activeBounties = bountyService.activeBountiesForTarget(player.getUuid());
|
||||||
List<Text> lines = new ArrayList<>();
|
List<Text> lines = new ArrayList<>();
|
||||||
lines.add(Text.literal("Souls: " + soulService.balanceOf(player.getUuid())).formatted(Formatting.GOLD));
|
lines.add(HudTexts.labeledValue("Souls", String.valueOf(soulService.balanceOf(player.getUuid())), Formatting.GOLD));
|
||||||
|
|
||||||
contractService.selectedContract(player.getUuid()).ifPresent(contract -> {
|
contractService.selectedContract(player.getUuid()).ifPresent(contract -> {
|
||||||
long progress = contractService.progress(player.getUuid(), contract.id());
|
long progress = contractService.progress(player.getUuid(), contract.id());
|
||||||
lines.add(Text.literal("Contract: " + contract.name()).formatted(Formatting.AQUA));
|
lines.add(HudTexts.labeledValue("Contract", contract.name(), Formatting.WHITE));
|
||||||
lines.add(Text.literal("Progress: " + progress + "/" + contract.amountRequired()).formatted(Formatting.GRAY));
|
lines.add(HudTexts.labeledValue("Progress", progress + "/" + contract.amountRequired(), Formatting.GRAY));
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!activeBounties.isEmpty()) {
|
if (!activeBounties.isEmpty()) {
|
||||||
@@ -259,9 +270,9 @@ public final class HudService {
|
|||||||
.orElse(nowEpochMillis);
|
.orElse(nowEpochMillis);
|
||||||
remainingSeconds = Math.max(0L, (remainingSeconds - nowEpochMillis + 999L) / 1000L);
|
remainingSeconds = Math.max(0L, (remainingSeconds - nowEpochMillis + 999L) / 1000L);
|
||||||
|
|
||||||
lines.add(Text.literal("Bounties: " + activeBounties.size()).formatted(Formatting.RED));
|
lines.add(HudTexts.labeledValue("Bounties", String.valueOf(activeBounties.size()), Formatting.RED));
|
||||||
lines.add(Text.literal("Wanted Value: " + totalValue).formatted(Formatting.GOLD));
|
lines.add(HudTexts.labeledValue("Wanted", String.valueOf(totalValue), Formatting.GOLD));
|
||||||
lines.add(Text.literal("Wanted Time: " + DurationFormatter.formatSeconds(remainingSeconds)).formatted(Formatting.DARK_RED));
|
lines.add(HudTexts.labeledValue("Time Left", DurationFormatter.formatSeconds(remainingSeconds), Formatting.DARK_RED));
|
||||||
}
|
}
|
||||||
|
|
||||||
return lines;
|
return lines;
|
||||||
@@ -294,7 +305,7 @@ public final class HudService {
|
|||||||
return scoreboard.addObjective(
|
return scoreboard.addObjective(
|
||||||
objectiveName,
|
objectiveName,
|
||||||
ScoreboardCriterion.DUMMY,
|
ScoreboardCriterion.DUMMY,
|
||||||
Text.literal(configSupplier.get().hud().scoreboard().title()).formatted(Formatting.DARK_AQUA),
|
HudTexts.title(configSupplier.get().hud().scoreboard().title()),
|
||||||
ScoreboardCriterion.RenderType.INTEGER,
|
ScoreboardCriterion.RenderType.INTEGER,
|
||||||
false,
|
false,
|
||||||
BlankNumberFormat.INSTANCE
|
BlankNumberFormat.INSTANCE
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package com.g2806.soulsteal.util;
|
||||||
|
|
||||||
|
import net.minecraft.text.MutableText;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
import net.minecraft.util.Formatting;
|
||||||
|
|
||||||
|
/** Text helpers for sidebar, bossbar, and other compact HUD surfaces. */
|
||||||
|
public final class HudTexts {
|
||||||
|
private HudTexts() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MutableText title(String text) {
|
||||||
|
return Text.literal(text).formatted(Formatting.DARK_AQUA, Formatting.BOLD);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MutableText label(String text) {
|
||||||
|
return Text.literal(text).formatted(Formatting.AQUA, Formatting.BOLD);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MutableText value(String text, Formatting formatting) {
|
||||||
|
return Text.literal(text).formatted(formatting);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MutableText labeledValue(String label, String value, Formatting valueFormatting) {
|
||||||
|
return label(label).append(Text.literal(" ")).append(value(value, valueFormatting));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MutableText separator() {
|
||||||
|
return Text.literal(" ").formatted(Formatting.GRAY);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user