Fix getCameraEntity not being thread safe (concurrent event registration) even though called from multiple threads

This commit is contained in:
johni0702
2015-07-17 11:48:32 +02:00
parent a55173ffc7
commit 71952e94dd

View File

@@ -31,6 +31,7 @@ import net.minecraft.network.EnumPacketDirection;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.play.INetHandlerPlayClient;
import net.minecraft.util.ReportedException;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher;
@@ -205,7 +206,14 @@ public class ReplayHandler {
}
public static CameraEntity getCameraEntity() {
if(cameraEntity == null && mc.theWorld != null) cameraEntity = new CameraEntity(mc.theWorld);
if(cameraEntity == null && mc.theWorld != null) {
synchronized (ReplayHandler.class) {
World world = mc.theWorld;
if (cameraEntity == null && world != null) {
cameraEntity = new CameraEntity(world);
}
}
}
return cameraEntity;
}