fix creative menu off-by-one crash

This commit is contained in:
Adrian Siekierka 2019-04-07 14:51:42 +02:00
parent 31db2b6d1b
commit 5f3245b0fd

View file

@ -68,7 +68,7 @@ public abstract class MixinCreativePlayerInventoryGui extends AbstractPlayerInve
@Override @Override
public void fabric_nextPage() { public void fabric_nextPage() {
if (fabric_getPageOffset(fabric_currentPage + 1) > ItemGroup.GROUPS.length) { if (fabric_getPageOffset(fabric_currentPage + 1) >= ItemGroup.GROUPS.length) {
return; return;
} }
fabric_currentPage++; fabric_currentPage++;
@ -86,13 +86,13 @@ public abstract class MixinCreativePlayerInventoryGui extends AbstractPlayerInve
@Override @Override
public boolean fabric_isButtonVisible(FabricCreativeGuiComponents.Type type) { public boolean fabric_isButtonVisible(FabricCreativeGuiComponents.Type type) {
return ItemGroup.GROUPS.length != 12; return ItemGroup.GROUPS.length > 12;
} }
@Override @Override
public boolean fabric_isButtonEnabled(FabricCreativeGuiComponents.Type type) { public boolean fabric_isButtonEnabled(FabricCreativeGuiComponents.Type type) {
if (type == FabricCreativeGuiComponents.Type.NEXT) { if (type == FabricCreativeGuiComponents.Type.NEXT) {
return !(fabric_getPageOffset(fabric_currentPage + 1) > ItemGroup.GROUPS.length); return !(fabric_getPageOffset(fabric_currentPage + 1) >= ItemGroup.GROUPS.length);
} }
if (type == FabricCreativeGuiComponents.Type.PREVIOUS) { if (type == FabricCreativeGuiComponents.Type.PREVIOUS) {
return fabric_currentPage != 0; return fabric_currentPage != 0;