Skip to content

Commit

Permalink
Release v3.1
Browse files Browse the repository at this point in the history
Mod compatibility fixes.
  • Loading branch information
TheCSDev committed Oct 2, 2023
1 parent 9ffab5c commit 0602283
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions betterstats-3-fabric-1.20.1/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ org.gradle.jvmargs=-Xmx1G
mod_name = Better Statistics Screen
mod_description = Improves the statistics screen and makes it more useful.
mod_author = TheCSDev
mod_version = 3.0.0+fabric-1.20.1
mod_version = 3.1+fabric-1.20.1

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

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

pack_mcmeta_format = 15

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Predicate;

import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.ApiStatus.Internal;

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

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

//return the result list
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
public abstract @Internal class SUStat<T> extends Object
{
// ==================================================
public static final Identifier ID_NULL = new Identifier("null");
// --------------------------------------------------
protected final IStatsProvider statsProvider;
protected final Identifier statId;
protected final Text statLabel;
Expand Down
Binary file not shown.

0 comments on commit 0602283

Please sign in to comment.