fix: Some items not being saved in /firm stoarge

This commit is contained in:
Linnea Gräf
2024-12-23 23:53:27 +01:00
parent 656958937f
commit 39d35afb70
4 changed files with 95 additions and 36 deletions

View File

@@ -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()
}
}
}