diff --git a/src/main/java/org/spongepowered/common/registry/RegistryHolderLogic.java b/src/main/java/org/spongepowered/common/registry/RegistryHolderLogic.java index 5fa7a4589bd..6aa0912b050 100644 --- a/src/main/java/org/spongepowered/common/registry/RegistryHolderLogic.java +++ b/src/main/java/org/spongepowered/common/registry/RegistryHolderLogic.java @@ -178,19 +178,16 @@ public Registry createRegistry(final RegistryType type, final @Nullabl if (defaultValues != null) { final MappedRegistry mr = (MappedRegistry) registry; defaultValues.forEach((vk, vi, vv) -> { - if (vi.isPresent()) { - mr.register( - net.minecraft.resources.ResourceKey.create(key, (ResourceLocation) (Object) vk), - vv, - RegistrationInfo.BUILT_IN - ); - } else { - mr.register( - net.minecraft.resources.ResourceKey.create(key, (ResourceLocation) (Object) vk), - vv, - RegistrationInfo.BUILT_IN - ); - } + mr.register( + net.minecraft.resources.ResourceKey.create(key, (ResourceLocation) (Object) vk), + vv, + RegistrationInfo.BUILT_IN + ); + vi.ifPresent(id -> { + if (mr.getId(vv) != id) { + throw new IllegalStateException("Registry entry " + vk + " was expected to have id of " + id + " but was instead " + mr.getId(vv)); + } + }); }); } diff --git a/src/main/java/org/spongepowered/common/registry/RegistryLoader.java b/src/main/java/org/spongepowered/common/registry/RegistryLoader.java index b16aaa5d37b..8521b091e51 100644 --- a/src/main/java/org/spongepowered/common/registry/RegistryLoader.java +++ b/src/main/java/org/spongepowered/common/registry/RegistryLoader.java @@ -30,6 +30,7 @@ import org.spongepowered.api.registry.RegistryKey; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.Map; import java.util.function.Consumer; import java.util.function.Function; @@ -37,7 +38,7 @@ public final class RegistryLoader extends InitialRegistryData { - private final Map values = new HashMap<>(); + private final Map values = new LinkedHashMap<>(); private @MonotonicNonNull Map ids; private RegistryLoader() { diff --git a/src/main/java/org/spongepowered/common/registry/loader/VanillaRegistryLoader.java b/src/main/java/org/spongepowered/common/registry/loader/VanillaRegistryLoader.java index 6a04310d6d7..ab2279e8cb9 100644 --- a/src/main/java/org/spongepowered/common/registry/loader/VanillaRegistryLoader.java +++ b/src/main/java/org/spongepowered/common/registry/loader/VanillaRegistryLoader.java @@ -251,11 +251,11 @@ private static RegistryLoader criterion() { private static RegistryLoader fireworkShape() { return RegistryLoader.of(l -> { - l.addWithId(FireworkExplosion.Shape.BURST.getId(), FireworkShapes.BURST, () -> (FireworkShape) (Object) FireworkExplosion.Shape.BURST); - l.addWithId(FireworkExplosion.Shape.CREEPER.getId(), FireworkShapes.CREEPER, () -> (FireworkShape) (Object) FireworkExplosion.Shape.CREEPER); - l.addWithId(FireworkExplosion.Shape.LARGE_BALL.getId(), FireworkShapes.LARGE_BALL, () -> (FireworkShape) (Object) FireworkExplosion.Shape.LARGE_BALL); l.addWithId(FireworkExplosion.Shape.SMALL_BALL.getId(), FireworkShapes.SMALL_BALL, () -> (FireworkShape) (Object) FireworkExplosion.Shape.SMALL_BALL); + l.addWithId(FireworkExplosion.Shape.LARGE_BALL.getId(), FireworkShapes.LARGE_BALL, () -> (FireworkShape) (Object) FireworkExplosion.Shape.LARGE_BALL); l.addWithId(FireworkExplosion.Shape.STAR.getId(), FireworkShapes.STAR, () -> (FireworkShape) (Object) FireworkExplosion.Shape.STAR); + l.addWithId(FireworkExplosion.Shape.CREEPER.getId(), FireworkShapes.CREEPER, () -> (FireworkShape) (Object) FireworkExplosion.Shape.CREEPER); + l.addWithId(FireworkExplosion.Shape.BURST.getId(), FireworkShapes.BURST, () -> (FireworkShape) (Object) FireworkExplosion.Shape.BURST); }); }