From 12e8d95e9fbf3e716cf2762e4cf7b55cdb0e9682 Mon Sep 17 00:00:00 2001 From: Lex Manos Date: Wed, 2 Apr 2014 23:53:05 -0700 Subject: [PATCH] Fix potential threading issue if FluidRegistry.loopupFluidForBlock is called from two threads at the same time before being setup. Closes #936 --- src/main/java/net/minecraftforge/fluids/FluidRegistry.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/minecraftforge/fluids/FluidRegistry.java b/src/main/java/net/minecraftforge/fluids/FluidRegistry.java index b3a7e1691..4fb50d12f 100644 --- a/src/main/java/net/minecraftforge/fluids/FluidRegistry.java +++ b/src/main/java/net/minecraftforge/fluids/FluidRegistry.java @@ -148,14 +148,15 @@ public abstract class FluidRegistry { if (fluidBlocks == null) { - fluidBlocks = HashBiMap.create(); + BiMap tmp = HashBiMap.create(); for (Fluid fluid : fluids.values()) { if (fluid.canBePlacedInWorld() && fluid.getBlock() != null) { - fluidBlocks.put(fluid.getBlock(), fluid); + tmp.put(fluid.getBlock(), fluid); } } + fluidBlocks = tmp; } return fluidBlocks.get(block); }