Skip to content

Commit

Permalink
Fix creative inventory buttons showing without any modded item groups.
Browse files Browse the repository at this point in the history
Also, a minor code cleanup from the port.
  • Loading branch information
modmuss50 committed Nov 17, 2023
1 parent 6f7ba8f commit 7feff5d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,19 @@ public ItemGroupButtonWidget(int x, int y, Type type, CreativeGuiExtensions exte

@Override
protected void renderButton(DrawContext drawContext, int mouseX, int mouseY, float delta) {
int pageCount = (int) Math.ceil((ItemGroups.getGroupsToDisplay().size() - COMMON_GROUPS.size()) / TABS_PER_PAGE);
this.active = type.isActive(extensions.fabric_currentPage(), pageCount);
this.active = extensions.fabric_isButtonEnabled(type);
this.visible = extensions.fabric_isButtonVisible(type);

if (!this.visible) {
return;
}

int u = active && this.isHovered() ? 22 : 0;
int v = active ? 0 : 12;
drawContext.drawTexture(BUTTON_TEX, this.getX(), this.getY(), u + (type == Type.NEXT ? 11 : 0), v, 11, 12);

if (this.isHovered()) {
int pageCount = (int) Math.ceil((ItemGroups.getGroupsToDisplay().size() - COMMON_GROUPS.size()) / TABS_PER_PAGE);
drawContext.drawTooltip(MinecraftClient.getInstance().textRenderer, Text.translatable("fabric.gui.creativeTabPage", extensions.fabric_currentPage() + 1, pageCount), mouseX, mouseY);
}
}
Expand All @@ -77,13 +82,5 @@ public enum Type {
this.text = text;
this.clickConsumer = clickConsumer;
}

private boolean isActive(int currentPage, int pageCount) {
if (this == NEXT) {
return currentPage < pageCount -1;
}

return currentPage > 0;
}
}
}
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx2560M
org.gradle.parallel=true
fabric.loom.multiProjectOptimisation=true

version=0.90.9
version=0.90.10
minecraft_version=23w46a
yarn_version=+build.1
loader_version=0.14.23
Expand All @@ -24,15 +24,15 @@ fabric-commands-v0-version=0.2.56
fabric-containers-v0-version=0.1.77
fabric-content-registries-v0-version=5.0.8
fabric-crash-report-info-v1-version=0.2.21
fabric-data-generation-api-v1-version=13.1.11
fabric-data-generation-api-v1-version=13.1.12
fabric-dimensions-v1-version=2.1.59
fabric-entity-events-v1-version=1.5.26
fabric-events-interaction-v0-version=0.6.13
fabric-events-lifecycle-v0-version=0.2.70
fabric-game-rule-api-v1-version=1.0.44
fabric-gametest-api-v1-version=1.2.18
fabric-item-api-v1-version=2.1.33
fabric-item-group-api-v1-version=4.0.18
fabric-item-group-api-v1-version=4.0.19
fabric-key-binding-api-v1-version=1.0.39
fabric-keybindings-v0-version=0.2.37
fabric-lifecycle-events-v1-version=2.2.28
Expand Down

0 comments on commit 7feff5d

Please sign in to comment.