Skip to content

Commit

Permalink
Added mc tweak keepMessageHistoryOnReconfiguration
Browse files Browse the repository at this point in the history
resolved #57, closed #58
  • Loading branch information
Fallen-Breath committed Mar 22, 2024
1 parent 10e1a93 commit c5713a3
Show file tree
Hide file tree
Showing 11 changed files with 254 additions and 0 deletions.
18 changes: 18 additions & 0 deletions docs/document-en_us.md
Original file line number Diff line number Diff line change
Expand Up @@ -1450,6 +1450,24 @@ With this option, no more need to worry about item tooltips covering too much in
- Default value: `false`


### keepMessageHistoryOnReconfiguration

Prevent the chat messages in the chat hud from being cleared when then client enters the reconfiguration network state

Proxy servers like BungeeCord and Velocity might let the client enter the reconfiguration network state

when the client is switching between different backend Minecraft servers.

With this option, you can keep your chat history with switching between different servers

- Category: MC Tweaks
- Type: boolean (Generic)
- Default value: `false`
- Mod restrictions:
- Required mods:
- Minecraft (`minecraft`) `>=1.20.2`


### legacyF3NLogic

Modify the logic of hotkey F3 + N back to 1.15 and before
Expand Down
18 changes: 18 additions & 0 deletions docs/document-zh_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -1446,6 +1446,24 @@ Format error: 修复使用原版聊天缩放设置来缩放聊天信息HUD中的
- 默认值: `false`


### 在重配置网络阶段保留消息历史 (keepMessageHistoryOnReconfiguration)

防止聊天记录在客户端进入重新配置网络状态时被清除

像BungeeCord和Velocity这样的代理服务器,可能会在客户端在不同的

后端Minecraft服务器之间切换时,让客户端进入重新配置网络状态

借助该选项,你可以在切换服务器的时候保留你的聊天信息

- 分类: MC修改
- 类型: 布尔值 (通用)
- 默认值: `false`
- 模组约束:
- 依赖模组:
- Minecraft (`minecraft`) `>=1.20.2`


### 旧版F3+N逻辑 (legacyF3NLogic)

修改快捷键F3+N的逻辑至1.15及之前的逻辑
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,9 @@ public class TweakerMoreConfigs
@Config(type = Config.Type.GENERIC, category = Config.Category.MC_TWEAKS)
public static final TweakerMoreConfigBoolean ITEM_TOOLTIP_HIDE_UNTIL_MOUSE_MOVE = newConfigBoolean("itemTooltipHideUntilMouseMove", false);

@Config(type = Config.Type.GENERIC, restriction = @Restriction(require = @Condition(value = minecraft, versionPredicates = ">=1.20.2")), category = Config.Category.MC_TWEAKS)
public static final TweakerMoreConfigBoolean KEEP_MESSAGE_HISTORY_ON_RECONFIGURATION = newConfigBoolean("keepMessageHistoryOnReconfiguration", false);

@Config(type = Config.Type.GENERIC, restriction = @Restriction(require = @Condition(value = minecraft, versionPredicates = ">=1.16")), category = Config.Category.MC_TWEAKS)
public static final TweakerMoreConfigBoolean LEGACY_F3_N_LOGIC = newConfigBoolean("legacyF3NLogic", false);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* This file is part of the TweakerMore project, licensed under the
* GNU Lesser General Public License v3.0
*
* Copyright (C) 2024 Fallen_Breath and contributors
*
* TweakerMore is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TweakerMore is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with TweakerMore. If not, see <https://www.gnu.org/licenses/>.
*/

package me.fallenbreath.tweakermore.impl.mc_tweaks.keepMessageHistoryOnReconfiguration;

