Skip to content

Commit 3f65e15

Browse files
committed
Fix Rendering Gui, Bump to 2.1.0
1 parent f38b12b commit 3f65e15

File tree

3 files changed

+30
-17
lines changed

3 files changed

+30
-17
lines changed

common/src/main/java/com/periut/chisel/gui/ChiselScreen.java

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ protected void drawSlot(DrawContext context, Slot slot) {
8282
boolean bl2 = slot == ((HandledScreenAccessor)this).getTouchDragSlotStart() && !((HandledScreenAccessor)this).getTouchDragStack().isEmpty() && !((HandledScreenAccessor)this).getTouchIsRightClickDrag();
8383
ItemStack itemStack2 = this.handler.getCursorStack();
8484
String string = null;
85-
int k;
8685

8786
// Check if this is a big slot
8887
boolean isBigSlot = slot instanceof BigSlot && ((BigSlot)slot).isBigSlot();
88+
int slotSize = isBigSlot ? 32 : 16; // 2x size for big slots
8989

9090
if (slot == ((HandledScreenAccessor)this).getTouchDragSlotStart() && !((HandledScreenAccessor)this).getTouchDragStack().isEmpty() && ((HandledScreenAccessor)this).getTouchIsRightClickDrag() && !itemStack.isEmpty()) {
9191
itemStack = itemStack.copyWithCount(itemStack.getCount() / 2);
@@ -96,7 +96,7 @@ protected void drawSlot(DrawContext context, Slot slot) {
9696

9797
if (ScreenHandler.canInsertItemIntoSlot(slot, itemStack2, true) && this.handler.canInsertIntoSlot(slot)) {
9898
bl = true;
99-
k = Math.min(itemStack2.getMaxCount(), slot.getMaxItemCount(itemStack2));
99+
int k = Math.min(itemStack2.getMaxCount(), slot.getMaxItemCount(itemStack2));
100100
int l = slot.getStack().isEmpty() ? 0 : slot.getStack().getCount();
101101
int m = ScreenHandler.calculateStackSize(this.cursorDragSlots, ((HandledScreenAccessor)this).getHeldButtonType(), itemStack2) + l;
102102
if (m > k) {
@@ -115,40 +115,53 @@ protected void drawSlot(DrawContext context, Slot slot) {
115115
if (itemStack.isEmpty() && slot.isEnabled()) {
116116
Identifier identifier = slot.getBackgroundSprite();
117117
if (identifier != null) {
118-
context.drawGuiTexture(RenderPipelines.GUI_TEXTURED, identifier, i, j, 16, 16);
118+
if (isBigSlot) {
119+
// Scale the background texture for big slots
120+
context.getMatrices().pushMatrix();
121+
context.getMatrices().translate(i, j);
122+
context.getMatrices().scale(2.0f, 2.0f);
123+
context.drawGuiTexture(RenderPipelines.GUI_TEXTURED, identifier, 0, 0, 16, 16);
124+
context.getMatrices().popMatrix();
125+
} else {
126+
context.drawGuiTexture(RenderPipelines.GUI_TEXTURED, identifier, i, j, 16, 16);
127+
}
119128
bl2 = true;
120129
}
121130
}
122131

123132
if (!bl2) {
124133
if (bl) {
125-
context.fill(i, j, i + 16, j + 16, -2130706433);
134+
context.fill(i, j, i + slotSize, j + slotSize, -2130706433);
126135
}
127136

128-
k = slot.x + slot.y * this.backgroundWidth;
137+
int k = slot.x + slot.y * this.backgroundWidth;
138+
139+
if (isBigSlot) {
140+
// Render big slot item with 2x scale
141+
context.getMatrices().pushMatrix();
142+
context.getMatrices().translate(i-8, j-8);
143+
context.getMatrices().scale(2.0f, 2.0f);
129144

130-
// Handle big slots differently
131-
if (isBigSlot && !itemStack.isEmpty()) {
132-
// Draw the item at 2x size (without matrix transformations)
133145
if (slot.disablesDynamicDisplay()) {
134-
context.drawItemWithoutEntity(itemStack, i, j, k);
146+
context.drawItemWithoutEntity(itemStack, 0, 0, k);
135147
} else {
136-
context.drawItem(itemStack, i, j, k);
148+
context.drawItem(itemStack, 0, 0, k);
137149
}
138150

139-
// Hide stack overlay for slots 1-60 (only draw for slots outside this range)
151+
// Draw overlay at scaled size
140152
if (slot.id < 1 || slot.id > 60) {
141-
context.drawStackOverlay(this.textRenderer, itemStack, i, j, string);
153+
context.drawStackOverlay(this.textRenderer, itemStack, 0, 0, string);
142154
}
155+
156+
context.getMatrices().popMatrix();
143157
} else {
144-
// Normal item rendering (unchanged)
158+
// Normal rendering for regular slots
145159
if (slot.disablesDynamicDisplay()) {
146160
context.drawItemWithoutEntity(itemStack, i, j, k);
147161
} else {
148162
context.drawItem(itemStack, i, j, k);
149163
}
150164

151-
// Hide stack overlay for slots 1-60 (only draw for slots outside this range)
152165
if (slot.id < 1 || slot.id > 60) {
153166
context.drawStackOverlay(this.textRenderer, itemStack, i, j, string);
154167
}

common/src/main/java/com/periut/chisel/mixins/HandledScreenMixin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ protected HandledScreenMixin(Text title) {
3939
@Unique
4040
public final void drawSlotHighlightBackBig(DrawContext context) {
4141
if (this.focusedSlot != null && ((BigSlot)this.focusedSlot).isBigSlot()) {
42-
context.drawGuiTexture(RenderPipelines.GUI_TEXTURED, SLOT_HIGHLIGHT_BACK_TEXTURE, this.focusedSlot.x-20, this.focusedSlot.y-20, 56, 56);
42+
context.drawGuiTexture(RenderPipelines.GUI_TEXTURED, SLOT_HIGHLIGHT_BACK_TEXTURE, this.focusedSlot.x - 20, this.focusedSlot.y - 20, 56, 56);
4343
}
4444

4545
}
4646

4747
@Unique
4848
public final void drawSlotHighlightFrontBig(DrawContext context) {
4949
if (this.focusedSlot != null && ((BigSlot)this.focusedSlot).isBigSlot()) {
50-
context.drawGuiTexture(RenderPipelines.GUI_NAUSEA_OVERLAY, SLOT_HIGHLIGHT_FRONT_TEXTURE, this.focusedSlot.x - 20, this.focusedSlot.y - 20, 56, 56);
50+
context.drawGuiTexture(RenderPipelines.GUI_TEXTURED, SLOT_HIGHLIGHT_FRONT_TEXTURE, this.focusedSlot.x - 20, this.focusedSlot.y - 20, 56, 56);
5151
}
5252
}
5353

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx2048M
22

33
enabled_platforms=fabric,neoforge
44

5-
mod_version = 2.0.1
5+
mod_version = 2.1.0
66
maven_group = com.periut.chisel
77
archives_name = chisel
88

0 commit comments

Comments
 (0)