Skip to content

Commit

Permalink
Tweak and log #141 fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbuilder1961 committed Dec 29, 2023
1 parent ecfca67 commit 85b743b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
3 changes: 2 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

## Chat Patches `204.6.2` for Minecraft 1.20.4 on Fabric
- Fixed log spam with `UnsupportedOperationException`s when loading the chat log ([thanks ArkoSammy12!](https://discord.com/channels/1077285607375638529/1077297192659861686/1187217543010717747))
- Fixed the chat log crashing the game when saving a message that opens a file when clicked (##138)
- Fixed the chat log crashing the game when saving a message that opens a file when clicked ([#138](https://www.github.com/mrbuilder1961/ChatPatches/issues/138))
- Note: these two only apply to Minecraft versions 1.20.3 and above
- Merged [#141](https://www.github.com/mrbuilder1961/ChatPatches/pull/141) (thanks [SmajloSlovakian](https://github.com/SmajloSlovakian)!)

## Chat Patches `204.6.1` for Minecraft 1.20.4 on Fabric
- Ported v203.6.0 to 1.20.4
Expand Down
28 changes: 18 additions & 10 deletions src/main/java/obro1961/chatpatches/mixin/gui/ChatHudMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,23 +102,31 @@ private int moreWidth(int defaultWidth) {
return config.chatWidth > 0 ? config.chatWidth : defaultWidth;
}


/**
* These methods shift the entire chat hud by
* {@link Config#shiftChat}, including the text, scroll
* bar, hover text and indicator bar
* by shifting the y position of the chat.
* 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 = 7)
private int moveEntireChat(int y) {
return y - MathHelper.floor(config.shiftChat / this.getChatScale());
@ModifyVariable(method = "render", at = @At("STORE"), ordinal = 7)
private int moveEntireChat(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 Expand Up @@ -314,4 +322,4 @@ private Text addCounter(Text incoming, boolean refreshing) {

return incoming;
}
}
}

0 comments on commit 85b743b

Please sign in to comment.