mirror of
https://github.com/FabricMC/fabric.git
synced 2024-11-14 19:25:23 -05:00
Fix common tab resetting when reopening creative screen (#2803)
This commit is contained in:
parent
4017a8cb18
commit
0a2a0d0b13
1 changed files with 10 additions and 8 deletions
|
@ -91,10 +91,12 @@ public abstract class CreativeInventoryScreenMixin<T extends ScreenHandler> exte
|
|||
}
|
||||
|
||||
private void fabric_updateSelection() {
|
||||
ItemGroupHelper.sortedGroups.stream()
|
||||
.filter(this::fabric_isGroupVisible)
|
||||
.findFirst()
|
||||
.ifPresent(this::setSelectedTab);
|
||||
if (!fabric_isGroupVisible(selectedTab)) {
|
||||
ItemGroupHelper.sortedGroups.stream()
|
||||
.filter(this::fabric_isGroupVisible)
|
||||
.findFirst()
|
||||
.ifPresent(this::setSelectedTab);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "init", at = @At("RETURN"))
|
||||
|
@ -137,14 +139,14 @@ public abstract class CreativeInventoryScreenMixin<T extends ScreenHandler> exte
|
|||
}
|
||||
|
||||
private boolean fabric_isGroupVisible(ItemGroup itemGroup) {
|
||||
if (FabricCreativeGuiComponents.COMMON_GROUPS.contains(itemGroup)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return fabric_currentPage == fabric_getPage(itemGroup);
|
||||
}
|
||||
|
||||
private static int fabric_getPage(ItemGroup itemGroup) {
|
||||
if (FabricCreativeGuiComponents.COMMON_GROUPS.contains(itemGroup)) {
|
||||
return fabric_currentPage;
|
||||
}
|
||||
|
||||
final FabricItemGroup fabricItemGroup = (FabricItemGroup) itemGroup;
|
||||
return fabricItemGroup.getPage();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue