mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-21 04:32:15 +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
@@ -1,6 +1,22 @@
|
||||
--- a/net/minecraft/core/MappedRegistry.java
|
||||
+++ b/net/minecraft/core/MappedRegistry.java
|
||||
@@ -90,7 +_,8 @@
|
||||
@@ -83,14 +_,24 @@
|
||||
return this.m_205857_(p_205853_, p_205854_, p_205855_, p_205856_, true);
|
||||
}
|
||||
|
||||
+ private static final Set<ResourceLocation> KNOWN = new java.util.LinkedHashSet<>();
|
||||
+ public static Set<ResourceLocation> getKnownRegistries() {
|
||||
+ return java.util.Collections.unmodifiableSet(KNOWN);
|
||||
+ }
|
||||
+ protected final void markKnown() {
|
||||
+ KNOWN.add(m_123023_().m_135782_());
|
||||
+ }
|
||||
+
|
||||
private Holder<T> m_205857_(int p_205858_, ResourceKey<T> p_205859_, T p_205860_, Lifecycle p_205861_, boolean p_205862_) {
|
||||
+ markKnown();
|
||||
this.m_205921_(p_205859_);
|
||||
Validate.notNull(p_205859_);
|
||||
Validate.notNull(p_205860_);
|
||||
this.f_122672_.size(Math.max(this.f_122672_.size(), p_205858_ + 1));
|
||||
this.f_122673_.put(p_205860_, p_205858_);
|
||||
this.f_211051_ = null;
|
||||
|
||||
@@ -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