@@ -43,6 +43,15 @@ private static <T, U extends IRegistrable<T>> U appendRegistrable(Map<String, Li
4343 return registrable ;
4444 }
4545
46+ /**
47+ * Get all registries created by SinoCore for a mod and registry key.
48+ *
49+ * @param modId Mod Id.
50+ * @param key Registry key.
51+ * @param <T> Registry entry type.
52+ * @param <U> Registry type.
53+ * @return List of registries.
54+ */
4655 @ SuppressWarnings ("unchecked" )
4756 public static <T , U extends IRegistryBase <T >> List <U > getRegistries (String modId , ResourceKey <Registry <T >> key ) {
4857 if (!REGISTRIES .containsKey (modId )) {
@@ -59,27 +68,62 @@ public static <T, U extends IRegistryBase<T>> List<U> getRegistries(String modId
5968 .build ();
6069 }
6170
71+ /**
72+ * Check if a registry exists.
73+ *
74+ * @param key Registry key.
75+ * @param <T> Registry entry type.
76+ * @return true if exists.
77+ */
6278 public static <T > boolean hasRegistry (ResourceKey <Registry <T >> key ) {
6379 if (!key .isFor (BuiltInRegistries .REGISTRY .key ())) {
6480 return false ;
6581 }
6682 return BuiltInRegistries .REGISTRY .containsKey (key .location ());
6783 }
6884
85+ /**
86+ * Get a registry by its key.
87+ *
88+ * @param key Registry key.
89+ * @param <T> Registry entry type.
90+ * @return The registry, or null if not found.
91+ */
6992 @ Nullable
7093 @ SuppressWarnings ("unchecked" )
7194 public static <T > Registry <T > getRegistry (ResourceKey <Registry <T >> key ) {
7295 return (Registry <T >) BuiltInRegistries .REGISTRY .get (key .location ());
7396 }
7497
98+ /**
99+ * Create a new registry (sync by default).
100+ *
101+ * @param key Registry key.
102+ * @param <T> Registry entry type.
103+ * @return The created registry.
104+ */
75105 public static <T > Registry <T > createRegistry (ResourceKey <Registry <T >> key ) {
76106 return createRegistry (new RegistryBuilder <>(key ).sync ());
77107 }
78108
109+ /**
110+ * Create a new registry.
111+ *
112+ * @param builder Registry builder.
113+ * @param <T> Registry entry type.
114+ * @return The created registry.
115+ */
79116 public static <T > Registry <T > createRegistry (RegistryBuilder <T > builder ) {
80117 return RegistryPlatform .createRegistry (builder );
81118 }
82119
120+ /**
121+ * Get if the registry exists, otherwise create a new one (sync by default).
122+ *
123+ * @param key Registry key.
124+ * @param <T> Registry entry type.
125+ * @return The registry.
126+ */
83127 public static <T > Registry <T > getOrCreateRegistry (ResourceKey <Registry <T >> key ) {
84128 Registry <T > registry = getRegistry (key );
85129 if (registry != null ) {
0 commit comments