-
For forge turtle upgrades registration is fairly straightforward. However, when it comes to fabric, how do I suppose to register turtle upgrades? I, obviously, need access to created registries, because created my own will not help (fabric in general mostly about registry extending that creating it own), but for now code doesn't store them anywhere and I am forced to retrieve them dynamically. And very strange thing about this, that this code: println(RegistriesAccessor.getROOT().keySet())
val turtleSerializerRegister = RegistriesAccessor.getROOT().get(TurtleUpgradeSerialiser.REGISTRY_ID.location()) as Registry<TurtleUpgradeSerialiser<*>>
val pocketSerializerRegister = RegistriesAccessor.getROOT().get(PocketUpgradeSerialiser.REGISTRY_ID.location()) as Registry<PocketUpgradeSerialiser<*>> works, but this val turtleSerializerRegister = RegistriesAccessor.getROOT().get(TurtleUpgradeSerialiser.REGISTRY_ID.location()) as Registry<TurtleUpgradeSerialiser<*>>
val pocketSerializerRegister = RegistriesAccessor.getROOT().get(PocketUpgradeSerialiser.REGISTRY_ID.location()) as Registry<PocketUpgradeSerialiser<*>> Throws NullPointerException, because PS: And of course, this behavior inconsistent! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Okey, I have answer now. You should use RegistryEntryAddedCallback event to resolve this issue. So, when you trying to access registries and they are not available, you should register callback for RegistryEntryAddedCallback, but if registries are available, you must register with them, because you will not have any RegistryEntryAddedCallback event for them. |
Beta Was this translation helpful? Give feedback.
-
Okey, code still goes out of control with this problem PeripheralWorksPlatform.registerTurtleUpgrade(
PeripheraliumHubPeripheral.ID,
TurtleUpgradeSerialiser.simpleWithCustomItem {_, stack ->
return@simpleWithCustomItem PeripheraliumHubTurtleUpgrade(PeripheralWorksConfig.peripheraliumHubUpgradeCount, stack)
}, { dataProvider, serializer ->
dataProvider.simpleWithCustomItem(
PeripheraliumHubPeripheral.ID,
serializer, Items.PERIPHERALIUM_HUB.get()
)
},
listOf(Consumer{
PeripheralWorksClientCore.registerHook { ComputerCraftAPIClient.registerTurtleUpgradeModeller(
it.get(), TurtleUpgradeModeller.flatItem()
) }
})
) @SquidDev can we have some special API for fabric for registration update in registries or just this registries exposed directly? |
Beta Was this translation helpful? Give feedback.
Okey, I have answer now. You should use RegistryEntryAddedCallback event to resolve this issue.
So, when you trying to access registries and they are not available, you should register callback for RegistryEntryAddedCallback, but if registries are available, you must register with them, because you will not have any RegistryEntryAddedCallback event for them.