Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--- before/net/minecraft/client/gui/GuiListExtended.java
+++ after/net/minecraft/client/gui/GuiListExtended.java
@@ -59,7 +59,7 @@

if (i >= 0)
{
- int j = this.left + this.width / 2 - this.getListWidth() / 2 + 2;
+ int j = this.getListEntryLeft();
int k = this.top + 4 - this.getAmountScrolled() + i * this.slotHeight + this.headerPadding;
int l = mouseX - j;
int i1 = mouseY - k;
@@ -79,7 +79,7 @@
{
for (int i = 0; i < this.getSize(); i++)
{
- int j = this.left + this.width / 2 - this.getListWidth() / 2 + 2;
+ int j = this.getListEntryLeft();
int k = this.top + 4 - this.getAmountScrolled() + i * this.slotHeight + this.headerPadding;
int l = x - j;
int i1 = y - k;
111 changes: 108 additions & 3 deletions patches/minecraft/net/minecraft/client/gui/GuiSlot.java.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
--- before/net/minecraft/client/gui/GuiSlot.java
+++ after/net/minecraft/client/gui/GuiSlot.java
@@ -186,27 +186,8 @@
@@ -110,8 +110,8 @@

public int getSlotIndexFromScreenCoords(int posX, int posY)
{
- int i = this.left + this.width / 2 - this.getListWidth() / 2;
- int j = this.left + this.width / 2 + this.getListWidth() / 2;
+ int i = this.getListLeft();
+ int j = this.getListRight();
int k = posY - this.top - this.headerPadding + (int)this.amountScrolled - 4;
int l = k / this.slotHeight;
return posX < this.getScrollBarX() && posX >= i && posX <= j && l >= 0 && k >= 0 && l < this.getSize() ? l : -1;
@@ -186,28 +186,9 @@
GlStateManager.disableFog();
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferbuilder = tessellator.getBuffer();
Expand All @@ -25,12 +36,80 @@
- .color(32, 32, 32, 255)
- .endVertex();
- tessellator.draw();
- int k = this.left + this.width / 2 - this.getListWidth() / 2 + 2;
+ // Forge: background rendering moved into separate method.
+ this.drawContainerBackground(tessellator);
int k = this.left + this.width / 2 - this.getListWidth() / 2 + 2;
+ int k = this.getListEntryLeft();
int l = this.top + 4 - (int)this.amountScrolled;

@@ -491,5 +472,31 @@
if (this.hasListHeader)
@@ -229,6 +210,7 @@
GlStateManager.disableAlpha();
GlStateManager.shadeModel(7425);
GlStateManager.disableTexture2D();
+ if (this.drawTopBottomShadow(tessellator)) {
int i1 = 4;
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
bufferbuilder.pos(this.left, this.top + 4, 0.0).tex(0.0, 1.0).color(0, 0, 0, 0).endVertex();
@@ -242,12 +224,12 @@
bufferbuilder.pos(this.right, this.bottom - 4, 0.0).tex(1.0, 0.0).color(0, 0, 0, 0).endVertex();
bufferbuilder.pos(this.left, this.bottom - 4, 0.0).tex(0.0, 0.0).color(0, 0, 0, 0).endVertex();
tessellator.draw();
+ }
int j1 = this.getMaxScroll();

if (j1 > 0)
{
- int k1 = (this.bottom - this.top) * (this.bottom - this.top) / this.getContentHeight();
- k1 = MathHelper.clamp(k1, 32, this.bottom - this.top - 8);
+ int k1 = this.getScrollThumbHeight();
int l1 = (int)this.amountScrolled * (this.bottom - this.top - k1) / j1 + this.top;

if (l1 < this.top)
@@ -292,8 +274,8 @@
&& this.mouseY >= this.top
&& this.mouseY <= this.bottom)
{
- int i = (this.width - this.getListWidth()) / 2;
- int j = (this.width + this.getListWidth()) / 2;
+ int i = this.getListLeft();
+ int j = this.getListRight();
int k = this.mouseY - this.top - this.headerPadding + (int)this.amountScrolled - 4;
int l = k / this.slotHeight;

@@ -318,8 +300,8 @@

if (this.mouseY >= this.top && this.mouseY <= this.bottom)
{
- int j2 = (this.width - this.getListWidth()) / 2;
- int k2 = (this.width + this.getListWidth()) / 2;
+ int j2 = this.getListLeft();
+ int k2 = this.getListRight();
int l2 = this.mouseY - this.top - this.headerPadding + (int)this.amountScrolled - 4;
int i1 = l2 / this.slotHeight;

@@ -349,8 +331,7 @@
k1 = 1;
}

- int l1 = (int)((float)((this.bottom - this.top) * (this.bottom - this.top)) / this.getContentHeight());
- l1 = MathHelper.clamp(l1, 32, this.bottom - this.top - 8);
+ int l1 = this.getScrollThumbHeight();
this.scrollMultiplier = this.scrollMultiplier / ((float)(this.bottom - this.top - l1) / k1);
}
else
@@ -429,8 +410,8 @@

if (this.showSelectionBox && this.isSelected(j))
{
- int i1 = this.left + (this.width / 2 - this.getListWidth() / 2);
- int j1 = this.left + this.width / 2 + this.getListWidth() / 2;
+ int i1 = this.getListLeft();
+ int j1 = this.getListRight();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.disableTexture2D();
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
@@ -491,5 +472,57 @@
public int getSlotHeight()
{
return this.slotHeight;
Expand Down Expand Up @@ -60,5 +139,31 @@
+ .color(32, 32, 32, 255)
+ .endVertex();
+ tessellator.draw();
+ }
+
+ 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;
Comment on lines +144 to +167

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 了。

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,23 @@
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import net.minecraft.client.Minecraft;
@@ -631,6 +632,7 @@
@@ -71,6 +72,7 @@
}

this.setCursorPositionEnd();
+ this.setResponderEntryValue(this.id, this.text);
}
}

@@ -590,6 +592,7 @@
if (this.text.length() > length)
{
this.text = this.text.substring(0, length);
+ this.setResponderEntryValue(this.id, this.text);
}
}

@@ -631,6 +634,7 @@
}

this.isFocused = isFocusedIn;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.cleanroommc.client.modlist;

import net.minecraft.client.gui.GuiScreen;

public interface LegacyModListScreen {
GuiScreen getParent();
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import java.util.Set;

/// <h1>Experimental</h1>
///
public interface IModData {
Type getType();

Expand Down
Loading