Skip to content

Fix mod list - #592

Merged
Rongmario merged 8 commits into
CleanroomMC:mainfrom
RuiXuqi:mod-list-fix
Jul 29, 2026
Merged

Fix mod list#592
Rongmario merged 8 commits into
CleanroomMC:mainfrom
RuiXuqi:mod-list-fix

Conversation

@RuiXuqi

@RuiXuqi RuiXuqi commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

This PR solves several issues caused by the refactor in #589.

  • Fix cursed layout by implementing original @Override methods in patches.
  • Fix mod list's config not available in Cleanroom dev cleanroomClient and not synced in production.
  • Fix case issues in mod searching.
  • Add back selective entry rendering to improve performance.

Comment on lines +144 to +167
+ protected boolean drawTopBottomShadow(Tessellator tessellator)
+ {
+ return true;
+ }
+
+ protected int getScrollThumbHeight()
+ {
+ int viewHeight = this.bottom - this.top;
+ return MathHelper.clamp(viewHeight * viewHeight / this.getContentHeight(), 32, viewHeight - 8);
+ }
+
+ protected int getListLeft()
+ {
+ return this.left + this.width / 2 - this.getListWidth() / 2;
+ }
+
+ protected int getListRight()
+ {
+ return this.left + this.width / 2 + this.getListWidth() / 2;
+ }
+
+ protected int getListEntryLeft()
+ {
+ return this.getListLeft() + 2;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

一定要在patches加那麼多方法?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

一定要在patches加那麼多方法?

原版是固定卡位置在中间的,不 patch 没法控制 layout,就会像当前这样左边空出来一点,很丑。

Override 也是可以的,但是你在 refactor 的时候把这些删了,就不考虑了。

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

每個用GuiSlot的不會突然出錯嗎?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GuiTextField也是

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

每個用GuiSlot的不會突然出錯嗎?

这里的计算方法是和原版一致的,除非真的有人 mixin 这个特定的赋值,不然一般不会出错。

@RuiXuqi RuiXuqi Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GuiTextField也是

这个确实可以考虑继续写在 Override,看你了。

我觉得可以当作原版的 Bug 处理,在更新一点的 MC 版本这几个地方都补上 callback 了。

this.parentScreen = parent;
if (!loaded) {
PlatformUtils.getAllModData().forEach(data -> CACHED_MODS.put(data.getModId(), new ModData(data)));
PlatformUtils.getAllModData().forEach(data -> CACHED_MODS.put(data.getModId().toLowerCase(Locale.ENGLISH), new ModData(data)));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ModContainer#getModId 只能回小寫的英文字母

@RuiXuqi RuiXuqi Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ModContainer#getModId 只能回小寫的英文字母

对于 FML 这样的自定义 ModContainer 不成立。

Comment on lines +92 to +94
// Forge's mod list may get mixin in late phase, which leads to crash
// Use an interface to avoid this
if (ModListConfig.enable && gui instanceof LegacyModListScreen modList)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你有在這裡崩潰過?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你有在這裡崩潰過?

https://github.com/KameiB/Localizator/blob/ddb812cbf6d77da42626252e85bead4a89d04b46/src/main/java/kameib/localizator/mixin/forge/GuiModListMixin.java#L15

破坏 late mixin 不划算,做一个 interface 也不是很 hack,也比反射好,我认为是可以接受的。

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GNNLGB 又是這

Comment on lines +106 to +108
if (ModListConstants.OWNER_MOD_ID.equals(event.getModID()))
{
ConfigManager.sync(ModListConfig.class);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

這跟寫在ForgeModContainer有啥差別?

@RuiXuqi RuiXuqi Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

這跟寫在ForgeModContainer有啥差別?

ForgeModContainer 不会调用这个 sync 事件,导致游戏内修改不会同步到文件里。开发和生产都会出这个问题。

public static boolean hasConfigForMod(String modid)
{
return asm_data.containsKey(modid);
return asm_data.containsKey(modid) || MOD_CONFIG_CLASSES.containsKey(modid);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

???

@RuiXuqi RuiXuqi Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

???

Fix mod list's config not available in Cleanroom runClient and not synced in production.

Cleanroom 开发环境 asm_data 有问题,丢 key,运行 cleanroomClient 可以看到模组列表里 Cleanroom 的配置按钮是灰色的。

@Rongmario
Rongmario merged commit 2e756de into CleanroomMC:main Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants