Skip to content

Commit

Permalink
Use page up/down to change creative inventory pages. (#4416)
Browse files Browse the repository at this point in the history
* Use page up/down to change creative inventory pages.

* Swap keys
  • Loading branch information
modmuss50 authored Feb 9, 2025
1 parent 44a0820 commit fcb9601
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.List;
import java.util.Objects;

import org.lwjgl.glfw.GLFW;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
Expand Down Expand Up @@ -108,6 +109,19 @@ private void renderTabIcon(DrawContext drawContext, ItemGroup itemGroup, Callbac
}
}

@Inject(method = "keyPressed", at = @At("HEAD"), cancellable = true)
private void keyPressed(int keyCode, int scanCode, int modifiers, CallbackInfoReturnable<Boolean> cir) {
if (keyCode == GLFW.GLFW_KEY_PAGE_UP) {
if (switchToPreviousPage()) {
cir.setReturnValue(true);
}
} else if (keyCode == GLFW.GLFW_KEY_PAGE_DOWN) {
if (switchToNextPage()) {
cir.setReturnValue(true);
}
}
}

@Unique
private boolean isGroupVisible(ItemGroup itemGroup) {
return itemGroup.shouldDisplay() && currentPage == getPage(itemGroup);
Expand Down

0 comments on commit fcb9601

Please sign in to comment.