Skip to content

Commit

Permalink
Impl shiftChat mixin optimization +more
Browse files Browse the repository at this point in the history
fix changelog, bump versions, remove old todo
  • Loading branch information
mrbuilder1961 committed Jan 1, 2024
1 parent 5fd271c commit d115e3b
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 25 deletions.
12 changes: 7 additions & 5 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
# Changelog

## Chat Patches `202.6.2` for Minecraft 1.20.2 on Fabric
- Removed `SharedVariables` class and redistributed its one useful variable to `ChatPatches`

## Chat Patches `202.6.1` for Minecraft 1.20.2 on Fabric
### - Skipped version `202.6.1` to re-sync with the 1.20.4 version
- Remove Gradle integration system, it was completely unnecessary and unused
- Fixed messages starting with a newline not being copyable
- Switched `chatWidth`'s YACL max value to the game window's width. Note: this can be incorrect if the game window is resized after the config screen is
opened. To fix this, just open the config screen when the game window is at the desired size.
- Change source Java version to 21 and update Gradle to 8.5
- Replaced old `Instant` references with `Date` ones for consistency
- Fixed a couple issues with the [Smooth Scroll](https://modrinth.com/mod/smooth-scroll) mod thanks to [@SmajloSlovakian](https://github.com/SmajloSlovakian)!
([#139](https://www.github.com/mrbuilder1961/ChatPatches/issues/139), [#141](https://www.github.com/mrbuilder1961/ChatPatches/pull/141))
- **Dev stuff**:
- Change source Java version to 21 and update Gradle to 8.5
- Replaced old `Instant` references with `Date` ones for consistency
- Removed `SharedVariables` class and redistributed its one useful variable to `ChatPatches`

## Chat Patches `202.6.0` for Minecraft 1.20.2 on Fabric
- Removed MixinExtras from dependencies because it's automatically bundled with the Fabric Loader since `0.15.0`!
Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ org.gradle.parallel=true
# Mod properties
archives_base_name=chatpatches
group=obro1961.chatpatches
version=202.6.1
version=202.6.2

# Required dependencies
# https://fabricmc.net/develop
minecraft=1.20.2
yarn=+build.4
loader=0.15.1
api=0.91.1+1.20.2
loader=0.15.3
api=0.91.2+1.20.2

# Dependencies
# https://modrinth.com/mod/modmenu/versions?l=fabric&c=release, https://modrinth.com/mod/yacl/versions?l=fabric&c=release
modmenu=8.0.0
modmenu=8.0.1
yacl=3.3.0-beta.1+1.20.2

# User and publishing info
Expand Down
30 changes: 17 additions & 13 deletions src/main/java/obro1961/chatpatches/mixin/gui/ChatHudMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,26 +103,30 @@ private int moreWidth(int defaultWidth) {
}

/**
* These methods shift various parts of the ChatHud by
* {@link Config#shiftChat}, including the text, scroll
* bar, indicator bar, and hover text.
* They all shift the y value, with the name of the parameter
* corresponding to the (yarn mapped) target variable name.
* These methods shift most of the chat hud by
* {@link Config#shiftChat}, including the text
* and scroll bar, by shifting the y position of the chat.
*
* @implNote Target: <br>{@code int m = MathHelper.floor((float)(l - 40) / f);}
*/
@ModifyVariable(method = "render", at = @At(value = "STORE", ordinal = 0), index = 31) // STORE ordinal=0 to not target all x stores
private int moveChatText(int x) {
return x - MathHelper.floor(config.shiftChat / this.getChatScale());
}
@ModifyVariable(method = "render", at = @At(value = "STORE", ordinal = 0), index = 27)
private int moveScrollBar(int af) {
return af + MathHelper.floor(config.shiftChat / this.getChatScale());
@ModifyVariable(method = "render", at = @At("STORE"), ordinal = 7)
private int moveChat(int m) {
return m - MathHelper.floor(config.shiftChat / this.getChatScale());
}
// condensed to one method because the first part of both methods are practically identical

/**
* Moves the message indicator and hover tooltip
* by {@link Config#shiftChat} to correctly shift
* the chat with the other components.
* Targets two methods because the first part of both
* methods are identical.
*/
@ModifyVariable(method = {"getIndicatorAt", "getTextStyleAt"}, argsOnly = true, at = @At("HEAD"), ordinal = 1)
private double moveINDHoverText(double e) {
return e + ( config.shiftChat * this.getChatScale() );
}


/**
* Modifies the incoming message by adding timestamps, nicer
* player names, hover events, and duplicate counters in conjunction with
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -707,8 +707,6 @@ private void onSearchFieldUpdate(String text) {
} else if(!searchResults.isEmpty()) { // mark the text green if there are results, and only show those
searchField.setEditableColor(0x55FF55);

// todo: ensure that when this method is run, any successful matches are cached so subsequent searches only look through that list and are faster
// might alr be done, idk
ChatHudAccessor chatHud = ChatHudAccessor.from(client);
chatHud.chatpatches$getVisibleMessages().clear();
chatHud.chatpatches$getVisibleMessages().addAll(searchResults);
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"ploxxy (uk_ua, bugfixes)",
"Fiz-Victor (bugfixes)",
"co-91 (ja_jp)",
"JustALittleWolf (#118, #123, #131, #132)"
"JustALittleWolf (#118, #123, #131, #132)",
"SmajloSlovakian (#139-141)"
],
"contact": {
"homepage": "https://modrinth.com/mod/MOqt4Z5n",
Expand Down

0 comments on commit d115e3b

Please sign in to comment.