11package com.lambda.core.registry
22
3- import com.lambda.util.Communication.warn
43import net.minecraft.registry.Registry
54import net.minecraft.registry.RegistryKey
65import net.minecraft.registry.entry.RegistryEntry
@@ -49,12 +48,14 @@ object AgnosticRegistries {
4948 *
5049 * @param registry The registry to dump into.
5150 * @param wrapper The registry wrapper to use to determine how to register the entry.
51+ *
52+ * @return Whether there were temporary registries or not.
5253 */
53- fun dump (registry : Registry <* >? , wrapper : RegistryWrapper <* >? ) {
54- val key = registry?.key ? : return warn( " Tried to dump into a null registry. " )
54+ fun dump (registry : Registry <* >? , wrapper : RegistryWrapper <* >? ): Boolean {
55+ val key = registry?.key
5556
5657 registries[key]?.forEach { it.handleRegister(wrapper ? : defaultWrapper(registry)) }
57- registries.remove(key)
58+ return registries.remove(key) != null
5859 }
5960
6061 /* *
@@ -63,6 +64,7 @@ object AgnosticRegistries {
6364 private fun defaultWrapper (registry : Registry <* >? ): RegistryWrapper <* > {
6465 return object : RegistryWrapper <Any > {
6566 override fun <T > registerForHolder (id : Identifier ? , value : T ): RegistryEntry <T > {
67+ @Suppress(" UNCHECKED_CAST" )
6668 return Registry .registerReference(registry as Registry <T >, id, value)
6769 }
6870 }
0 commit comments