Skip to content

Commit

Permalink
[1.21.1] Adjust DeferredRegister$DataComponents constructor to acce…
Browse files Browse the repository at this point in the history
…pt registry key (#1522)
  • Loading branch information
dhyces authored Sep 10, 2024
1 parent 42ad3e8 commit a1640e1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,20 @@ public static DeferredRegister.Blocks createBlocks(String modid) {
return new Blocks(modid);
}

/**
* Factory for a specialized DeferredRegister for {@link DataComponentType DataComponentTypes}.
*
* @param registryKey The key for the data component type registry, like {@link Registries#DATA_COMPONENT_TYPE} for item data components
* @param modid The namespace for all objects registered to this DeferredRegister
* @see #create(Registry, String)
* @see #create(ResourceKey, String)
* @see #create(ResourceLocation, String)
* @see #createItems(String)
*/
public static DataComponents createDataComponents(ResourceKey<Registry<DataComponentType<?>>> registryKey, String modid) {
return new DataComponents(registryKey, modid);
}

/**
* Factory for a specialized DeferredRegister for {@link DataComponentType DataComponentTypes}.
*
Expand All @@ -164,7 +178,9 @@ public static DeferredRegister.Blocks createBlocks(String modid) {
* @see #create(ResourceKey, String)
* @see #create(ResourceLocation, String)
* @see #createItems(String)
* @deprecated Scheduled for removal in 1.21.2; use {@link DeferredRegister#createDataComponents(ResourceKey, String)} with {@link Registries#DATA_COMPONENT_TYPE} instead
*/
@Deprecated(since = "1.21.1", forRemoval = true)
public static DataComponents createDataComponents(String modid) {
return new DataComponents(modid);
}
Expand Down Expand Up @@ -599,6 +615,12 @@ protected <I extends Item> DeferredItem<I> createHolder(ResourceKey<? extends Re
* Specialized DeferredRegister for {@link DataComponentType DataComponentTypes}.
*/
public static class DataComponents extends DeferredRegister<DataComponentType<?>> {
protected DataComponents(ResourceKey<Registry<DataComponentType<?>>> registryKey, String namespace) {
super(registryKey, namespace);
}

/** @deprecated Scheduled for removal in 1.21.2; use {@link DataComponents#DataComponents(ResourceKey, String)} */
@Deprecated(since = "1.21.1", forRemoval = true)
protected DataComponents(String namespace) {
super(Registries.DATA_COMPONENT_TYPE, namespace);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class DeferredRegistryTest {
private static final Logger LOGGER = LogManager.getLogger();

private static final DeferredRegister.Blocks BLOCKS = DeferredRegister.createBlocks(MODID);
private static final DeferredRegister.DataComponents COMPONENTS = DeferredRegister.createDataComponents(MODID);
private static final DeferredRegister.DataComponents COMPONENTS = DeferredRegister.createDataComponents(Registries.DATA_COMPONENT_TYPE, MODID);
private static final DeferredRegister.Items ITEMS = DeferredRegister.createItems(MODID);
private static final ResourceKey<Registry<Custom>> CUSTOM_REGISTRY_KEY = ResourceKey.createRegistryKey(ResourceLocation.fromNamespaceAndPath(MODID, "test_registry"));
private static final DeferredRegister<Custom> CUSTOMS = DeferredRegister.create(CUSTOM_REGISTRY_KEY, MODID);
Expand Down

0 comments on commit a1640e1

Please sign in to comment.