diff options
author | Linnea Gräf <nea@nea.moe> | 2024-12-23 23:53:27 +0100 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-12-23 23:53:27 +0100 |
commit | 39d35afb702cf017569ef9594774561848db7494 (patch) | |
tree | b8ce02020bebced97115373507d37ffc713e49e2 /src/main/kotlin/util | |
parent | 656958937fe29da90d7229b979996a68b5ea5b67 (diff) | |
download | Firmament-39d35afb702cf017569ef9594774561848db7494.tar.gz Firmament-39d35afb702cf017569ef9594774561848db7494.tar.bz2 Firmament-39d35afb702cf017569ef9594774561848db7494.zip |
fix: Some items not being saved in /firm stoarge
Diffstat (limited to 'src/main/kotlin/util')
-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() + } + } +} |