Fix potential threading issue if FluidRegistry.loopupFluidForBlock is called from two threads at the same time before being setup. Closes #936

This commit is contained in:
Lex Manos 2014-04-02 23:53:05 -07:00
parent 14b9d639a2
commit 12e8d95e9f
1 changed files with 3 additions and 2 deletions

View File

@ -148,14 +148,15 @@ public abstract class FluidRegistry
{
if (fluidBlocks == null)
{
fluidBlocks = HashBiMap.create();
BiMap<Block, Fluid> 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);
}