Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Expand Up @@ -212,9 +212,13 @@ protected void renderBg(GuiGraphics guiGraphics, float delta, int mouseX, int mo
private void renderConfigurableSlotBackgrounds(GuiGraphics guiGraphics) {
for (Slot slot : this.menu.slots) {
if (slot instanceof BackgroundRenderedSlot brs) {
var atlas = brs.getBackgroundAtlasLocation();
if (atlas == null) {
continue;
}
int px = leftPos + slot.x - 1;
int py = topPos + slot.y - 1;
guiGraphics.blit(SLOT_ATLAS, px, py, brs.getBackgroundU(), brs.getBackgroundV(), 18, 18);
guiGraphics.blit(atlas, px, py, brs.getBackgroundU(), brs.getBackgroundV(), 18, 18);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,22 @@
*/
package aztech.modern_industrialization.inventory;

import aztech.modern_industrialization.MI;
import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.Nullable;

/**
* Implement this on a slot to render its background automatically.
*/
public interface BackgroundRenderedSlot {
/**
* @return the {@link ResourceLocation} of the slot atlas texture to use for the slot background. Return null to render no background.
*/
@Nullable
default ResourceLocation getBackgroundAtlasLocation() {
return MI.id("textures/gui/container/slot_atlas.png");
}

default int getBackgroundU() {
return 0;
}
Expand Down
Loading