Skip to content

Commit 862dd78

Browse files
committed
Allow background rendered slots to override the slot atlas texture
1 parent 993d195 commit 862dd78

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/client/java/aztech/modern_industrialization/machines/gui/MachineScreen.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,15 @@ protected void renderBg(GuiGraphics guiGraphics, float delta, int mouseX, int mo
209209

210210
private void renderConfigurableSlotBackgrounds(GuiGraphics guiGraphics) {
211211
for (Slot slot : this.menu.slots) {
212-
if (slot instanceof BackgroundRenderedSlot brs) {
212+
if (slot.isActive() && slot instanceof BackgroundRenderedSlot brs) {
213213
int px = leftPos + slot.x - 1;
214214
int py = topPos + slot.y - 1;
215-
guiGraphics.blit(SLOT_ATLAS, px, py, brs.getBackgroundU(), brs.getBackgroundV(), 18, 18);
215+
if (slot.getItem().isEmpty()) {
216+
var atlas = brs.getBackgroundAtlasLocation();
217+
guiGraphics.blit(atlas == null ? SLOT_ATLAS : atlas, px, py, brs.getBackgroundU(), brs.getBackgroundV(), 18, 18);
218+
} else {
219+
guiGraphics.blit(SLOT_ATLAS, px, py, 0, 0, 18, 18);
220+
}
216221
}
217222
}
218223
}

src/main/java/aztech/modern_industrialization/inventory/BackgroundRenderedSlot.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,21 @@
2323
*/
2424
package aztech.modern_industrialization.inventory;
2525

26+
import net.minecraft.resources.ResourceLocation;
27+
import org.jetbrains.annotations.Nullable;
28+
2629
/**
2730
* Implement this on a slot to render its background automatically.
2831
*/
2932
public interface BackgroundRenderedSlot {
33+
/**
34+
* @return the {@link ResourceLocation} of the slot atlas texture to use for the slot background. When null, uses the MI slot atlas
35+
*/
36+
@Nullable
37+
default ResourceLocation getBackgroundAtlasLocation() {
38+
return null;
39+
}
40+
3041
default int getBackgroundU() {
3142
return 0;
3243
}

0 commit comments

Comments
 (0)