Skip to content

Commit 0602283

Browse files
committed
Release v3.1
Mod compatibility fixes.
1 parent 9ffab5c commit 0602283

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

betterstats-3-fabric-1.20.1/gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ org.gradle.jvmargs=-Xmx1G
1616
mod_name = Better Statistics Screen
1717
mod_description = Improves the statistics screen and makes it more useful.
1818
mod_author = TheCSDev
19-
mod_version = 3.0.0+fabric-1.20.1
19+
mod_version = 3.1+fabric-1.20.1
2020

2121
mod_contact_homepage = https://github.com/TheCSMods
2222
mod_contact_sources = https://github.com/TheCSMods/mc-better-stats
@@ -38,7 +38,7 @@ org.gradle.jvmargs=-Xmx1G
3838
mod_depends_minecraft = >=1.20
3939
mod_depends_java = >=17
4040

41-
mod_jar_tcdcommons = META-INF/jarjar/tcdcommons-3.0.0+fabric-1.20.1.jar
41+
mod_jar_tcdcommons = META-INF/jarjar/tcdcommons-3.1+fabric-1.20.1.jar
4242

4343
pack_mcmeta_format = 15
4444

betterstats-3-fabric-1.20.1/src/main/java/io/github/thecsdev/betterstats/api/util/stats/SUGeneralStat.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
import java.util.Comparator;
99
import java.util.List;
1010
import java.util.Objects;
11+
import java.util.Optional;
1112
import java.util.function.Predicate;
1213

1314
import org.jetbrains.annotations.Nullable;
15+
import org.jetbrains.annotations.ApiStatus.Internal;
1416

1517
import io.github.thecsdev.betterstats.api.util.io.IStatsProvider;
1618
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
@@ -39,12 +41,19 @@ public final class SUGeneralStat extends SUStat<Identifier>
3941
// ==================================================
4042
public SUGeneralStat(IStatsProvider statsProvider, Stat<Identifier> stat)
4143
{
42-
super(statsProvider, Registries.CUSTOM_STAT.get(stat.getValue()), getGeneralStatText(stat));
44+
super(statsProvider, id(stat), getGeneralStatText(stat));
4345
this.stat = Objects.requireNonNull(stat);
4446
this.value = statsProvider.getStatValue(stat);
4547
this.valueText = fLiteral(stat.format(this.value));
4648
this.isEmpty = this.value == 0;
4749
}
50+
// --------------------------------------------------
51+
private static final @Internal Identifier id(Stat<Identifier> stat)
52+
{
53+
//not the intended way of dealing with this, but has to be done to deal with incompatibilities,
54+
//and by incompatibilities i mean mod devs. not registering their stats because... idk either
55+
return Optional.ofNullable(Registries.CUSTOM_STAT.get(stat.getValue())).orElse(ID_NULL);
56+
}
4857
// ==================================================
4958
/**
5059
* Returns the "general" {@link Stat} that corresponds with this {@link SUGeneralStat}.
@@ -88,7 +97,8 @@ public static String getGeneralStatTranslationKey(Stat<Identifier> stat)
8897
statsList.sort(Comparator.comparing(stat -> translatable(getGeneralStatTranslationKey(stat)).getString()));
8998

9099
for(final var stat : statsList) result.add(new SUGeneralStat(statsProvider, stat));
91-
if(filter != null) result.removeIf(filter.negate());
100+
//filter out stats with NULL IDs and stats the filter filters out
101+
result.removeIf(stat -> Objects.equals(ID_NULL, stat.getStatID()) || (filter != null && !filter.test(stat)));
92102

93103
//return the result list
94104
return result;

betterstats-3-fabric-1.20.1/src/main/java/io/github/thecsdev/betterstats/api/util/stats/SUStat.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
public abstract @Internal class SUStat<T> extends Object
2525
{
2626
// ==================================================
27+
public static final Identifier ID_NULL = new Identifier("null");
28+
// --------------------------------------------------
2729
protected final IStatsProvider statsProvider;
2830
protected final Identifier statId;
2931
protected final Text statLabel;

0 commit comments

Comments
 (0)