Skip to content

Commit

Permalink
Revert "Update 204.6.5 to 1.20.6"
Browse files Browse the repository at this point in the history
This reverts commit 3aecc6b.
  • Loading branch information
mrbuilder1961 committed May 28, 2024
1 parent 3aecc6b commit 9d3af20
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 47 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ jobs:
strategy:
matrix:
java: [
21 # Latest Java LTS & minimum supported by Minecraft
17 # Current Java LTS & minimum supported by Minecraft
#,21 # Latest Java LTS
]
# and run on the latest dists of Linux, MacOs, and Windows
os: [ubuntu-latest, windows-latest, macos-latest]
Expand Down Expand Up @@ -54,4 +55,4 @@ jobs:
path: |
build/libs/
build/devlibs/
!build/devlibs/*-sources.jar
!build/devlibs/*-sources.jar
7 changes: 3 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ processResources {
}

tasks.withType(JavaCompile).configureEach {
it.options.release = 21
it.options.release = 17
}

java {
withSourcesJar()

sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

jar {
Expand All @@ -97,7 +97,6 @@ jar {
publishing {
publications {
mavenJava(MavenPublication) {
artifactId = project.archives_base_name
from components.java
}
}
Expand Down
10 changes: 1 addition & 9 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
# Changelog

## Chat Patches `206.6.5` for Minecraft 1.20.5, 1.20.6 on Fabric, Quilt
- Actually updated to Java 21 and Gradle 8.7
- Fixed copy menu rendering behind other chat elements
- Otherwise identical to `204.6.5`
- **Dev notes:**
- Switched some references from `Text.Serialization` to `TextCodecs.CODEC` due to weird new registry stuff
- Minecraft made adding messages into the chat use a more modular system, however this makes future unified jar plans more difficult

## Chat Patches `204.6.5` for Minecraft 1.20.4 on Fabric, Quilt
- Fixed certain messages from showing up blank and logging `ArrayIndexOutOfBoundsException`s ([#156](https://www.github.com/mrbuilder1961/ChatPatches/issues/146))
- Fixed normal duplicate messages not having a counter (1.20.4 only, [#157](https://www.github.com/mrbuilder1961/ChatPatches/issues/157))
Expand Down Expand Up @@ -256,4 +248,4 @@ This update officially fixes [#4](https://www.github.com/mrbuilder1961/ChatPatch
## (TEMPLATE) Chat Patches `{version}` for Minecraft {targets} on {loaders}
- Changes go here

Typically as a list but not required!
Typically as a list but not required!
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ org.gradle.parallel=true
# Mod properties
archives_base_name=chatpatches
group=obro1961.chatpatches
version=206.6.5
version=204.6.5
cfId=560042
mrId=MOqt4Z5n

# Required dependencies - https://fabricmc.net/develop
minecraft=1.20.6
yarn=+build.1
minecraft=1.20.4
yarn=+build.3
loader=0.15.11
api=0.98.0+1.20.6
api=0.97.0+1.20.4

# Dependencies - modmenu: https://modrinth.com/mod/modmenu/versions?l=fabric and yacl: https://modrinth.com/mod/yacl/versions?l=fabric
modmenu=10.0.0-beta.1
yacl=3.4.2+1.20.5
modmenu=9.0.0
yacl=3.4.2+1.20.4

# Publishing metadata - phase can be ALPHA, BETA, or STABLE
targets=1.20.5,1.20.6
targets=1.20.4
loaders=Fabric,Quilt
phase=STABLE
# relations
Expand Down
7 changes: 2 additions & 5 deletions src/main/java/obro1961/chatpatches/chatlog/ChatLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
import com.google.gson.InstanceCreator;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonSerializer;
import com.mojang.serialization.JsonOps;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.hud.MessageIndicator;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.text.Text;
import net.minecraft.text.TextCodecs;
import obro1961.chatpatches.ChatPatches;
import obro1961.chatpatches.config.Config;
import obro1961.chatpatches.util.Flags;
Expand All @@ -24,7 +22,6 @@
import java.nio.file.StandardOpenOption;
import java.util.List;

import static obro1961.chatpatches.ChatPatches.LOGGER;
import static obro1961.chatpatches.ChatPatches.config;

/**
Expand All @@ -35,8 +32,8 @@ public class ChatLog {
public static final MessageIndicator RESTORED_TEXT = new MessageIndicator(0x382fb5, null, null, I18n.translate("text.chatpatches.restored"));

private static final Gson GSON = new com.google.gson.GsonBuilder()
.registerTypeAdapter(Text.class, (JsonSerializer<Text>) (src, type, context) -> TextCodecs.CODEC.encodeStart(JsonOps.INSTANCE, src).resultOrPartial(LOGGER::error).orElseThrow())
.registerTypeAdapter(Text.class, (JsonDeserializer<Text>) (json, type, context) -> TextCodecs.CODEC.parse(JsonOps.INSTANCE, json).resultOrPartial(LOGGER::error).orElseThrow())
.registerTypeAdapter(Text.class, (JsonSerializer<Text>) (src, type, context) -> Text.Serialization.toJsonTree(src))
.registerTypeAdapter(Text.class, (JsonDeserializer<Text>) (json, type, context) -> Text.Serialization.fromJsonTree(json))
.registerTypeAdapter(Text.class, (InstanceCreator<Text>) type -> Text.empty())
.create();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public abstract class MessageHandlerMixin {
@Inject(method = "onChatMessage", at = @At("HEAD"))
private void cacheChatData(SignedMessage message, GameProfile sender, MessageType.Parameters params, CallbackInfo ci) {
// only logs the metadata if it was a player-sent message (otherwise tries to format some commands like /msg and /me)
if( params.type().value().chat().translationKey().equals("chat.type.text") )
if( params.type().chat().translationKey().equals("chat.type.text") )
ChatPatches.msgData = new ChatUtils.MessageData(sender, Date.from(message.getTimestamp()), true);
else
ChatPatches.msgData = ChatUtils.NIL_MSG_DATA;
Expand Down
19 changes: 11 additions & 8 deletions src/main/java/obro1961/chatpatches/mixin/gui/ChatHudMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import com.llamalad7.mixinextras.sugar.Local;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.hud.ChatHud;
import net.minecraft.client.gui.hud.ChatHudLine;
import net.minecraft.client.gui.hud.MessageIndicator;
import net.minecraft.client.util.CommandHistoryManager;
import net.minecraft.text.Text;
import net.minecraft.util.math.MathHelper;
Expand All @@ -17,6 +19,7 @@
import obro1961.chatpatches.config.Config;
import obro1961.chatpatches.util.ChatUtils;
import obro1961.chatpatches.util.Flags;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand Down Expand Up @@ -84,7 +87,7 @@ private void clear(boolean clearHistory, CallbackInfo ci) {
}

@ModifyExpressionValue(
method = {"addMessage(Lnet/minecraft/client/gui/hud/ChatHudLine;)V", "addVisibleMessage"},
method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;ILnet/minecraft/client/gui/hud/MessageIndicator;Z)V",
at = @At(value = "CONSTANT", args = "intValue=100")
)
private int moreMessages(int hundred) {
Expand Down Expand Up @@ -131,12 +134,12 @@ private double moveINDHoverText(double e) {
* implementation specifications.
*/
@ModifyVariable(
method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;Lnet/minecraft/client/gui/hud/MessageIndicator;)V",
method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;ILnet/minecraft/client/gui/hud/MessageIndicator;Z)V",
at = @At("HEAD"),
argsOnly = true
)
private Text modifyMessage(Text m) {
return addCounter(ChatUtils.modifyMessage(m, false), false);
private Text modifyMessage(Text m, @Local(argsOnly = true) boolean refreshing) {
return addCounter(ChatUtils.modifyMessage(m, refreshing), refreshing);
}

@Inject(method = "addToMessageHistory", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/collection/ArrayListDeque;size()I"))
Expand All @@ -152,8 +155,8 @@ private boolean disableCommandLog(CommandHistoryManager manager, String message)
}

@Inject(method = "logChatMessage", at = @At("HEAD"), cancellable = true)
private void ignoreRestoredMessages(ChatHudLine hudLine, CallbackInfo ci) {
if( Flags.LOADING_CHATLOG.isRaised() && hudLine.indicator() != null )
private void ignoreRestoredMessages(Text message, @Nullable MessageIndicator indicator, CallbackInfo ci) {
if( Flags.LOADING_CHATLOG.isRaised() && indicator != null )
ci.cancel();
}

Expand All @@ -175,14 +178,14 @@ private void ignoreRestoredMessages(ChatHudLine hudLine, CallbackInfo ci) {
* <li>If a message was the same, call {@link ChatUtils#tryCondenseMessage(Text, int)},
* which ultimately removes that message and its visibles.</li>
* </ol>
* <li>Return the (potentially) condensed message, to later be formatted further in {@link #modifyMessage(Text)}</li>
* <li>Return the (potentially) condensed message, to later be formatted further in {@link #modifyMessage(Text, boolean)}</li>
* </ol>
* (Wraps the entire method in a try-catch to prevent any errors accidentally disabling the chat.)
*
* @apiNote This injector is pretty ugly and could definitely be cleaner and more concise, but I'm going to deal with it
* in the future when I API-ify the rest of the mod. When that happens, this flag-add-flag-cancel method will be replaced
* with a simple (enormous) method call alongside
* {@link #modifyMessage(Text)} in a @{@link ModifyVariable}
* {@link #modifyMessage(Text, boolean)} in a @{@link ModifyVariable}
* handler. (NOTE: as of v202.6.0, this is partially done already thanks to #132)
*/
@Unique
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.mojang.serialization.JsonOps;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.loader.api.FabricLoader;
Expand All @@ -23,11 +22,12 @@
import net.minecraft.client.util.ChatMessages;
import net.minecraft.client.util.SkinTextures;
import net.minecraft.network.message.MessageSignatureData;
import net.minecraft.text.*;
import net.minecraft.text.HoverEvent;
import net.minecraft.text.OrderedText;
import net.minecraft.text.Style;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.JsonHelper;
import net.minecraft.util.math.MathHelper;
import obro1961.chatpatches.ChatPatches;
import obro1961.chatpatches.accessor.ChatHudAccessor;
import obro1961.chatpatches.accessor.ChatScreenAccessor;
import obro1961.chatpatches.config.ChatSearchSetting;
Expand Down Expand Up @@ -177,8 +177,7 @@ protected void initSearchStuff(CallbackInfo ci) {
// hover menu buttons, column two
hoverButtons.put(COPY_RAW_STRING, of(1, COPY_RAW_STRING, () -> Formatting.strip( selectedLine.content().getString() )));
hoverButtons.put(COPY_FORMATTED_STRING, of(1, COPY_FORMATTED_STRING, () -> TextUtils.reorder( selectedLine.content().asOrderedText(), true )));
hoverButtons.put(COPY_JSON_STRING, of(1, COPY_JSON_STRING,
() -> TextCodecs.CODEC.encodeStart(JsonOps.INSTANCE, selectedLine.content()).map(JsonHelper::toSortedString).resultOrPartial(ChatPatches.LOGGER::error).get()));
hoverButtons.put(COPY_JSON_STRING, of(1, COPY_JSON_STRING, () -> Text.Serialization.toJsonString(selectedLine.content())));
hoverButtons.put(COPY_LINK_N.apply(0), of(1, COPY_LINK_N.apply(0), () -> ""));
hoverButtons.put(COPY_TIMESTAMP_TEXT, of(1, COPY_TIMESTAMP_TEXT, () -> getPart(selectedLine.content(), TIMESTAMP_INDEX).getString()));
hoverButtons.put(COPY_TIMESTAMP_HOVER_TEXT, of(1, COPY_TIMESTAMP_HOVER_TEXT, () -> {
Expand Down Expand Up @@ -243,7 +242,7 @@ protected void initSearchStuff(CallbackInfo ci) {
* </ol>
* </ol>
*/
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/math/MatrixStack;pop()V"))
@Inject(method = "render", at = @At("HEAD"))
public void renderSearchStuff(DrawContext drawContext, int mX, int mY, float delta, CallbackInfo ci) {
if(showSearch && !config.hideSearchButton) {
drawContext.fill(SEARCH_X - 2, height + SEARCH_Y_OFFSET - 2, (int) (width * (SEARCH_W_MULT + 0.06)), height + SEARCH_Y_OFFSET + SEARCH_H - 2, client.options.getTextBackgroundColor(Integer.MIN_VALUE));
Expand Down Expand Up @@ -754,7 +753,7 @@ private List<ChatHudLine.Visible> filterMessages(String target) {
/**
* Creates a new list of to-be-rendered chat messages from the given list
* of chat messages. The steps to achieving this are largely based on
* the first half of the {@link ChatHud#addMessage(Text, MessageSignatureData, MessageIndicator)}
* the first half of the {@link ChatHud#addMessage(Text, MessageSignatureData, int, MessageIndicator, boolean)}
* method, specifically everything before the {@code while} loop.
*/
@Unique
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/chatpatches.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"required": true,
"minVersion": "0.8",
"package": "obro1961.chatpatches.mixin",
"compatibilityLevel": "JAVA_21",
"compatibilityLevel": "JAVA_17",
"verbose": true,
"mixinPriority": 2000,
"mixins": [],
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
],

"depends": {
"java": ">=21",
"minecraft": [ "1.20.5", "1.20.6" ],
"java": ">=17",
"minecraft": [ "1.20.3", "1.20.4" ],
"fabricloader": ">=0.15.0",
"fabric-api": "*",
"yet_another_config_lib_v3": "*"
Expand Down

0 comments on commit 9d3af20

Please sign in to comment.