Skip to content

Commit 229eca5

Browse files
committed
return bool if key exists
1 parent 5ac1fab commit 229eca5

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

common/src/main/kotlin/com/lambda/core/registry/AgnosticRegistries.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.lambda.core.registry
22

3-
import com.lambda.util.Communication.warn
43
import net.minecraft.registry.Registry
54
import net.minecraft.registry.RegistryKey
65
import 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

Comments
 (0)