diff --git a/src/main/java/crazypants/enderio/conduit/liquid/LiquidConduitRenderer.java b/src/main/java/crazypants/enderio/conduit/liquid/LiquidConduitRenderer.java index 892e450468..0227292fe1 100644 --- a/src/main/java/crazypants/enderio/conduit/liquid/LiquidConduitRenderer.java +++ b/src/main/java/crazypants/enderio/conduit/liquid/LiquidConduitRenderer.java @@ -120,11 +120,12 @@ public static void renderFluidOutline(CollidableComponent component, FluidStack public static List computeFluidOutlineToCache(CollidableComponent component, Fluid fluid, double scaleFactor, float outlineWidth) { - Map> cache0 = cache.get(component); - if (cache0 == null) { - cache0 = new ConcurrentHashMap<>(); - cache.put(component, cache0); - } + // Only init once per component across all threads so the cache stays accurate. + Map> cache0 = cache + .computeIfAbsent(component, _k -> new ConcurrentHashMap<>()); + // The rest of this function 'should' be in a `computeIfAbsent` as well for: + // `cache0.computeIfAbsent(fluid, _k -> ...)` but that won't cause a bug in this case, + // just a bit more garbage. List data = cache0.get(fluid); if (data != null) { return data;