public class KeepMessageHistoryOnReconfigurationHelper
{
public static final ThreadLocal<Boolean> isReconfiguring = ThreadLocal.withInitial(() -> false);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* This file is part of the TweakerMore project, licensed under the
* GNU Lesser General Public License v3.0
*
* Copyright (C) 2024 Fallen_Breath and contributors
*
* TweakerMore is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TweakerMore is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with TweakerMore. If not, see <https://www.gnu.org/licenses/>.
*/

package me.fallenbreath.tweakermore.mixins.tweaks.mc_tweaks.keepMessageHistoryOnReconfiguration;

import me.fallenbreath.tweakermore.util.mixin.DummyClass;
import org.spongepowered.asm.mixin.Mixin;

@Mixin(DummyClass.class)
public abstract class InGameHudMixin
{
// mc1.20.2+
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* This file is part of the TweakerMore project, licensed under the
* GNU Lesser General Public License v3.0
*
* Copyright (C) 2024 Fallen_Breath and contributors
*
* TweakerMore is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TweakerMore is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with TweakerMore. If not, see <https://www.gnu.org/licenses/>.
*/

package me.fallenbreath.tweakermore.mixins.tweaks.mc_tweaks.keepMessageHistoryOnReconfiguration;

import net.minecraft.client.MinecraftClient;
import org.spongepowered.asm.mixin.Mixin;

@Mixin(MinecraftClient.class)
public abstract class MinecraftClientMixin
{
}
7 changes: 7 additions & 0 deletions src/main/resources/assets/tweakermore/lang/en_us.yml
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,13 @@ tweakermore:
comment: |-
Hide item tooltips in container screens until the mouse has moved
With this option, no more need to worry about item tooltips covering too much information in container screens
keepMessageHistoryOnReconfiguration:
.: keepMessageHistoryOnReconfiguration
comment: |-
Prevent the chat messages in the chat hud from being cleared when then client enters the reconfiguration network state
Proxy servers like BungeeCord and Velocity might let the client enter the reconfiguration network state
when the client is switching between different backend Minecraft servers.
With this option, you can keep your chat history with switching between different servers
legacyF3NLogic:
.: legacyF3NLogic
comment: |-
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/assets/tweakermore/lang/zh_cn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,13 @@ tweakermore:
comment: |-
在容器GUI中隐藏物品的悬浮文本,直至鼠标移动
借此,无需再担心物品的悬浮文本遮挡过多容器GUI中的物品图标信息
keepMessageHistoryOnReconfiguration:
.: 在重配置网络阶段保留消息历史
comment: |-
防止聊天记录在客户端进入重新配置网络状态时被清除
像BungeeCord和Velocity这样的代理服务器,可能会在客户端在不同的
后端Minecraft服务器之间切换时,让客户端进入重新配置网络状态
借助该选项,你可以在切换服务器的时候保留你的聊天信息
legacyF3NLogic:
.: 旧版F3+N逻辑
comment: |-
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/tweakermore.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@
"tweaks.mc_tweaks.fixHoverTextScale.HoverTextRendererClassMixin",
"tweaks.mc_tweaks.flyDrag.LivingEntityMixin",
"tweaks.mc_tweaks.itemTooltipHideUntilMouseMove.ContainerScreenMixin",
"tweaks.mc_tweaks.keepMessageHistoryOnReconfiguration.InGameHudMixin",
"tweaks.mc_tweaks.keepMessageHistoryOnReconfiguration.MinecraftClientMixin",
"tweaks.mc_tweaks.legacyF3NLogic.KeyboardMixin",
"tweaks.mc_tweaks.maxChatHudHeight.ChatHudMixin",
"tweaks.mc_tweaks.multiplayerForcedEnabled.MinecraftClientMixin",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* This file is part of the TweakerMore project, licensed under the
* GNU Lesser General Public License v3.0
*
* Copyright (C) 2024 Fallen_Breath and contributors
*
* TweakerMore is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TweakerMore is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with TweakerMore. If not, see <https://www.gnu.org/licenses/>.
*/

package me.fallenbreath.tweakermore.mixins.tweaks.mc_tweaks.keepMessageHistoryOnReconfiguration;

import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import me.fallenbreath.tweakermore.config.TweakerMoreConfigs;
import me.fallenbreath.tweakermore.impl.mc_tweaks.keepMessageHistoryOnReconfiguration.KeepMessageHistoryOnReconfigurationHelper;
import net.minecraft.client.gui.hud.ChatHud;
import net.minecraft.client.gui.hud.InGameHud;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

@Mixin(InGameHud.class)
public abstract class InGameHudMixin
{
@SuppressWarnings("RedundantIfStatement")
@WrapWithCondition(
method = "clear",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/gui/hud/ChatHud;clear(Z)V"
)
)
private boolean keepMessageOnReconfiguration_dontClearChatHud(ChatHud instance, boolean clearHistory)
{
if (TweakerMoreConfigs.KEEP_MESSAGE_HISTORY_ON_RECONFIGURATION.getBooleanValue())
{
if (KeepMessageHistoryOnReconfigurationHelper.isReconfiguring.get())
{
return false;
}
}
return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* This file is part of the TweakerMore project, licensed under the
* GNU Lesser General Public License v3.0
*
* Copyright (C) 2024 Fallen_Breath and contributors
*
* TweakerMore is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TweakerMore is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with TweakerMore. If not, see <https://www.gnu.org/licenses/>.
*/

package me.fallenbreath.tweakermore.mixins.tweaks.mc_tweaks.keepMessageHistoryOnReconfiguration;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import me.fallenbreath.tweakermore.config.TweakerMoreConfigs;
import me.fallenbreath.tweakermore.impl.mc_tweaks.keepMessageHistoryOnReconfiguration.KeepMessageHistoryOnReconfigurationHelper;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.hud.InGameHud;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

@Mixin(MinecraftClient.class)
public abstract class MinecraftClientMixin
{
@WrapOperation(
method = "enterReconfiguration",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/gui/hud/InGameHud;clear()V"
)
)
private void keepMessageOnReconfiguration_markIsReconfiguring(InGameHud instance, Operation<Void> original)
{
boolean optionEnabled = TweakerMoreConfigs.KEEP_MESSAGE_HISTORY_ON_RECONFIGURATION.getBooleanValue();
if (optionEnabled)
{
KeepMessageHistoryOnReconfigurationHelper.isReconfiguring.set(true);
}
try
{
original.call(instance);
}
finally
{
if (optionEnabled)
{
KeepMessageHistoryOnReconfigurationHelper.isReconfiguring.remove();
}
}
}
}

0 comments on commit c5713a3

Please sign in to comment.