Skip to content

Commit

Permalink
Fixed #13
Browse files Browse the repository at this point in the history
Also removed contributors from the README file, I dont want to update that anymore
  • Loading branch information
mrbuilder1961 committed Jun 1, 2022
1 parent 3e53ccf commit 8cc38eb
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 24 deletions.
14 changes: 0 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,5 @@ This also applies for all other options: if you toggle it off, it will probably
re-adds every chat message, which then triggers the method that initially adds these modifications. That ends up re-adding them. This is fixable,
but ends up being very tedious and it breaks on most servers. The best solution is to just clear the chat manually with F3+D or ignore it.

## Contributors to the latest version
### Developers
- MechanicalArcane (me): Made this amalgamation monstrosity of a mod
- ryanbester: Created some code for older versions of WMCH from their mod [keepcommandhistory](https://github.com/ryanbester/keepcommandhistory/blob/master/src/main/java/com/ryanbester/keepcommandhistory/mixin/MixinNewChatGui.java), for making sure F3+D works
- JackFred2: Created some code from their mod [MoreChatHistory](https://github.com/JackFred2/MoreChatHistory/blob/main/src/main/java/red/jackf/morechathistory/mixins/MixinChatHud.java), for increasing the max number of chat messages cached

### Suggestors and Bug Reporters
- KOMPuteRSH4IK: Suggested a config
- LOLboy199: Reported a game-breaking bug
- jpeterik12: Reported timestamps missing a text buffer
- EGOIST1372: Suggested copying messages
- PaladinFallen: Reported chat mixin error
- Ovbi-UwU: Reported `[SYSTEM]` messages and incorrect name formatting

## License
This mod is available under the GNU GPLv3 license. TL;DR: You can do whatever, as long as it's free, open-source, and credits me and the other authors.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17

archivesBaseName = 'wmch'
version = '1.4.6'
version = '1.4.6.1'
group = 'obro1961.wmch'
project.ext.set('minecraft_version', '1.18.2')
project.ext.set('loader_version', '0.13.3')
Expand Down
1 change: 0 additions & 1 deletion src/main/java/obro1961/wmch/WMCH.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* TODO List (highest priority is top):
* - highlighted and copyable important messages or smart messages (not configurable, ex. port from LAN screen)
*!- duplicate counter (xN, ex. x3) [NOT WORKING, BORROW FROM OTHER MOD]
* - regex +normal search functionality (ChatHudMixin) (based on Vazkii's ChatFlow mod)
*
* Planning:
Expand Down
21 changes: 14 additions & 7 deletions src/main/java/obro1961/wmch/mixins/ChatHudMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static net.minecraft.text.HoverEvent.Action.SHOW_ENTITY;
import static net.minecraft.text.HoverEvent.Action.SHOW_TEXT;

import java.util.Collections;
import java.util.Date;
import java.util.Deque;
import java.util.List;
Expand Down Expand Up @@ -146,7 +147,7 @@ private void grabText(double x,double y,CallbackInfoReturnable<Style> ci,double

/** Decides which messages need dupe counters and which don't */
@Inject(method = "addMessage(Lnet/minecraft/text/Text;IIZ)V", at = @At("HEAD"), cancellable = true)
public void injectCounter(Text m, int time, int id, boolean rfrs, CallbackInfo ci) {
public void injectCounter(Text m, int id, int tick, boolean rfrs, CallbackInfo ci) {
//* index 0 is the message before this one (current message hasnt been added yet)
if( Option.COUNTER.get() && !m.getString().equals( Util.delAll(Option.BOUNDARYSTR.get(), "(?:&[0-9a-fA-Fk-orK-OR])+") ) && messages.size() > 0 ) {
ChatHudLine<Text> last = messages.get(0);
Expand All @@ -165,19 +166,25 @@ public void injectCounter(Text m, int time, int id, boolean rfrs, CallbackInfo c
: sibs.get(1).getString().equals(lSibs.get(1).getString())
) {
++dupes;
// adds the updated counter and timestamp
// modifies the message to have a counter and timestamp
if(lSibs.size() > 2) last.getText().getSiblings().set(2, WMCH.config.getDupeF(dupes));
else last.getText().getSiblings().add(2, WMCH.config.getDupeF(dupes));
if(lSibs.get(0).getString().length() > 0) last.getText().getSiblings().set(0, sibs.get(0));
// modifies the message to have a counter
messages.set(0, new ChatHudLine<Text>(last.getCreationTick(), last.getText(), last.getId()));

if(messages.size() > 0) visibleMessages.remove(0);
net.minecraft.client.util.ChatMessages.breakRenderedChatMessageLines(
// modifies the actual message to have a counter
if(messages.size() > 0) messages.remove(0);
messages.add(0, new ChatHudLine<Text>(tick, last.getText(), id));

// modifies the rendered messages to have a counter
List<OrderedText> visibles = net.minecraft.client.util.ChatMessages.breakRenderedChatMessageLines(
last.getText(),
net.minecraft.util.math.MathHelper.floor((double)ChatHud.getWidth(client.options.chatWidth) / client.options.chatScale),
client.textRenderer
).forEach(vt -> visibleMessages.add(0, new ChatHudLine<>(last.getCreationTick(), vt, last.getId())));
); Collections.reverse(visibles);

for(OrderedText text : visibles)
visibleMessages.set( visibles.indexOf(text), new ChatHudLine<>(tick, text, id) );


ci.cancel(); //? might screw up logs or something, maybe add a warning that says a message was removed for duping
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"schemaVersion": 1,
"id": "wmch",
"version": "1.4.6",
"version": "1.4.6.1",

"name": "Where's My Chat History",
"description": "A versatile client-side chat mod that can do many things, just check out the config and the GitHub page for more info!",
Expand Down

0 comments on commit 8cc38eb

Please sign in to comment.