Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

1.20.4 Support #158

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "fabric-loom" version "1.2-SNAPSHOT"
id "maven-publish"
id 'fabric-loom' version '1.5-SNAPSHOT'
id 'maven-publish'
id "io.freefair.lombok" version "8.0.1"
}

Expand All @@ -26,7 +26,7 @@ repositories {
name = 'Ladysnake Mods'
url = 'https://maven.ladysnake.org/releases'
content {
includeGroup 'io.github.ladysnake'
includeGroup 'org.ladysnake'
includeGroupByRegex 'io\\.github\\.onyxstudios.*'
}
}
Expand All @@ -44,7 +44,7 @@ dependencies {
// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs.
// You may need to force-disable transitiveness on them.
//modImplementation "com.github.DarkKronicle:DarkKore:${project.darkkore_version}" // 1.20.1 version not yet published
modCompileOnly files("run/mods/DarkKore-0.3.5-1.20.1.jar")
modCompileOnly files("run/mods/DarkKore-0.3.5-1.20.4.jar")

modImplementation "com.terraformersmc:modmenu:${project.modmenu_version}"

Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://fabricmc.net/versions.html
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.1
loader_version=0.14.21
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.3
loader_version=0.15.6
# Mod Properties
mod_version=2.2.6
maven_group=io.github.darkkronicle
archives_base_name=KronHUD
# Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
fabric_version=0.84.0+1.20.1
fabric_version=0.96.1+1.20.4
darkkore_version=ab012735d8
modmenu_version=7.1.0
modmenu_version=9.0.0

# Uploading data
curseforge_slug=kronhud
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public HudEntry get(Identifier identifier) {
}

public void render(DrawContext context, float delta) {
if (!(client.currentScreen instanceof HudEditScreen) && !client.options.debugEnabled) {
if (!(client.currentScreen instanceof HudEditScreen) && !client.getDebugHud().shouldShowDebugHud()) {
for (HudEntry hud : getEntries()) {
if (hud.isEnabled()) {
hud.render(context, delta);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
import io.github.darkkronicle.kronhud.config.KronOptionList;
import io.github.darkkronicle.kronhud.gui.component.DynamicallyPositionable;
import io.github.darkkronicle.kronhud.gui.entry.TextHudEntry;
import io.github.darkkronicle.kronhud.gui.hud.simple.TPSHud;
import io.github.darkkronicle.kronhud.gui.layout.AnchorPoint;
import io.github.darkkronicle.kronhud.gui.layout.CardinalOrder;
import io.github.darkkronicle.kronhud.util.Rectangle;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.texture.Sprite;
import net.minecraft.entity.effect.StatusEffect;
Expand Down Expand Up @@ -106,7 +108,7 @@ private void renderPotion(DrawContext context, StatusEffectInstance effect, int
RenderSystem.setShaderColor(1, 1, 1, 1);
context.drawSprite(x, y, 0, 18, 18, sprite);
if (!iconsOnly.getValue()) {
drawString(context, client.textRenderer, StatusEffectUtil.getDurationText(effect, 1), x + 19, y + 5,
drawString(context, client.textRenderer, StatusEffectUtil.getDurationText(effect, 1, 20), x + 19, y + 5, //TODO: replace 20 with tickRate (don't know how :[)
textColor.getValue().color(), shadow.getValue()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public void renderPlaceholderComponent(DrawContext context, float delta) {
removeM.add(Text.literal("[").setStyle(Style.EMPTY.withColor(TextColor.fromRgb(ColorUtil.DARK_GRAY.color()))));
removeM.add(Text.literal("4").setStyle(Style.EMPTY.withColor(Formatting.WHITE)));
removeM.add(Text.literal("] ").setStyle(Style.EMPTY.withColor(TextColor.fromRgb(ColorUtil.DARK_GRAY.color()))));
removeM.add(new ItemStack(Items.GRASS).getName());
removeM.add(new ItemStack(Items.SHORT_GRASS).getName());
OrderedText removeText = Language.getInstance().reorder(removeM.getCombined());
if (shadow.getValue()) {
context.drawTextWithShadow(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import net.minecraft.scoreboard.*;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.Identifier;
import net.minecraft.util.Util;

Expand All @@ -30,17 +31,19 @@ public class ScoreboardHud extends TextHudEntry implements DynamicallyPositionab
Scoreboard placeScore = new Scoreboard();
ScoreboardObjective objective = placeScore.addObjective("placeholder", ScoreboardCriterion.DUMMY,
Text.literal("Scoreboard"),
ScoreboardCriterion.RenderType.INTEGER);
ScoreboardPlayerScore dark = placeScore.getPlayerScore("DarkKronicle", objective);
ScoreboardCriterion.RenderType.INTEGER,
true,
null);
ScoreAccess dark = placeScore.getOrCreateScore(ScoreHolder.fromName("DarkKronicle"), objective);
dark.setScore(8780);

ScoreboardPlayerScore moeh = placeScore.getPlayerScore("moehreag", objective);
ScoreAccess moeh = placeScore.getOrCreateScore(ScoreHolder.fromName("moehreag"), objective);
moeh.setScore(743);

ScoreboardPlayerScore kode = placeScore.getPlayerScore("TheKodeToad", objective);
ScoreAccess kode = placeScore.getOrCreateScore(ScoreHolder.fromName("TheKodeToad"), objective);
kode.setScore(2948);

placeScore.setObjectiveSlot(1, objective);
placeScore.setObjectiveSlot(ScoreboardDisplaySlot.SIDEBAR, objective);
return objective;
});

Expand All @@ -67,15 +70,16 @@ public void render(DrawContext context, float delta) {
public void renderComponent(DrawContext context, float delta) {
Scoreboard scoreboard = this.client.world.getScoreboard();
ScoreboardObjective scoreboardObjective = null;
Team team = scoreboard.getPlayerTeam(this.client.player.getEntityName());
Team team = scoreboard.getTeam(this.client.player.getNameForScoreboard());
if (team != null) {
int t = team.getColor().getColorIndex();
if (t >= 0) {
scoreboardObjective = scoreboard.getObjectiveForSlot(3 + t);
Formatting t = team.getColor();
int tc = t.getColorIndex();
if (tc >= 0) {
scoreboardObjective = scoreboard.getObjectiveForSlot(ScoreboardDisplaySlot.fromFormatting(t));
}
}

ScoreboardObjective scoreboardObjective2 = scoreboardObjective != null ? scoreboardObjective : scoreboard.getObjectiveForSlot(1);
ScoreboardObjective scoreboardObjective2 = scoreboardObjective != null ? scoreboardObjective : scoreboard.getObjectiveForSlot(ScoreboardDisplaySlot.SIDEBAR);
if (scoreboardObjective2 != null) {
this.renderScoreboardSidebar(context, scoreboardObjective2);
}
Expand All @@ -90,9 +94,9 @@ public void renderPlaceholderComponent(DrawContext context, float delta) {
// show any more information than it would have in vanilla.
private void renderScoreboardSidebar(DrawContext context, ScoreboardObjective objective) {
Scoreboard scoreboard = objective.getScoreboard();
Collection<ScoreboardPlayerScore> scores = scoreboard.getAllPlayerScores(objective);
List<ScoreboardPlayerScore> filteredScores = scores.stream().filter((testScore) ->
testScore.getPlayerName() != null && !testScore.getPlayerName().startsWith("#")
Collection<ScoreboardEntry> scores = scoreboard.getScoreboardEntries(objective);
List<ScoreboardEntry> filteredScores = scores.stream().filter((testScore) ->
testScore.owner() != null && !testScore.owner().startsWith("#")
).collect(Collectors.toList());

if (filteredScores.size() > 15) {
Expand All @@ -101,22 +105,22 @@ private void renderScoreboardSidebar(DrawContext context, ScoreboardObjective ob
scores = filteredScores;
}

List<Pair<ScoreboardPlayerScore, Text>> scoresWText = Lists.newArrayListWithCapacity(scores.size());
List<Pair<ScoreboardEntry, Text>> scoresWText = Lists.newArrayListWithCapacity(scores.size());
Text text = objective.getDisplayName();
int displayNameWidth = client.textRenderer.getWidth(text);
int maxWidth = displayNameWidth;
int spacerWidth = client.textRenderer.getWidth(": ");

ScoreboardPlayerScore scoreboardPlayerScore;
ScoreboardEntry scoreboardPlayerScore;
MutableText formattedText;
for (
Iterator<ScoreboardPlayerScore> scoresIterator = scores.iterator();
Iterator<ScoreboardEntry> scoresIterator = scores.iterator();
scoresIterator.hasNext();
maxWidth = Math.max(maxWidth, client.textRenderer.getWidth(formattedText) + spacerWidth + client.textRenderer.getWidth(Integer.toString(scoreboardPlayerScore.getScore())))
maxWidth = Math.max(maxWidth, client.textRenderer.getWidth(formattedText) + spacerWidth + client.textRenderer.getWidth(Integer.toString(scoreboardPlayerScore.value())))
) {
scoreboardPlayerScore = scoresIterator.next();
Team team = scoreboard.getPlayerTeam(scoreboardPlayerScore.getPlayerName());
formattedText = Team.decorateName(team, Text.literal(scoreboardPlayerScore.getPlayerName()));
Team team = scoreboard.getTeam(scoreboardPlayerScore.owner());
formattedText = Team.decorateName(team, Text.literal(scoreboardPlayerScore.owner()));
scoresWText.add(Pair.of(scoreboardPlayerScore, formattedText));
}
maxWidth = maxWidth + 6;
Expand Down Expand Up @@ -148,11 +152,11 @@ private void renderScoreboardSidebar(DrawContext context, ScoreboardObjective ob
int num = 0;
int textOffset = scoreX - 4;

for (Pair<ScoreboardPlayerScore, Text> scoreboardPlayerScoreTextPair : scoresWText) {
for (Pair<ScoreboardEntry, Text> scoreboardPlayerScoreTextPair : scoresWText) {
++num;
ScoreboardPlayerScore scoreboardPlayerScore2 = scoreboardPlayerScoreTextPair.getFirst();
ScoreboardEntry scoreboardPlayerScore2 = scoreboardPlayerScoreTextPair.getFirst();
Text scoreText = scoreboardPlayerScoreTextPair.getSecond();
String score = String.valueOf(scoreboardPlayerScore2.getScore());
String score = String.valueOf(scoreboardPlayerScore2.value());
int relativeY = scoreY - num * 9 + topPadding.getValue() * 2;

if (background.getValue() && backgroundColor.getValue().alpha() > 0) {
Expand Down