mirror of
https://github.com/FabricMC/fabric.git
synced 2025-04-21 11:20:55 -04:00
Fix log spam with multiple calls to combinedItemApiProvider
(#3387)
(cherry picked from commitd6f4a34e15
) (cherry picked from commitbb1ee60efb
)
This commit is contained in:
parent
ae9f657a88
commit
1bc31aeb60
1 changed files with 6 additions and 2 deletions
|
@ -82,10 +82,14 @@ public class CombinedProvidersImpl {
|
|||
}
|
||||
|
||||
public static Event<FluidStorage.CombinedItemApiProvider> getOrCreateItemEvent(Item item) {
|
||||
// register here is thread-safe, so the query below will return a valid provider (possibly one registered before or from another thread).
|
||||
FluidStorage.ITEM.registerForItems(new Provider(), item);
|
||||
ItemApiLookup.ItemApiProvider<Storage<FluidVariant>, ContainerItemContext> existingProvider = FluidStorage.ITEM.getProvider(item);
|
||||
|
||||
if (existingProvider == null) {
|
||||
FluidStorage.ITEM.registerForItems(new Provider(), item);
|
||||
// The provider might not be new Provider() if a concurrent registration happened, re-query.
|
||||
existingProvider = FluidStorage.ITEM.getProvider(item);
|
||||
}
|
||||
|
||||
if (existingProvider instanceof Provider registeredProvider) {
|
||||
return registeredProvider.event;
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue