Skip to content

Commit

Permalink
Release v2.10+fabric-1.20.1
Browse files Browse the repository at this point in the history
Finished porting. Code can be improved and organized a bit more, but overall, it's all good.
  • Loading branch information
TheCSDev committed Jun 18, 2023
1 parent 573ed77 commit 0caefdf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 19 deletions.
4 changes: 2 additions & 2 deletions betterstats-2-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 = 2.10-beta.1+1.20.1
mod_version = 2.10+1.20.1

mod_contact_homepage = https://github.com/TheCSMods
mod_contact_sources = https://github.com/TheCSMods/mc-better-stats
Expand All @@ -41,7 +41,7 @@ org.gradle.jvmargs=-Xmx1G

mod_jar_fabricapi = META-INF/jarjar/fabric-api-0.83.1+1.20.1.jar
mod_jar_architectury = META-INF/jarjar/architectury-9.0.8-fabric.jar
mod_jar_tcdcommons = META-INF/jarjar/tcdcommons-2.10-beta.1+1.20.1.jar
mod_jar_tcdcommons = META-INF/jarjar/tcdcommons-2.10+1.20.1.jar

# Dependencies
# If you choose to use any of the following mods as dependencies,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ public static void init() {/*calls static*/}
//^ why so long to expire? because of HTTP rate limits for remote badges
//^ (statistics caches do get updated when requesting new stats tho)

//clear stat cache when leaving a world (mandatory)
ClientPlayerEvent.CLIENT_PLAYER_QUIT.register(clientPlayer -> ProfileCache.invalidateAll());

//init network
initNetworkReceivers();
}
Expand All @@ -91,11 +88,13 @@ private static void initNetworkReceivers()
//by default, do not respond to S2C_REQ_PREFS
enableBSSProtocol = false;
serverHasBSS = false;
ClientPlayerEvent.CLIENT_PLAYER_QUIT.register((cp) ->
ClientPlayerEvent.CLIENT_PLAYER_QUIT.register((cp) -> //when the client player leaves a world...
{
//...reset the state of everything
enableBSSProtocol = false;
serverHasBSS = false;
InGameHud_Screens.remove(HUD_ID); //TODO - temporary bug fix for switching worlds/servers
InGameHud_Screens.remove(HUD_ID);
ProfileCache.invalidateAll();
});
//handle S2C_REQ_PREFS
NetworkManager.registerReceiver(Side.S2C, S2C_I_HAVE_BSS, (payload, context) -> serverHasBSS = true);
Expand Down Expand Up @@ -164,17 +163,6 @@ private static boolean onReceivedBSNetworkProfile(BSNetworkProfile receivedProfi
if(receivedProfile == null) return false;

//obtain profile info
/*var pDisplayName = profile.getProfileDisplayName();
var existingProfile = ProfileCache.getIfPresent(pDisplayName);
//var notifyCurrentScreen = (existingProfile == null) || profile.isLocalClient();
//cache...
if(existingProfile != null)
//if one exists, just add the updated stats on top of it
existingProfile.putAllStats(profile);
else
//but if one doesn't exist, then put this new one in place
ProfileCache.put(pDisplayName, (existingProfile = profile));*/
final var cachedProfile = handleCachingAndMerging(receivedProfile);

//...and notify
Expand All @@ -201,7 +189,7 @@ public static boolean c2s_sendPrefs()

//create prefs. packet
var data = new PacketByteBuf(Unpooled.buffer());
data.writeBoolean(enableBSSProtocol && BetterStatsHudScreen.getInstance() != null); //boolean - statsHudAccuracyMode
data.writeBoolean(BetterStatsHudScreen.getInstance() != null); //boolean - statsHudAccuracyMode
var packet = new CustomPayloadC2SPacket(C2S_PREFS, data);
//send packet
try { MinecraftClient.getInstance().getNetworkHandler().sendPacket(packet); }
Expand Down
Binary file not shown.

0 comments on commit 0caefdf

Please sign in to comment.