diff --git a/fabric-item-group-api-v1/src/client/java/net/fabricmc/fabric/mixin/itemgroup/client/CreativeInventoryScreenMixin.java b/fabric-item-group-api-v1/src/client/java/net/fabricmc/fabric/mixin/itemgroup/client/CreativeInventoryScreenMixin.java index d2b5ae035..13d01e935 100644 --- a/fabric-item-group-api-v1/src/client/java/net/fabricmc/fabric/mixin/itemgroup/client/CreativeInventoryScreenMixin.java +++ b/fabric-item-group-api-v1/src/client/java/net/fabricmc/fabric/mixin/itemgroup/client/CreativeInventoryScreenMixin.java @@ -20,6 +20,7 @@ import java.util.Comparator; 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; @@ -108,6 +109,19 @@ public abstract class CreativeInventoryScreenMixin extends HandledScreen<Creativ } } + @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);