mirror of
https://github.com/FabricMC/fabric.git
synced 2024-11-14 19:25:23 -05:00
Sort item groups to ensure they are in a deterministic order between runs. (#3222)
This commit is contained in:
parent
e3d1b5f3d8
commit
23d91081b6
1 changed files with 7 additions and 1 deletions
|
@ -31,6 +31,7 @@ import static net.minecraft.item.ItemGroups.SEARCH;
|
|||
import static net.minecraft.item.ItemGroups.SPAWN_EGGS;
|
||||
import static net.minecraft.item.ItemGroups.TOOLS;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -58,7 +59,12 @@ public class ItemGroupsMixin {
|
|||
|
||||
int count = 0;
|
||||
|
||||
for (RegistryKey<ItemGroup> registryKey : Registries.ITEM_GROUP.getKeys()) {
|
||||
// Sort the item groups to ensure they are in a deterministic order.
|
||||
final List<RegistryKey<ItemGroup>> sortedItemGroups = Registries.ITEM_GROUP.getKeys().stream()
|
||||
.sorted(Comparator.comparing(RegistryKey::getValue))
|
||||
.toList();
|
||||
|
||||
for (RegistryKey<ItemGroup> registryKey : sortedItemGroups) {
|
||||
final ItemGroup itemGroup = Registries.ITEM_GROUP.getOrThrow(registryKey);
|
||||
final FabricItemGroup fabricItemGroup = (FabricItemGroup) itemGroup;
|
||||
|
||||
|
|
Loading…
Reference in a new issue