Merge branch '1.20.1' of https://git.dbotthepony.ru/DBot/overdrive_that_matters into 1.19.4
This commit is contained in:
commit
cc164f669d
@ -22,8 +22,8 @@ import kotlin.reflect.KProperty
|
|||||||
/**
|
/**
|
||||||
* DeferredRegister which allows parallel initialization
|
* DeferredRegister which allows parallel initialization
|
||||||
*/
|
*/
|
||||||
class MDeferredRegister<R : Any>(val registry: ResourceKey<out Registry<R>>, val modId: String = OverdriveThatMatters.MOD_ID) {
|
class MDeferredRegister<R : Any>(val registry: ResourceKey<out Registry<R>>, val modId: String = OverdriveThatMatters.MOD_ID, val allowParallel: Boolean = false) {
|
||||||
constructor(registry: IForgeRegistry<R>, modId: String = OverdriveThatMatters.MOD_ID) : this(registry.registryKey, modId)
|
constructor(registry: IForgeRegistry<R>, modId: String = OverdriveThatMatters.MOD_ID, allowParallel: Boolean = false) : this(registry.registryKey, modId, allowParallel)
|
||||||
|
|
||||||
private val entries = Object2ObjectLinkedOpenHashMap<String, Entry<R>>()
|
private val entries = Object2ObjectLinkedOpenHashMap<String, Entry<R>>()
|
||||||
private var allowRegistration = true
|
private var allowRegistration = true
|
||||||
@ -74,8 +74,10 @@ class MDeferredRegister<R : Any>(val registry: ResourceKey<out Registry<R>>, val
|
|||||||
check(allowRegistration) { "Unable to register new entries after RegisterEvent has been fired" }
|
check(allowRegistration) { "Unable to register new entries after RegisterEvent has been fired" }
|
||||||
require(entries.put(name, this) == null) { "Duplicate entry $name for registry $registry" }
|
require(entries.put(name, this) == null) { "Duplicate entry $name for registry $registry" }
|
||||||
|
|
||||||
if (stages.isEmpty() || stages.last().serial != serial) {
|
val actualSerial = if (allowParallel) serial else true
|
||||||
val stage = RegistrationStage(serial)
|
|
||||||
|
if (stages.isEmpty() || stages.last().serial != actualSerial) {
|
||||||
|
val stage = RegistrationStage(actualSerial)
|
||||||
stage.add(this)
|
stage.add(this)
|
||||||
stages.add(stage)
|
stages.add(stage)
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user