Skip to content

Commit

Permalink
v3.9 dev. progress
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCSDev committed Feb 14, 2024
1 parent 895314b commit 2711a05
Show file tree
Hide file tree
Showing 21 changed files with 102 additions and 57 deletions.
2 changes: 1 addition & 1 deletion betterstats-3-fabric-1.20.1/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins
{
id 'fabric-loom' version '1.0-SNAPSHOT'
id 'fabric-loom' version '1.5-SNAPSHOT'
id 'maven-publish'
}

Expand Down
2 changes: 1 addition & 1 deletion 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.8.1+fabric-1.20.1
mod_version = 3.9+fabric-1.20.1

mod_contact_homepage = https://github.com/TheCSMods
mod_contact_sources = https://github.com/TheCSMods/mc-better-stats
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import static io.github.thecsdev.tcdcommons.api.util.TextUtils.literal;
import static io.github.thecsdev.tcdcommons.api.util.TextUtils.translatable;

import java.util.Objects;

import org.jetbrains.annotations.Nullable;

import io.github.thecsdev.betterstats.BetterStats;
Expand All @@ -17,6 +19,7 @@
import net.minecraft.client.gui.tooltip.Tooltip;
import net.minecraft.entity.EntityType;
import net.minecraft.registry.Registries;
import net.minecraft.stat.StatType;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
Expand Down Expand Up @@ -49,17 +52,22 @@ public MobStatWidget(int x, int y, int size, SUMobStat stat) throws NullPointerE
.append("\n§r");

//iterate all registered stat types, to append their values to the tooltip text
for(final var st : Registries.STAT_TYPE)
for(final var statType : Registries.STAT_TYPE)
{
//ignore all registry types except ENTITY_TYPE; also ignore the two vanilla stat types
if(st.getRegistry() != Registries.ENTITY_TYPE) continue;
if(statType.getRegistry() != Registries.ENTITY_TYPE) continue;

//obtain the text formatter for this stat type
final @Nullable var textFormatter = BSRegistries.ENTITY_STAT_TEXT_FORMATTER.get(st);
if(textFormatter == null) continue; //unfortunate, but it's the only way...

//append the stat value to the final Tooltip text
ttt.append("\n§e-§r ").append(textFormatter.apply(stat));
final @Nullable var textFormatter = BSRegistries.ENTITY_STAT_TEXT_FORMATTER.get(statType);
if(textFormatter != null) ttt.append("\n§e-§r ").append(textFormatter.apply(stat));
else
{
@SuppressWarnings("unchecked")
final var stVal = stat.getStatsProvider().getStatValue(
(StatType<EntityType<?>>)statType, stat.getEntityType());
final var stIdStr = Objects.toString(Registries.STAT_TYPE.getId(statType));
ttt.append("\n§e-§r ").append(stIdStr + " : " + stVal);
}
}
setTooltip(this.defaultTooltip = Tooltip.of(ttt));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import static io.github.thecsdev.tcdcommons.api.util.TextUtils.translatable;

import blue.endless.jankson.annotation.Nullable;
import org.jetbrains.annotations.Nullable;

