mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-18 03:25:18 +00:00
Fire registry events in the order vanilla registers to registries (#8677)
Custom registries are still fired in alphabetical order, after all vanilla registries. Move forge's data_serializers registry to forge namespace.
This commit is contained in:
1 parent
0c35436217
commit
9b144f4541
5 files changed
+25
-12
No files matched your search
@@ -142,7 +142,7 @@ public class ForgeRegistries
|
||||
public static final ResourceKey<Registry<Biome>> BIOMES = key("worldgen/biome");
|
||||
|
||||
// Forge
|
||||
public static final ResourceKey<Registry<EntityDataSerializer<?>>> DATA_SERIALIZERS = key("data_serializers");
|
||||
public static final ResourceKey<Registry<EntityDataSerializer<?>>> DATA_SERIALIZERS = key("forge:data_serializers");
|
||||
public static final ResourceKey<Registry<GlobalLootModifierSerializer<?>>> LOOT_MODIFIER_SERIALIZERS = key("forge:loot_modifier_serializers");
|
||||
public static final ResourceKey<Registry<ForgeWorldPreset>> WORLD_TYPES = key("forge:world_types");
|
||||
public static final ResourceKey<Registry<Codec<? extends BiomeModifier>>> BIOME_MODIFIER_SERIALIZERS = key("forge:biome_modifier_serializers");
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.mojang.serialization.Lifecycle;
|
||||
import java.util.LinkedHashSet;
|
||||
import net.minecraft.core.DefaultedRegistry;
|
||||
import net.minecraft.core.IdMapper;
|
||||
import net.minecraft.core.MappedRegistry;
|
||||
@@ -297,20 +298,14 @@ public class GameData
|
||||
Set<ResourceLocation> keySet = new HashSet<>(RegistryManager.ACTIVE.registries.keySet());
|
||||
keySet.addAll(RegistryManager.getVanillaRegistryKeys());
|
||||
keySet.addAll(BuiltinRegistries.REGISTRY.keySet());
|
||||
List<ResourceLocation> keys = keySet.stream()
|
||||
.sorted((o1, o2) -> String.valueOf(o1).compareToIgnoreCase(String.valueOf(o2)))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
//Move Blocks to first, and Items to second.
|
||||
keys.remove(BLOCKS.location());
|
||||
keys.remove(ITEMS.location());
|
||||
|
||||
keys.add(0, BLOCKS.location());
|
||||
keys.add(1, ITEMS.location());
|
||||
Set<ResourceLocation> ordered = new LinkedHashSet<>(MappedRegistry.getKnownRegistries());
|
||||
ordered.retainAll(keySet);
|
||||
ordered.addAll(keySet.stream().sorted(ResourceLocation::compareNamespaced).toList());
|
||||
|
||||
RuntimeException aggregate = new RuntimeException();
|
||||
|
||||
for (ResourceLocation rootRegistryName : keys)
|
||||
for (ResourceLocation rootRegistryName : ordered)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -52,6 +52,7 @@ class NamespacedDefaultedWrapper<T> extends DefaultedRegistry<T> implements ILoc
|
||||
throw new IllegalStateException("Can not register to a locked registry. Modder should use Forge Register methods.");
|
||||
|
||||
Validate.notNull(value);
|
||||
markKnown();
|
||||
this.elementsLifecycle = this.elementsLifecycle.add(lifecycle);
|
||||
|
||||
T oldValue = this.delegate.getRaw(key.location());
|
||||
|
||||
@@ -55,6 +55,7 @@ class NamespacedWrapper<T> extends MappedRegistry<T> implements ILockableRegistr
|
||||
throw new IllegalStateException("Can not register to a locked registry. Modder should use Forge Register methods.");
|
||||
|
||||
Validate.notNull(value);
|
||||
markKnown();
|
||||
this.elementsLifecycle = this.elementsLifecycle.add(lifecycle);
|
||||
|
||||
T oldValue = get(key);
|
||||
|
||||
Reference in new issue
Block a user