diff --git a/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/impl/transfer/fluid/CombinedProvidersImpl.java b/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/impl/transfer/fluid/CombinedProvidersImpl.java index 54ca2481da..0231d2007a 100644 --- a/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/impl/transfer/fluid/CombinedProvidersImpl.java +++ b/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/impl/transfer/fluid/CombinedProvidersImpl.java @@ -82,10 +82,14 @@ public Storage find(ItemStack itemStack, ContainerItemContext cont } public static Event 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, 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 {