mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-10-25 20:22:23 +00:00
Probably less thread unsafe. (#164)
This commit is contained in:
1 parent
efb918fc6d
commit
af923d1977
1 file changed
+8
-5
@@ -2,10 +2,11 @@ package crazypants.enderio.conduit.liquid;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
@@ -113,27 +114,28 @@ public class LiquidConduitRenderer extends DefaultConduitRenderer implements IRe
|
||||
}
|
||||
}
|
||||
|
||||
private static Map<CollidableComponent, Map<Fluid, List<CachableRenderStatement>>> cache = new WeakHashMap<CollidableComponent, Map<Fluid, List<CachableRenderStatement>>>();
|
||||
private static final Map<CollidableComponent, Map<Fluid, List<CachableRenderStatement>>> cache = Collections
|
||||
.synchronizedMap(new WeakHashMap<>());
|
||||
|
||||
public static List<CachableRenderStatement> computeFluidOutlineToCache(CollidableComponent component, Fluid fluid,
|
||||
double scaleFactor, float outlineWidth) {
|
||||
|
||||
Map<Fluid, List<CachableRenderStatement>> cache0 = cache.get(component);
|
||||
if (cache0 == null) {
|
||||
cache0 = new HashMap<Fluid, List<CachableRenderStatement>>();
|
||||
cache0 = new ConcurrentHashMap<>();
|
||||
cache.put(component, cache0);
|
||||
}
|
||||
List<CachableRenderStatement> data = cache0.get(fluid);
|
||||
if (data != null) {
|
||||
return data;
|
||||
}
|
||||
data = new ArrayList<CachableRenderStatement>();
|
||||
cache0.put(fluid, data);
|
||||
data = new ArrayList<>();
|
||||
|
||||
IIcon texture = fluid.getStillIcon();
|
||||
if (texture == null) {
|
||||
texture = fluid.getIcon();
|
||||
if (texture == null) {
|
||||
cache0.put(fluid, data);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -192,6 +194,7 @@ public class LiquidConduitRenderer extends DefaultConduitRenderer implements IRe
|
||||
}
|
||||
}
|
||||
}
|
||||
cache0.put(fluid, data);
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user