diff options
author | Linnea Gräf <nea@nea.moe> | 2024-12-31 16:52:29 +0100 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-12-31 16:52:29 +0100 |
commit | a892a5f90b87b530331a7652dd4eb5bc07bf1c03 (patch) | |
tree | 808ac4b59557b2b0a6c8459a2dac13ce272937a6 /src/main/kotlin/util/mc/TolerantRegistriesOps.kt | |
parent | 533fd68e2be8236c842f53fd0cafa52341226226 (diff) | |
parent | 620f1a45ac02b078e95c68a59a45bd4d24ff176b (diff) | |
download | Firmament-a892a5f90b87b530331a7652dd4eb5bc07bf1c03.tar.gz Firmament-a892a5f90b87b530331a7652dd4eb5bc07bf1c03.tar.bz2 Firmament-a892a5f90b87b530331a7652dd4eb5bc07bf1c03.zip |
Merge branch 'mc-1.21.3'
Diffstat (limited to 'src/main/kotlin/util/mc/TolerantRegistriesOps.kt')
-rw-r--r-- | src/main/kotlin/util/mc/TolerantRegistriesOps.kt | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/main/kotlin/util/mc/TolerantRegistriesOps.kt b/src/main/kotlin/util/mc/TolerantRegistriesOps.kt new file mode 100644 index 0000000..ce596a0 --- /dev/null +++ b/src/main/kotlin/util/mc/TolerantRegistriesOps.kt @@ -0,0 +1,29 @@ +package moe.nea.firmament.util.mc + +import com.mojang.serialization.DynamicOps +import java.util.Optional +import net.minecraft.registry.Registry +import net.minecraft.registry.RegistryKey +import net.minecraft.registry.RegistryOps +import net.minecraft.registry.RegistryWrapper +import net.minecraft.registry.entry.RegistryEntryOwner + +class TolerantRegistriesOps<T>( + delegate: DynamicOps<T>, + registryInfoGetter: RegistryInfoGetter +) : RegistryOps<T>(delegate, registryInfoGetter) { + constructor(delegate: DynamicOps<T>, registry: RegistryWrapper.WrapperLookup) : + this(delegate, CachedRegistryInfoGetter(registry)) + + class TolerantOwner<E> : RegistryEntryOwner<E> { + override fun ownerEquals(other: RegistryEntryOwner<E>?): Boolean { + return true + } + } + + override fun <E : Any?> getOwner(registryRef: RegistryKey<out Registry<out E>>?): Optional<RegistryEntryOwner<E>> { + return super.getOwner(registryRef).map { + TolerantOwner() + } + } +} |