import io.github.thecsdev.betterstats.BetterStats;
import io.github.thecsdev.betterstats.BetterStatsConfig;
import io.github.thecsdev.betterstats.api.client.gui.util.StatsTabUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public final @Internal class FoodStuffsStatsTab extends ItemStatsTab
{
// ==================================================
public final @Override Text getName() { return translatable("advancements.husbandry.balanced_diet.title"); }
public final @Override Text getName() { return translatable("itemGroup.foodAndDrink"); }
// --------------------------------------------------
protected final @Override Map<Text, List<SUItemStat>> getStatsDefault(
IStatsProvider stats,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,22 @@
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.stream.Collectors;

import org.jetbrains.annotations.ApiStatus.Internal;

import io.github.thecsdev.betterstats.api.client.gui.stats.widget.MobStatWidget;
import io.github.thecsdev.betterstats.api.client.gui.util.StatsTabUtils;
import io.github.thecsdev.betterstats.api.client.util.StatFilterSettings;
import io.github.thecsdev.betterstats.api.util.enumerations.FilterGroupBy;
import io.github.thecsdev.betterstats.api.util.enumerations.FilterSortMobsBy;
import io.github.thecsdev.betterstats.api.util.stats.SUMobStat;
import io.github.thecsdev.betterstats.client.gui.screen.hud.BetterStatsHudScreen;
import io.github.thecsdev.betterstats.client.gui.screen.hud.entry.StatsHudMobEntry;
import io.github.thecsdev.tcdcommons.api.client.gui.panel.TPanelElement;
import io.github.thecsdev.tcdcommons.api.util.annotations.Virtual;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.text.Text;

public @Internal @Virtual class MobStatsTab extends BSStatsTab<SUMobStat>
Expand Down Expand Up @@ -82,6 +85,13 @@
StatsTabUtils.initGroupByFilter(initContext);
StatsTabUtils.initSortMobsByFilter(initContext);
}

protected @Virtual @Override Predicate<SUMobStat> getPredicate(StatFilterSettings filterSettings)
{
//super predicate, and, hide misc entities unless they aren't empty
return super.getPredicate(filterSettings)
.and(stat -> stat.getEntityType().getSpawnGroup() != SpawnGroup.MISC || !stat.isEmpty());
}
// ==================================================
protected @Virtual void processWidget(MobStatWidget widget)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@
import io.github.thecsdev.betterstats.api.util.stats.SUMobStat;
import io.github.thecsdev.tcdcommons.api.client.gui.panel.TPanelElement;
import io.github.thecsdev.tcdcommons.api.util.annotations.Virtual;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.text.Text;

public final @Internal class MonstersHuntedStatsTab extends MobStatsTab
{
// ==================================================
public final @Override Text getName() { return translatable("advancements.adventure.kill_all_mobs.title"); }
public final @Override Text getName() { return translatable("soundCategory.hostile"); }
// --------------------------------------------------
protected final @Override void processWidget(MobStatWidget widget)
{
Expand All @@ -33,10 +32,7 @@
{
final String sq = filterSettings.getPropertyOrDefault(StatsTabUtils.FILTER_ID_SEARCH, "");
final Predicate<SUMobStat> sqPred = stat -> stat.matchesSearchQuery(sq);
return sqPred.and(stat ->
stat.getEntityType().getSpawnGroup() == SpawnGroup.MONSTER &&
stat.getEntityType() != EntityType.GIANT &&
stat.getEntityType() != EntityType.ILLUSIONER);
return sqPred.and(stat -> stat.getEntityType().getSpawnGroup() == SpawnGroup.MONSTER);
}
// ==================================================
}
2 changes: 1 addition & 1 deletion betterstats-3-fabric-1.20.2/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins
{
id 'fabric-loom' version '1.0-SNAPSHOT'
id 'fabric-loom' version '1.5-SNAPSHOT'
id 'maven-publish'
}

Expand Down
2 changes: 1 addition & 1 deletion betterstats-3-fabric-1.20.2/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.8.1+fabric-1.20.2
mod_version = 3.9+fabric-1.20.2

mod_contact_homepage = https://github.com/TheCSMods
mod_contact_sources = https://github.com/TheCSMods/mc-better-stats
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import static io.github.thecsdev.tcdcommons.api.util.TextUtils.literal;

import java.util.Objects;

import org.jetbrains.annotations.Nullable;

import io.github.thecsdev.betterstats.BetterStats;
Expand All @@ -17,6 +19,7 @@
import net.minecraft.client.gui.tooltip.Tooltip;
import net.minecraft.entity.EntityType;
import net.minecraft.registry.Registries;
import net.minecraft.stat.StatType;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
Expand Down Expand Up @@ -49,17 +52,22 @@ public MobStatWidget(int x, int y, int size, SUMobStat stat) throws NullPointerE
.append("\n§r");

//iterate all registered stat types, to append their values to the tooltip text
for(final var st : Registries.STAT_TYPE)
for(final var statType : Registries.STAT_TYPE)
{
//ignore all registry types except ENTITY_TYPE; also ignore the two vanilla stat types
if(st.getRegistry() != Registries.ENTITY_TYPE) continue;
if(statType.getRegistry() != Registries.ENTITY_TYPE) continue;

//obtain the text formatter for this stat type
final @Nullable var textFormatter = BSRegistries.ENTITY_STAT_TEXT_FORMATTER.get(st);
if(textFormatter == null) continue; //unfortunate, but it's the only way...

//append the stat value to the final Tooltip text
ttt.append("\n§e-§r ").append(textFormatter.apply(stat));
final @Nullable var textFormatter = BSRegistries.ENTITY_STAT_TEXT_FORMATTER.get(statType);
if(textFormatter != null) ttt.append("\n§e-§r ").append(textFormatter.apply(stat));
else
{
@SuppressWarnings("unchecked")
final var stVal = stat.getStatsProvider().getStatValue(
(StatType<EntityType<?>>)statType, stat.getEntityType());
final var stIdStr = Objects.toString(Registries.STAT_TYPE.getId(statType));
ttt.append("\n§e-§r ").append(stIdStr + " : " + stVal);
}
}
setTooltip(this.defaultTooltip = Tooltip.of(ttt));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import static io.github.thecsdev.tcdcommons.api.util.TextUtils.translatable;

import blue.endless.jankson.annotation.Nullable;
import org.jetbrains.annotations.Nullable;

import io.github.thecsdev.betterstats.BetterStats;
import io.github.thecsdev.betterstats.BetterStatsConfig;
import io.github.thecsdev.betterstats.api.client.gui.util.StatsTabUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public final @Internal class FoodStuffsStatsTab extends ItemStatsTab
{
// ==================================================
public final @Override Text getName() { return translatable("advancements.husbandry.balanced_diet.title"); }
public final @Override Text getName() { return translatable("itemGroup.foodAndDrink"); }
// --------------------------------------------------
protected final @Override Map<Text, List<SUItemStat>> getStatsDefault(
IStatsProvider stats,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,22 @@
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.stream.Collectors;

import org.jetbrains.annotations.ApiStatus.Internal;

import io.github.thecsdev.betterstats.api.client.gui.stats.widget.MobStatWidget;
import io.github.thecsdev.betterstats.api.client.gui.util.StatsTabUtils;
import io.github.thecsdev.betterstats.api.client.util.StatFilterSettings;
import io.github.thecsdev.betterstats.api.util.enumerations.FilterGroupBy;
import io.github.thecsdev.betterstats.api.util.enumerations.FilterSortMobsBy;
import io.github.thecsdev.betterstats.api.util.stats.SUMobStat;
import io.github.thecsdev.betterstats.client.gui.screen.hud.BetterStatsHudScreen;
import io.github.thecsdev.betterstats.client.gui.screen.hud.entry.StatsHudMobEntry;
import io.github.thecsdev.tcdcommons.api.client.gui.panel.TPanelElement;
import io.github.thecsdev.tcdcommons.api.util.annotations.Virtual;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.text.Text;

public @Internal @Virtual class MobStatsTab extends BSStatsTab<SUMobStat>
Expand Down Expand Up @@ -82,6 +85,13 @@
StatsTabUtils.initGroupByFilter(initContext);
StatsTabUtils.initSortMobsByFilter(initContext);
}

protected @Virtual @Override Predicate<SUMobStat> getPredicate(StatFilterSettings filterSettings)
{
//super predicate, and, hide misc entities unless they aren't empty
return super.getPredicate(filterSettings)
.and(stat -> stat.getEntityType().getSpawnGroup() != SpawnGroup.MISC || !stat.isEmpty());
}
// ==================================================
protected @Virtual void processWidget(MobStatWidget widget)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@
import io.github.thecsdev.betterstats.api.util.stats.SUMobStat;
import io.github.thecsdev.tcdcommons.api.client.gui.panel.TPanelElement;
import io.github.thecsdev.tcdcommons.api.util.annotations.Virtual;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.text.Text;

public final @Internal class MonstersHuntedStatsTab extends MobStatsTab
{
// ==================================================
public final @Override Text getName() { return translatable("advancements.adventure.kill_all_mobs.title"); }
public final @Override Text getName() { return translatable("soundCategory.hostile"); }
// --------------------------------------------------
protected final @Override void processWidget(MobStatWidget widget)
{
Expand All @@ -33,10 +32,7 @@
{
final String sq = filterSettings.getPropertyOrDefault(StatsTabUtils.FILTER_ID_SEARCH, "");
final Predicate<SUMobStat> sqPred = stat -> stat.matchesSearchQuery(sq);
return sqPred.and(stat ->
stat.getEntityType().getSpawnGroup() == SpawnGroup.MONSTER &&
stat.getEntityType() != EntityType.GIANT &&
stat.getEntityType() != EntityType.ILLUSIONER);
return sqPred.and(stat -> stat.getEntityType().getSpawnGroup() == SpawnGroup.MONSTER);
}
// ==================================================
}
2 changes: 1 addition & 1 deletion betterstats-3-fabric-1.20.4/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins
{
id 'fabric-loom' version '1.0-SNAPSHOT'
id 'fabric-loom' version '1.5-SNAPSHOT'
id 'maven-publish'
}

Expand Down
14 changes: 7 additions & 7 deletions betterstats-3-fabric-1.20.4/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.2
loader_version=0.15.1
yarn_mappings=1.20.4+build.3
loader_version=0.15.6

# Mod Properties
# the maven group
Expand All @@ -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.8.1+fabric-1.20.4
mod_version = 3.9+fabric-1.20.4

mod_contact_homepage = https://github.com/TheCSMods
mod_contact_sources = https://github.com/TheCSMods/mc-better-stats
Expand Down Expand Up @@ -46,7 +46,7 @@ org.gradle.jvmargs=-Xmx1G
# If you choose to use any of the following mods as dependencies,
# uncomment them in build.gradle, and don't forget to list them
# as dependencies in fabric.mod.json
fabric_version=0.91.2+1.20.4
modmenu_version=9.0.0-pre.1
architectury_version=11.0.7
rei_version=14.0.687
fabric_version=0.96.1+1.20.4
modmenu_version=9.0.0
architectury_version=11.0.12
rei_version=14.0.688
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import static io.github.thecsdev.tcdcommons.api.util.TextUtils.literal;

import java.util.Objects;

import org.jetbrains.annotations.Nullable;

import io.github.thecsdev.betterstats.BetterStats;
Expand All @@ -17,6 +19,7 @@
import net.minecraft.client.gui.tooltip.Tooltip;
import net.minecraft.entity.EntityType;
import net.minecraft.registry.Registries;
import net.minecraft.stat.StatType;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
Expand Down Expand Up @@ -49,17 +52,22 @@ public MobStatWidget(int x, int y, int size, SUMobStat stat) throws NullPointerE
.append("\n§r");

//iterate all registered stat types, to append their values to the tooltip text
for(final var st : Registries.STAT_TYPE)
for(final var statType : Registries.STAT_TYPE)
{
//ignore all registry types except ENTITY_TYPE; also ignore the two vanilla stat types
if(st.getRegistry() != Registries.ENTITY_TYPE) continue;
if(statType.getRegistry() != Registries.ENTITY_TYPE) continue;

//obtain the text formatter for this stat type
final @Nullable var textFormatter = BSRegistries.ENTITY_STAT_TEXT_FORMATTER.get(st);
if(textFormatter == null) continue; //unfortunate, but it's the only way...

//append the stat value to the final Tooltip text
ttt.append("\n§e-§r ").append(textFormatter.apply(stat));
final @Nullable var textFormatter = BSRegistries.ENTITY_STAT_TEXT_FORMATTER.get(statType);
if(textFormatter != null) ttt.append("\n§e-§r ").append(textFormatter.apply(stat));
else
{
@SuppressWarnings("unchecked")
final var stVal = stat.getStatsProvider().getStatValue(
(StatType<EntityType<?>>)statType, stat.getEntityType());
final var stIdStr = Objects.toString(Registries.STAT_TYPE.getId(statType));
ttt.append("\n§e-§r ").append(stIdStr + " : " + stVal);
}
}
setTooltip(this.defaultTooltip = Tooltip.of(ttt));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import static io.github.thecsdev.tcdcommons.api.util.TextUtils.translatable;

import blue.endless.jankson.annotation.Nullable;
import org.jetbrains.annotations.Nullable;

import io.github.thecsdev.betterstats.BetterStats;
import io.github.thecsdev.betterstats.BetterStatsConfig;
import io.github.thecsdev.betterstats.api.client.gui.util.StatsTabUtils;
Expand Down
Loading

0 comments on commit 2711a05

Please sign in to comment.