Fix off-by-one error in item group tooltip ()

This commit is contained in:
Florens Pauwels 2022-04-10 17:27:18 +02:00 committed by GitHub
parent dbb7b03f94
commit 91896a4963
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions
fabric-item-groups-v0/src
main/java/net/fabricmc/fabric/impl/item/group
testmod/java/net/fabricmc/fabric/test/item/group

View file

@ -68,7 +68,8 @@ public class FabricCreativeGuiComponents {
this.drawTexture(matrixStack, this.x, this.y, u + (type == Type.NEXT ? 11 : 0), v, 11, 10);
if (this.hovered) {
gui.renderTooltip(matrixStack, new TranslatableText("fabric.gui.creativeTabPage", extensions.fabric_currentPage() + 1, ((ItemGroup.GROUPS.length - 12) / 9) + 2), mouseX, mouseY);
int pageCount = (int) Math.ceil((ItemGroup.GROUPS.length - COMMON_GROUPS.size()) / 9D);
gui.renderTooltip(matrixStack, new TranslatableText("fabric.gui.creativeTabPage", extensions.fabric_currentPage() + 1, pageCount), mouseX, mouseY);
}
}
}

View file

@ -51,5 +51,11 @@ public class ItemGroupTest implements ModInitializer {
@Override
public void onInitialize() {
TEST_ITEM = Registry.register(Registry.ITEM, new Identifier("fabric-item-groups-v0-testmod", "item_test_group"), new Item(new Item.Settings().group(ITEM_GROUP_2)));
// Exactly two pages of item groups
for (int i = 3; i < 10; i++) {
Item iconItem = Registry.ITEM.get(i);
FabricItemGroupBuilder.build(new Identifier("fabric-item-groups-v0-testmod", "test_group_" + i), () -> new ItemStack(iconItem));
}
}
}